-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 97e09c8 with MkDocs version: 1.6.0
- Loading branch information
1 parent
3c12fa5
commit 35f7b9c
Showing
52 changed files
with
5,868 additions
and
45,187 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
assets/javascripts/bundle.ad660dcc.min.js → assets/javascripts/bundle.fe8b6f2b.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...ts/javascripts/bundle.ad660dcc.min.js.map → ...ts/javascripts/bundle.fe8b6f2b.min.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Oops, something went wrong.