Skip to content

Commit 2f249a5

Browse files
committed
fix mkdocs with more docs best practices
1 parent dc4ff1f commit 2f249a5

File tree

7 files changed

+328
-180
lines changed

7 files changed

+328
-180
lines changed

docs/admin/install.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Option 1: Install from PyPI.
44

5-
```
5+
```bash
66
pip install pyntc
77
```
88

99
Option 2: Manually install via Poetry.
1010

11-
```
11+
```bash
1212
git clone https://github.com/networktocode/pyntc.git
1313
cd pyntc
1414
curl -sSL https://install.python-poetry.org | python3 -
@@ -18,5 +18,5 @@ poetry install
1818
Option 3: Install from a GitHub branch, such as develop as shown below.
1919

2020
```bash
21-
$ pip install git+https://github.com/networktocode/pyntc.git@develop
21+
pip install git+https://github.com/networktocode/pyntc.git@develop
2222
```

docs/admin/uninstall.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Uninstall from environment.
44

55
```bash
6-
$ pip uninstall pyntc
6+
pip uninstall pyntc
77
```

docs/admin/upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Upgrade from PyPI.
44

55
```bash
6-
$ pip install pyntc --upgrade
6+
pip install pyntc --upgrade
77
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Generate code reference pages."""
2+
3+
from pathlib import Path
4+
5+
import mkdocs_gen_files
6+
7+
for file_path in Path("pyntc").rglob("*.py"):
8+
module_path = file_path.with_suffix("")
9+
doc_path = file_path.with_suffix(".md")
10+
full_doc_path = Path("code-reference", doc_path)
11+
12+
parts = list(module_path.parts)
13+
if parts[-1] == "__init__":
14+
parts = parts[:-1]
15+
16+
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
17+
identifier = ".".join(parts)
18+
print(f"::: {identifier}", file=fd)
19+
20+
mkdocs_gen_files.set_edit_path(full_doc_path, file_path)

mkdocs.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ theme:
1414
- "python"
1515
- "yaml"
1616
features:
17+
- "content.code.annotate"
1718
- "content.code.copy"
18-
- "navigation.indexes"
19+
- "content.tabs.link"
20+
- "navigation.footer"
1921
- "navigation.tabs"
2022
- "navigation.tabs.sticky"
2123
- "navigation.tracking"
@@ -40,15 +42,26 @@ theme:
4042
toggle:
4143
icon: "material/weather-night"
4244
name: "Switch to light mode"
43-
extra_css:
44-
- "assets/extra.css"
4545

4646
# needed for RTD version flyout menu
4747
# jquery is not (yet) injected by RTD automatically and it might be dropped
4848
# as a dependency in the future
4949
extra_javascript:
5050
- "https://code.jquery.com/jquery-3.6.0.min.js"
5151

52+
# Since their file size is quite large, we exclude them from the built docs.
53+
exclude_docs: |
54+
/media/*.gif
55+
56+
validation:
57+
absolute_links: warn
58+
anchors: warn
59+
omitted_files: warn
60+
unrecognized_links: warn
61+
62+
extra_css:
63+
- "assets/extra.css"
64+
5265
extra:
5366
generator: false
5467
ntc_sponsor: true
@@ -69,20 +82,41 @@ extra:
6982
link: "https://twitter.com/networktocode"
7083
name: "Network to Code Twitter"
7184
markdown_extensions:
85+
- "markdown_version_annotations":
86+
admonition_tag: "???"
7287
- "admonition"
7388
- "toc":
7489
permalink: true
7590
- "attr_list"
91+
- "markdown_data_tables":
92+
base_path: "docs"
7693
- "md_in_html"
94+
- "pymdownx.details"
95+
# Need pymdownx.emoji for Grid icon search
96+
- pymdownx.emoji:
97+
emoji_index: !!python/name:material.extensions.emoji.twemoji
98+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
7799
- "pymdownx.highlight":
78100
anchor_linenums: true
79101
- "pymdownx.inlinehilite"
80102
- "pymdownx.snippets"
81-
- "pymdownx.superfences"
82-
- "footnotes"
103+
- "pymdownx.superfences":
104+
custom_fences:
105+
- name: "mermaid"
106+
class: "mermaid"
107+
format: !!python/name:pymdownx.superfences.fence_code_format
108+
- "pymdownx.tabbed":
109+
"alternate_style": true
110+
- "pymdownx.tilde"
111+
83112
plugins:
84113
- "search"
85-
- "mkdocs-version-annotations"
114+
- "gen-files":
115+
scripts:
116+
- docs/generate_code_reference_pages.py
117+
- "glightbox":
118+
manual: true # See https://blueswen.github.io/mkdocs-glightbox/flexibility/enable-by-image-or-page/
119+
- "section-index"
86120
- "mkdocstrings":
87121
default_handler: "python"
88122
handlers:
@@ -93,8 +127,6 @@ plugins:
93127
show_root_heading: true
94128
show_root_members_full_path: true
95129
show_source: false
96-
watch:
97-
- "README.md"
98130

99131
nav:
100132
- Overview: "index.md"

0 commit comments

Comments
 (0)