Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ endif
poetry run mypy $(PACKAGES) --config-file=.mypy.ini
poetry run pylint $(PACKAGES) --rcfile=.pylint.ini
poetry run pydocstyle $(PACKAGES) $(CONFIG)
poetry run ruff check

# TESTS #######################################################################

Expand Down
17 changes: 17 additions & 0 deletions doorstop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@

__project__ = "Doorstop"

__all__ = [
"DoorstopError",
"DoorstopInfo",
"DoorstopWarning",
"Document",
"Item",
"Tree",
"build",
"builder",
"editor",
"exporter",
"find_document",
"find_item",
"importer",
"publisher",
]

try:
__version__ = version(__project__)
except PackageNotFoundError:
Expand Down
1 change: 0 additions & 1 deletion doorstop/cli/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import unittest

from doorstop import settings
from doorstop.cli.main import main

ROOT = os.path.join(os.path.dirname(__file__), "..", "..", "..")
REQS = os.path.join(ROOT, "reqs")
Expand Down
18 changes: 9 additions & 9 deletions doorstop/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,30 +307,30 @@ def update_data_from_markdown_content(data, content, textattributekeys):
if "header" in textattributekeys:
# search for first content line and check
# if it is a h1 header
for l in s:
for line in s:
# skip empty lines
if len(l.strip()) == 0:
if len(line.strip()) == 0:
continue
# check if first found line is a header
m = h1.match(l.strip())
m = h1.match(line.strip())
if m:
# header found
header = m.group(1)
else:
# no header found, add to normal text
text += l
text += line
break

# if header was found, skip empty lines before main text
if header:
for l in s:
if len(l.strip()) != 0:
text += l
for line in s:
if len(line.strip()) != 0:
text += line
break

# remaining content is normal text
for l in s:
text += l
for line in s:
text += line

if "header" in textattributekeys and header:
data["header"] = header
Expand Down
9 changes: 9 additions & 0 deletions doorstop/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@
from doorstop.core.document import Document
from doorstop.core.item import Item
from doorstop.core.tree import Tree

__all__ = [
"build",
"find_document",
"find_item",
"Document",
"Item",
"Tree",
]
15 changes: 0 additions & 15 deletions doorstop/core/publishers/tests/test_publisher_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# pylint: disable=unused-argument,protected-access

import os
import stat
import unittest
from secrets import token_hex
from shutil import rmtree
Expand Down Expand Up @@ -41,20 +40,6 @@ def tearDownClass(cls):
"""Remove test folder."""
rmtree("mock_%s" % __name__, onerror=on_error_with_retry)

@patch("os.path.isdir", Mock(side_effect=[False, False, False, False]))
@patch("os.makedirs")
@patch("builtins.open")
def test_publish_document(self, mock_open, mock_makedirs):
"""Verify a document can be published."""
path = os.path.join(self.dirpath, "published.html")
self.document.items = []
# Act
path2 = publisher.publish(self.document, path)
# Assert
self.assertIs(path, path2)
mock_makedirs.assert_called_once_with(self.dirpath)
mock_open.assert_called_once_with(path, "wb")

@patch("os.path.isdir", Mock(return_value=False))
@patch("os.makedirs")
@patch("builtins.open")
Expand Down
1 change: 0 additions & 1 deletion doorstop/core/publishers/tests/test_publisher_html_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# pylint: disable=unused-argument,protected-access

import os
import stat
import unittest
from secrets import token_hex
from shutil import rmtree
Expand Down
1 change: 0 additions & 1 deletion doorstop/core/publishers/tests/test_publisher_latex_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# pylint: disable=unused-argument,protected-access

import os
import stat
import unittest
from secrets import token_hex
from shutil import rmtree
Expand Down
1 change: 0 additions & 1 deletion doorstop/core/publishers/tests/test_publisher_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
MockItemAndVCS,
)
from doorstop.core.tests.helpers import on_error_with_retry
from doorstop.core.types import UID


class TestModule(MockDataMixIn, unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# pylint: disable=unused-argument,protected-access

import os
import stat
import unittest
from secrets import token_hex
from shutil import rmtree
Expand Down
10 changes: 0 additions & 10 deletions doorstop/core/publishers/tests/test_publisher_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# pylint: disable=unused-argument,protected-access

import os
import stat
import unittest
from secrets import token_hex
from shutil import rmtree
Expand Down Expand Up @@ -108,15 +107,6 @@ def test_lines_text_item_with_child_links(self):
# Assert
self.assertIn("Child links: tst1", text)

def test_lines_text_item(self):
"""Verify text can be published from an item."""
with patch.object(
self.item5, "find_ref", Mock(return_value=("path/to/mock/file", 42))
):
lines = publisher.publish_lines(self.item5, ".txt")
text = "".join(line + "\n" for line in lines)
self.assertIn("Reference: path/to/mock/file (line 42)", text)

@patch("doorstop.settings.ENABLE_HEADERS", True)
def test_setting_enable_headers_true(self):
"""Verify that the settings.ENABLE_HEADERS changes the output appropriately when True."""
Expand Down
6 changes: 4 additions & 2 deletions doorstop/core/publishers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ def lines(self, obj, **_):
label = "Parent links: "
else:
label = "Links: "
slinks = label + ", ".join(str(l) for l in item.links)
slinks = label + ", ".join(str(link) for link in item.links)
yield from self._chunks(slinks)
if settings.PUBLISH_CHILD_LINKS:
links = item.find_child_links()
if links:
yield "" # break before links
slinks = "Child links: " + ", ".join(str(l) for l in links)
slinks = "Child links: " + ", ".join(
str(link) for link in links
)
yield from self._chunks(slinks)

# Attributes
Expand Down
4 changes: 2 additions & 2 deletions doorstop/core/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_issues_duplicate_level(self):
expect = DoorstopWarning("duplicate level: 2.1 (REQ002, REQ2-001)")
for issue in self.document.issues:
logging.info(repr(issue))
if type(issue) == type(expect) and issue.args == expect.args:
if type(issue) is type(expect) and issue.args == expect.args:
break
else:
self.fail("issue not found: {}".format(expect))
Expand All @@ -194,7 +194,7 @@ def test_issues_skipped_level(self):
expect = DoorstopInfo("skipped level: 1.2.3 (REQ001), 1.4 (REQ003)")
for issue in self.document.issues:
logging.info(repr(issue))
if type(issue) == type(expect) and issue.args == expect.args:
if type(issue) is type(expect) and issue.args == expect.args:
break
else:
self.fail("issue not found: {}".format(expect))
Expand Down
2 changes: 1 addition & 1 deletion doorstop/core/tests/validators/validator_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-only

from doorstop import DoorstopError, DoorstopInfo, DoorstopWarning
from doorstop import DoorstopInfo


def item_validator(item):
Expand Down
5 changes: 5 additions & 0 deletions doorstop/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
"""Web interface for Doorstop."""

from .client import check, get_next_number

__all__ = [
"check",
"get_next_number",
]
38 changes: 33 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ isort = "^5.12"
mypy = ">=1.1.1"
pydocstyle = "*"
pylint = "~3.2.0"
ruff = "^0.12.3"
types-markdown = "*"
types-pyyaml = "*"
types-requests = "*"
Expand Down
5 changes: 2 additions & 3 deletions reqs/ext/.req_sha_item_validator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# SPDX-License-Identifier: LGPL-3.0-only
from doorstop import DoorstopInfo, DoorstopWarning, DoorstopError
from doorstop import DoorstopWarning
from subprocess import check_output
from copy import copy
from random import random


def item_validator(item):
if getattr(item, "references") == None:
if getattr(item, "references") is None:
return []

for ref in item.references:
Expand Down