Skip to content

Commit

Permalink
Deployed 97e09c8 with MkDocs version: 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 5, 2024
1 parent 3c12fa5 commit 35f7b9c
Show file tree
Hide file tree
Showing 52 changed files with 5,868 additions and 45,187 deletions.
591 changes: 68 additions & 523 deletions 404.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3,510 changes: 2,789 additions & 721 deletions docs/CHANGELOG/index.html

Large diffs are not rendered by default.

657 changes: 76 additions & 581 deletions docs/CODE_TAG_SUMMARY/index.html

Large diffs are not rendered by default.

699 changes: 113 additions & 586 deletions docs/DEVELOPER_GUIDE/index.html

Large diffs are not rendered by default.

635 changes: 74 additions & 561 deletions docs/MIGRATION/index.html

Large diffs are not rendered by default.

637 changes: 75 additions & 562 deletions docs/STYLE_GUIDE/index.html

Large diffs are not rendered by default.

42 changes: 27 additions & 15 deletions gen_ref_nav.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
"""Generate the code reference pages and navigation.
"""Generate the code reference pages.
Copied from:
https://github.com/pawamoy/copier-pdm/blob/79135565c4c7f756204a5f460e87129649f8b704/project/docs/gen_ref_nav.py
Adapted without navigation from:
https://github.com/pawamoy/copier-pdm/blob/adff9b64887d0b4c9ec0b42de1698b34858a511e/project/scripts/gen_ref_nav.py
"""

from pathlib import Path

import mkdocs_gen_files
from corallium.tomllib import tomllib


def has_public_code(line: str) -> bool:
"""Determine if a given line contains code that will be documented."""
for key in ('def', 'async def', 'class'):
starts = line.startswith(f'{key} ')
if starts and not line.startswith(f'{key} _'):
return True
if starts:
break
return False


_config = tomllib.loads(Path('pyproject.toml').read_text(encoding='utf-8'))
_pkg_name = _config['tool']['poetry']['name']
src = Path(_pkg_name)
for path in sorted(src.rglob('*.py')):
for line in path.read_text().split('\n'):
if has_public_code(line):
break
else:
continue # Do not include the file in generated documentation

nav = mkdocs_gen_files.Nav()

for path in sorted(Path('calcipy').rglob('*.py')):
module_path = path.with_suffix('')
doc_path = path.with_suffix('.md')
full_doc_path = Path('reference', doc_path)

parts = tuple(module_path.parts)

if parts[-1] == '__init__':
parts = parts[:-1]
doc_path = doc_path.with_name('index.md')
full_doc_path = full_doc_path.with_name('index.md')
elif parts[-1] == '__main__':
elif parts[-1].startswith('_'):
continue

nav[parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, 'w') as fd:
ident = '.'.join(parts)
fd.write(f'::: {ident}')

mkdocs_gen_files.set_edit_path(full_doc_path, path)

# FYI, to add pages manually, use: `nav["package", "module"] = "path/to/file.md"`

with mkdocs_gen_files.open('reference/SUMMARY.md', 'w') as nav_file:
nav_file.writelines(nav.build_literate_nav())
Loading

0 comments on commit 35f7b9c

Please sign in to comment.