Skip to content

Commit

Permalink
added files for mkdocs generation (#242)
Browse files Browse the repository at this point in the history
* added files for mkdocs generation
  • Loading branch information
ssb-jnk authored Sep 1, 2023
1 parent 436edb9 commit 056ce15
Show file tree
Hide file tree
Showing 7 changed files with 848 additions and 42 deletions.
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

0 comments on commit 056ce15

Please sign in to comment.