Skip to content

Commit 939c0ca

Browse files
committed
docs: enhance documentation styling and configuration
- Add CSS files for improved fonts, API navigation, and material design - Include MathJax support for mathematical expressions - Update mkdocs configuration with better styling and plugins - Remove unused documentation generation scripts - Optimize theme features and markdown extensions
1 parent 7caddfc commit 939c0ca

12 files changed

Lines changed: 203 additions & 126 deletions

File tree

.cspell.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
"version": "0.2",
44
"language": "en",
55
"words": [
6+
"arithmatex",
67
"asyncio",
78
"cuda",
89
"cython",
910
"direnv",
1011
"dmypy",
11-
"dsanders",
1212
"elif",
13-
"envrc",
13+
"fieldz",
1414
"getattr",
1515
"hynek",
16+
"inlinehilite",
1617
"ipynb",
1718
"ipython",
1819
"libc",
@@ -26,6 +27,7 @@
2627
"pixi",
2728
"pybuilder",
2829
"pycache",
30+
"pydantic",
2931
"pydocstyle",
3032
"pyenv",
3133
"pyflow",

docs/css/fonts.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* ref: https://squidfunk.github.io/mkdocs-material/setup/changing-the-fonts/ */
2+
/* TODO: choose fonts */
3+
:root {
4+
--md-text-font:
5+
"Roboto", "Verdana", "Arial", "Helvetica", sans-serif, ui-sans-serif,
6+
system-ui, "Segoe UI Emoji", "Noto Color Emoji", emoji;
7+
--md-code-font:
8+
"MonaspiceNe Nerd Font", "CaskaydiaCove Nerd Font", "FiraCode Nerd Font",
9+
"Monaspace Neon", "Cascadia Code", "FiraCode", "JetBrains Mono",
10+
ui-monospace, monospace, "Segoe UI Emoji", "Noto Color Emoji", emoji;
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* ref: https://github.com/tlambert03/mkdocs-api-autonav */
2+
nav.md-nav code.doc-symbol.doc-symbol-nav {
3+
margin-right: 0.25em;
4+
}

docs/css/mkdocstrings/material.css

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* ref: https://mkdocstrings.github.io/python/usage/customization/#material */
2+
3+
/* Indentation. */
4+
div.doc-contents:not(.first) {
5+
padding-left: 25px;
6+
border-left: 0.05rem solid var(--md-typeset-table-color);
7+
}
8+
9+
/* Mark external links as such. */
10+
a.external::after,
11+
a.autorefs-external::after {
12+
/* https://primer.style/octicons/arrow-up-right-24 */
13+
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
14+
-webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
15+
content: " ";
16+
17+
display: inline-block;
18+
vertical-align: middle;
19+
position: relative;
20+
21+
height: 1em;
22+
width: 1em;
23+
background-color: currentColor;
24+
}
25+
26+
a.external:hover::after,
27+
a.autorefs-external:hover::after {
28+
background-color: var(--md-accent-fg-color);
29+
}
30+
31+
/* Tree-like output for backlinks. */
32+
.doc-backlink-list {
33+
--tree-clr: var(--md-default-fg-color);
34+
--tree-font-size: 1rem;
35+
--tree-item-height: 1;
36+
--tree-offset: 1rem;
37+
--tree-thickness: 1px;
38+
--tree-style: solid;
39+
display: grid;
40+
list-style: none !important;
41+
}
42+
43+
.doc-backlink-list li > span:first-child {
44+
text-indent: 0.3rem;
45+
}
46+
.doc-backlink-list li {
47+
padding-inline-start: var(--tree-offset);
48+
border-left: var(--tree-thickness) var(--tree-style) var(--tree-clr);
49+
position: relative;
50+
margin-left: 0 !important;
51+
52+
&:last-child {
53+
border-color: transparent;
54+
}
55+
&::before {
56+
content: "";
57+
position: absolute;
58+
top: calc(
59+
var(--tree-item-height) / 2 * -1 * var(--tree-font-size) +
60+
var(--tree-thickness)
61+
);
62+
left: calc(var(--tree-thickness) * -1);
63+
width: calc(var(--tree-offset) + var(--tree-thickness) * 2);
64+
height: calc(var(--tree-item-height) * var(--tree-font-size));
65+
border-left: var(--tree-thickness) var(--tree-style) var(--tree-clr);
66+
border-bottom: var(--tree-thickness) var(--tree-style) var(--tree-clr);
67+
}
68+
&::after {
69+
content: "";
70+
position: absolute;
71+
border-radius: 50%;
72+
background-color: var(--tree-clr);
73+
top: calc(var(--tree-item-height) / 2 * 1rem);
74+
left: var(--tree-offset);
75+
translate: calc(var(--tree-thickness) * -1) calc(var(--tree-thickness) * -1);
76+
}
77+
}

template/docs/css/mkdocstrings/syntax-highlight-in-signatures.css renamed to docs/css/mkdocstrings/syntax-highlight-in-signatures.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/* This file is @generated by <https://github.com/liblaf/copier-python>.
2-
DO NOT EDIT! */
3-
4-
/* https://mkdocstrings.github.io/python/usage/customization/#syntax-highlight-in-signatures */
1+
/* ref: https://mkdocstrings.github.io/python/usage/customization/#syntax-highlight-in-signatures */
52

63
/* Fancier color for operators such as * and |. */
74
.doc-signature .o {

docs/javascript/mathjax.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ref: <https://squidfunk.github.io/mkdocs-material/reference/math/#mathjax>
2+
window.MathJax = {
3+
tex: {
4+
inlineMath: [["\\(", "\\)"]],
5+
displayMath: [["\\[", "\\]"]],
6+
processEscapes: true,
7+
processEnvironments: true,
8+
},
9+
options: {
10+
ignoreHtmlClass: ".*|",
11+
processHtmlClass: "arithmatex",
12+
},
13+
};
14+
15+
document$.subscribe(() => {
16+
MathJax.startup.output.clearCache();
17+
MathJax.typesetClear();
18+
MathJax.texReset();
19+
MathJax.typesetPromise();
20+
});

template/.config/copier/mkdocs.yaml.jinja

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ repo_url: "https://github.com/{{ github_user }}/{{ github_repo }}"
1515
edit_uri: blob/main/docs/
1616

1717
extra_css:
18-
# - https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/css/fonts.css
19-
# - https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/css/mkdocstrings/material.css
20-
# - https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/css/mkdocstrings/syntax-highlight-in-signatures.css
21-
# I don't know why, but external CSS does not work.
22-
- css/fonts.css
23-
- css/mkdocstrings/material.css
24-
- css/mkdocstrings/syntax-highlight-in-signatures.css
18+
- https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/docs/css/fonts.css
19+
- https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/docs/css/mkdocstrings/api-autonav.css
20+
- https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/docs/css/mkdocstrings/material.css
21+
- https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/docs/css/mkdocstrings/syntax-highlight-in-signatures.css
22+
23+
extra_javascript:
24+
- https://raw.githubusercontent.com/liblaf/copier-python/refs/heads/main/docs/javascript/mathjax.js
25+
- https://raw.githubusercontent.com/readthedocs/test-builds/refs/heads/mkdocs-material/docs/javascripts/readthedocs.js
26+
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
2527

2628
theme:
2729
name: material
2830
features:
29-
- announce.dismiss
31+
# - announce.dismiss
3032
- content.action.edit
3133
- content.action.view
3234
- content.code.annotate
@@ -44,7 +46,7 @@ theme:
4446
- navigation.instant.progress
4547
- navigation.path
4648
# - navigation.prune
47-
- navigation.sections
49+
# - navigation.sections
4850
- navigation.tabs
4951
- navigation.tabs.sticky
5052
- navigation.top
@@ -55,6 +57,7 @@ theme:
5557
- toc.follow
5658
# - toc.integrate
5759
palette:
60+
# ref: <https://github.com/mkdocstrings/mkdocstrings/blob/d5bf4e1ed0370853f968b210ad77913faf106eed/mkdocs.yml#L70-L88>
5861
- media: (prefers-color-scheme)
5962
toggle:
6063
icon: material/brightness-auto
@@ -76,20 +79,26 @@ theme:
7679

7780
plugins:
7881
# Built-in plugins
82+
# blog:
83+
# group:
84+
# info:
85+
meta:
86+
# offline:
7987
# optimize: # sponsors only
88+
privacy:
89+
# projects:
8090
search:
8191
social:
92+
tags:
8293
# typeset: # sponsors only
94+
8395
# External plugins, schema provided by us
84-
gen-files:
85-
scripts:
86-
- docs/scripts/gen-ref-pages.py
8796
git-committers:
8897
enabled: !ENV [READTHEDOCS, CI, false]
8998
repository: "{{ github_user }}/{{ github_repo }}"
9099
branch: main
91-
literate-nav:
92100
section-index:
101+
93102
# External plugins, schema provided by our community
94103
include-markdown:
95104
git-revision-date-localized:
@@ -103,44 +112,90 @@ plugins:
103112
- https://docs.python.org/3/objects.inv
104113
options:
105114
# General
115+
backlinks: tree
116+
extensions:
117+
# Official extensions
118+
- griffe_inherited_docstrings
119+
- griffe_pydantic
120+
- griffe_warnings_deprecated
121+
# Third-party extensions
122+
- docstring_inheritance.griffe
123+
- griffe_fieldz
124+
- griffe_generics
125+
# - griffe_inherited_method_crossrefs # does not work
126+
find_stubs_package: true
127+
show_inheritance_diagram: true
106128
# Headings
129+
heading_level: 1
130+
show_root_heading: true
107131
show_symbol_type_heading: true
108132
show_symbol_type_toc: true
109133
# Members
110134
inherited_members: true
111135
filters:
112-
- "!^_[^_]"
113136
- "!__all__"
137+
- "!^_[^_]"
114138
summary: true
115139
# Docstrings
116140
docstring_style: google
117141
docstring_options:
118142
ignore_init_summary: true
119143
docstring_section_style: list
120144
merge_init_into_class: true
145+
relative_crossrefs: true
146+
scoped_crossrefs: true
121147
show_if_no_docstring: true
122148
# Signatures
149+
modernize_annotations: true
123150
show_signature_annotations: true
124151
separate_signature: true
152+
show_overloads: true
125153
signature_crossrefs: true
126-
# External plugins, schema not provided
154+
155+
# ref: <https://mkdocstrings.github.io/autorefs/>
127156
autorefs:
128157

158+
# ref: <https://github.com/tlambert03/mkdocs-api-autonav>
159+
api-autonav:
160+
modules:
161+
- "src/{{ wheel_package_dir }}/"
162+
129163
markdown_extensions:
164+
# ref: <https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown/>
165+
abbr:
130166
admonition:
167+
attr_list:
168+
def_list:
169+
footnotes:
131170
md_in_html:
132-
mdx_truly_sane_lists:
171+
toc:
172+
# ref: <https://github.com/mkdocstrings/mkdocstrings/blob/d5bf4e1ed0370853f968b210ad77913faf106eed/mkdocs.yml#L124-L125>
173+
permalink: ¤
174+
175+
# ref: <https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown-extensions/>
176+
pymdownx.arithmatex:
177+
generic: true
178+
pymdownx.betterem:
179+
smart_enable: all
180+
pymdownx.blocks.caption:
181+
pymdownx.caret:
182+
pymdownx.mark:
183+
pymdownx.tilde:
184+
pymdownx.critic:
133185
pymdownx.details:
186+
pymdownx.emoji:
187+
pymdownx.highlight:
188+
pymdownx.inlinehilite:
189+
pymdownx.keys:
190+
pymdownx.smartsymbols:
134191
pymdownx.snippets:
135192
pymdownx.superfences:
136193
pymdownx.tabbed:
137194
alternate_style: true
138-
toc:
139-
permalink: ¤
195+
pymdownx.tasklist:
140196

141-
extra:
142-
version:
143-
provider: mike
197+
# ref: <https://github.com/radude/mdx_truly_sane_lists>
198+
mdx_truly_sane_lists:
144199

145200
watch:
146201
- .config/copier/mkdocs.yaml

template/docs/SUMMARY.md

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

template/docs/css/fonts.css

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

template/docs/css/mkdocstrings/material.css

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

0 commit comments

Comments
 (0)