Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added files for mkdocs generation #242

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/codeofconduct.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/codeofconduct.md
7 changes: 0 additions & 7 deletions docs/contributing.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/contributing.md
33 changes: 33 additions & 0 deletions docs/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Generate the code reference pages and navigation."""

from pathlib import Path

import mkdocs_gen_files


nav = mkdocs_gen_files.Nav()

for path in sorted(Path("src").rglob("*.py")):
module_path = path.relative_to("src").with_suffix("")
doc_path = path.relative_to("src").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__":
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)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
21 changes: 0 additions & 21 deletions docs/index.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/index.md
31 changes: 31 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
site_name: dapla-toolbelt-pseudo
site_description: Pseudonymization extensions for Dapla Toolbelt
site_url: https://statisticsnorway.github.io/dapla-toolbelt-pseudo

theme:
name: "material"
repo_name: statisticsnorway/dapla-toolbelt-pseudo
repo_url: https://github.com/statisticsnorway/dapla-toolbelt-pseudo
edit_uri: edit/main/docs/

nav:
- Home: "index.md"
- Code Reference: reference/
- Contributing: "CONTRIBUTING.md"

plugins:
- search
- gen-files:
scripts:
- docs/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
- section-index
- mkdocstrings:
# watch:
# - src/dapla_pseudo

markdown_extensions:
- admonition # note blocks, warning blocks -- https://github.com/mkdocs/mkdocs/issues/1659
- attr_list # Enables full command headers, see https://github.com/DataDog/mkdocs-click#full-command-path-headers
- mkdocs-typer
Loading
Loading