File tree Expand file tree Collapse file tree 7 files changed +117
-15
lines changed
.github/alternative_workflows Expand file tree Collapse file tree 7 files changed +117
-15
lines changed Original file line number Diff line number Diff line change 11{
22 "template" : " https://github.com/collijk/python-package-cookiecutter" ,
3- "commit" : " 7e9285f84cc6b52165dbc97b9a0d4f059d0f6818 " ,
3+ "commit" : " 8e2aaf58b416eecf27f0021e9ee770a34688fff9 " ,
44 "checkout" : null ,
55 "context" : {
66 "cookiecutter" : {
1111 "project_slug" : " rra-tools" ,
1212 "package_name" : " rra_tools" ,
1313 "project_short_description" : " Common utilities for IHME Rapid Response team pipelines." ,
14- "_template" : " https://github.com/collijk/python-package-cookiecutter"
14+ "_template" : " https://github.com/collijk/python-package-cookiecutter" ,
15+ "_commit" : " 8e2aaf58b416eecf27f0021e9ee770a34688fff9"
1516 }
1617 },
1718 "directory" : null
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+
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
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/rra_tools
@@ -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 @@ -43,6 +43,9 @@ requests = "^2.32.2"
4343mkdocstrings = {version = " >=0.23" , extras = [" python" ]}
4444mkdocs-material = " *"
4545mkdocs-table-reader-plugin = " *"
46+ mkdocs-gen-files = " ^0.5.0"
47+ mkdocs-literate-nav = " ^0.6.1"
48+ mkdocs-section-index = " ^0.3.9"
4649mypy = " *"
4750pre-commit = " *"
4851pymdown-extensions = " *"
@@ -90,6 +93,9 @@ ignore-init-module-imports = true
9093 " ARG" , # "Unused function argument". Fixtures are often unused.
9194 " S105" , # "Possible hardcoded password".
9295]
96+ "scripts/**" = [
97+ " INP001" , # "Scripts are not part of a package."
98+ ]
9399
94100[tool .ruff .lint .mccabe ]
95101max-complexity = 10
@@ -134,9 +140,3 @@ module = [
134140 " pathos.*" ,
135141]
136142ignore_missing_imports = true
137-
138- # [[tool.mypy.overrides]]
139- # module = [
140- # "tests/my_thing/test_my_thing",
141- # ]
142- # disallow_untyped_defs = false
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