Skip to content

Commit

Permalink
Consistent order in auto-generated documentation
Browse files Browse the repository at this point in the history
Don't depend on how the filesystem reads it; sort to get the same order everywhere.
  • Loading branch information
phihag committed Sep 12, 2023
1 parent f16edc5 commit fe5778a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions bx_py_utils/doc_write/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ Notes:

### Notes

* All Doc-String without the `{prefix}` will be ignored.
* The created created Markdown file is relative to `output_base_path` (defined in `pyproject.toml`)

* The `{file-path}` must has the file extension `.md`
Otherwise the DocString block will be ignored.
* Headlines will be sorted, so they appears ordered by the level.

* The created created Markdown file is relative to `output_base_path` (defined in `pyproject.toml`)
* All Doc-String without the `{prefix}` will be ignored.

* Headlines will be sorted, so they appears ordered by the level.
* The `{file-path}` must has the file extension `.md`
Otherwise the DocString block will be ignored.
2 changes: 1 addition & 1 deletion bx_py_utils/doc_write/docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def collect_docstrings(*, config: DocuwriteConfig) -> dict:
regex = re.compile(config.docstring_prefix + r'\s*(.*?) (#{1,}.+?)\n+(.+)', re.DOTALL)

storage = collections.defaultdict(dict)
for file_path in iter_file_path(file_paths=config.search_paths, rglob_pattern='*.py'):
for file_path in sorted(iter_file_path(file_paths=config.search_paths, rglob_pattern='*.py')):
for doc_string in iter_docstrings(file_path=file_path):
if not doc_string.startswith(config.docstring_prefix):
"""DocWrite: bx_py_utils/doc_write/README.md ### Notes
Expand Down
2 changes: 1 addition & 1 deletion bx_py_utils_tests/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Helper to publish this Project to PyPi
"""

from pathlib import Path
import subprocess
from pathlib import Path

from manageprojects.utilities.publish import publish_package

Expand Down
9 changes: 5 additions & 4 deletions bx_py_utils_tests/tests/test_doc_write_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_happy_path(self):
inspect.cleandoc(
"""
'''TestDocs: test/README.md # Headline 1
The Doc String 1
The Doc String 2 (from foo)
'''
"""
)
Expand All @@ -40,7 +40,7 @@ def test_happy_path(self):
inspect.cleandoc(
"""
'''TestDocs: test/README.md # Headline 1
Merged Text to Headline 1
Merged Text to Headline 1 (from bar)
'''
"""
)
Expand All @@ -62,6 +62,7 @@ def test_happy_path(self):
DocuwriteConfig(
base_path=temp_path,
search_paths=[
# intentionally not in alphabetical order
temp_path / 'foo',
temp_path / 'bar',
],
Expand All @@ -81,9 +82,9 @@ def test_happy_path(self):
"""
# Headline 1
The Doc String 1
Merged Text to Headline 1 (from bar)
Merged Text to Headline 1
The Doc String 2 (from foo)
## Headline 2
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bx_py_utils"
version = "87"
version = "88"
description = "Various Python utility functions"
homepage = "https://github.com/boxine/bx_py_utils/"
authors = [
Expand Down

0 comments on commit fe5778a

Please sign in to comment.