Skip to content

Commit 32c7c47

Browse files
authored
chore: update project structure to 8e2aaf58
1 parent d518162 commit 32c7c47

File tree

10 files changed

+149
-10
lines changed

10 files changed

+149
-10
lines changed

.cruft.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/collijk/python-package-cookiecutter",
3-
"commit": "7e9285f84cc6b52165dbc97b9a0d4f059d0f6818",
3+
"commit": "8e2aaf58b416eecf27f0021e9ee770a34688fff9",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -11,7 +11,8 @@
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
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

.pre-commit-config.yaml.rej

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff a/.pre-commit-config.yaml b/.pre-commit-config.yaml (rejected hunks)
2+
@@ -25,11 +25,6 @@ repos:
3+
# Add --fix, in case you want it to autofix when this hook runs
4+
entry: poetry run ruff check --force-exclude --fix
5+
require_serial: true
6+
- - id: ruff
7+
- name: ruff
8+
- # Add --fix, in case you want it to autofix when this hook runs
9+
- entry: poetry run ruff check --force-exclude
10+
- require_serial: true
11+
language: system
12+
types: [ python ]
13+
- id: mypy

docs/api_docs.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

mkdocs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ theme:
1414
name: Switch to light mode
1515

1616
nav:
17-
- Introduction: 'index.md'
18-
- api_docs.md
19-
- changelog.md
17+
- Home: 'index.md'
18+
- Code Reference: reference/
19+
- Changelog: changelog.md
2020

2121
watch:
2222
- src/rra_tools
@@ -61,6 +61,12 @@ markdown_extensions:
6161
plugins:
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:

mkdocs.yml.rej

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
diff a/mkdocs.yml b/mkdocs.yml (rejected hunks)
2+
@@ -73,5 +79,5 @@ extra_javascript:
3+
- https://unpkg.com/tablesort@5.3.0/dist/tablesort.min.js
4+
- _javascript/tablesort.js
5+
- _javascript/mathjax.js
6+
- - https://polyfill.io/v3/polyfill.min.js?features=es6
7+
+ - https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6
8+
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

poetry.lock

Lines changed: 44 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ requests = "^2.32.2"
4343
mkdocstrings = {version = ">=0.23", extras = ["python"]}
4444
mkdocs-material = "*"
4545
mkdocs-table-reader-plugin = "*"
46+
mkdocs-gen-files = "^0.5.0"
47+
mkdocs-literate-nav = "^0.6.1"
48+
mkdocs-section-index = "^0.3.9"
4649
mypy = "*"
4750
pre-commit = "*"
4851
pymdown-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]
95101
max-complexity = 10

pyproject.toml.rej

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff a/pyproject.toml b/pyproject.toml (rejected hunks)
2+
@@ -90,7 +96,7 @@ classmethod-decorators = [
3+
]
4+
5+
[tool.ruff.lint.flake8-tidy-imports]
6+
-ban-relative-imports = true
7+
+ban-relative-imports = "all"
8+
9+
[tool.pytest.ini_options]
10+
addopts = """\

scripts/gen_ref_pages.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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())

0 commit comments

Comments
 (0)