File tree Expand file tree Collapse file tree 5 files changed +71
-6
lines changed
{{cookiecutter.project_slug}}
.github/alternative_workflows Expand file tree Collapse file tree 5 files changed +71
-6
lines changed Original file line number Diff line number Diff line change 1+ name : Build and Deploy Docs
2+
3+ on :
4+ workflow_dispatch :
5+ pull_request :
6+ branches :
7+ - main
8+ types :
9+ - closed
10+ {% raw %}
11+ jobs :
12+ build-and-deploy-docs :
13+ if : ${{ github.event.pull_request.merged }} or ${{ github.event_name == 'workflow_dispatch' }}
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+ with :
18+ token : ${{ secrets.GH_TOKEN }}
19+ - uses : ./.github/actions/python-poetry-env
20+ - name : Deploy docs
21+ run : poetry run mkdocs gh-deploy --force{% endraw %}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1414 name : Switch to light mode
1515
1616nav :
17- - Introduction : ' index.md'
18- - api_docs.md
19- - changelog.md
17+ - Home : ' index.md'
18+ - Code Reference : reference/
19+ - Changelog : changelog.md
2020
2121watch :
2222 - src/{{ cookiecutter.package_name }}
@@ -61,6 +61,12 @@ markdown_extensions:
6161plugins :
6262 - table-reader
6363 - search
64+ - gen-files :
65+ scripts :
66+ - scripts/gen_ref_pages.py
67+ - literate-nav :
68+ nav_vile : SUMMARY.md
69+ - section-index
6470 - mkdocstrings :
6571 default_handler : python
6672 handlers :
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ click = "*"
3737mkdocstrings = {version = " >=0.23" , extras = [" python" ]}
3838mkdocs-material = " *"
3939mkdocs-table-reader-plugin = " *"
40+ mkdocs-gen-files = " ^0.5.0"
41+ mkdocs-literate-nav = " ^0.6.1"
42+ mkdocs-section-index = " ^0.3.9"
4043mypy = " *"
4144pre-commit = " *"
4245pymdown-extensions = " *"
@@ -78,6 +81,9 @@ ignore = [
7881 " ARG" , # "Unused function argument". Fixtures are often unused.
7982 " S105" , # "Possible hardcoded password".
8083]
84+ "scripts/**" = [
85+ " INP001" , # "Scripts are not part of a package."
86+ ]
8187
8288[tool .ruff .lint .mccabe ]
8389max-complexity = 10
Original file line number Diff line number Diff line change 1+ """Generate the code reference pages and navigation."""
2+
3+ from pathlib import Path
4+
5+ import mkdocs_gen_files
6+
7+ nav = mkdocs_gen_files .Nav () # type: ignore[attr-defined, no-untyped-call]
8+
9+ root = Path (__file__ ).parent .parent
10+ src = root / "src"
11+
12+ for path in sorted (src .rglob ("*.py" )):
13+ module_path = path .relative_to (src ).with_suffix ("" )
14+ doc_path = path .relative_to (src ).with_suffix (".md" )
15+ full_doc_path = Path ("reference" , doc_path )
16+
17+ parts = tuple (module_path .parts )
18+
19+ if parts [- 1 ] == "__init__" :
20+ parts = parts [:- 1 ]
21+ doc_path = doc_path .with_name ("index.md" )
22+ full_doc_path = full_doc_path .with_name ("index.md" )
23+ elif parts [- 1 ] == "__main__" :
24+ continue
25+
26+ nav [parts ] = doc_path .as_posix ()
27+
28+ with mkdocs_gen_files .open (full_doc_path , "w" ) as fd :
29+ ident = "." .join (parts )
30+ fd .write (f"::: { ident } " )
31+
32+ mkdocs_gen_files .set_edit_path (full_doc_path , path .relative_to (root ))
33+
34+ with mkdocs_gen_files .open ("reference/SUMMARY.md" , "w" ) as nav_file :
35+ nav_file .writelines (nav .build_literate_nav ())
You can’t perform that action at this time.
0 commit comments