qdocs 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.5
2
+ Name: qdocs
3
+ Version: 0.2.0
4
+ Summary: The website theme and generator of qspec and qunits.
5
+ Project-URL: source, https://github.com/patmlr/qdocs
6
+ Project-URL: tracker, https://github.com/patmlr/qdocs/issues
7
+ Author-email: Patrick Müller <pamueller.ikp@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Topic :: Documentation
13
+ Classifier: Topic :: Software Development :: Documentation
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: jinja2
16
+ Requires-Dist: pygments>=2.17
17
+ Description-Content-Type: text/markdown
18
+
19
+ # qdocs
20
+
21
+ The website theme and generator of [qspec](https://github.com/patmlr/qspec) and
22
+ [qunits](https://github.com/patmlr/qunits). This repository is both:
23
+
24
+ - a Jekyll theme (`_layouts/`, `_includes/`, `_sass/`, `assets/`) that GitHub Pages loads with `remote_theme`, and
25
+ - a Python package (`qdocs/`) that generates the API pages and the tutorial code blocks of a site.
26
+
27
+ ## Use it in a site
28
+
29
+ `docs/_config.yml`:
30
+
31
+ ```yaml
32
+ title: qunits
33
+ logo: /assets/img/logo.svg # The dark logo is logo_dark.svg next to it.
34
+ description: A performant, verbose and generic physical unit system.
35
+ show_downloads: true # The PyPi, GitHub and .zip links.
36
+ accent_color: "#2a7fff" # The color of the logo.
37
+ copyright: 2026 Patrick M&#252;ller. All rights reserved.
38
+ remote_theme: patmlr/qdocs@v0.2.0 # Pin a tag, so theme changes do not reach the site unnoticed.
39
+ plugins:
40
+ - jekyll-remote-theme
41
+ - jekyll-seo-tag
42
+ ```
43
+
44
+ The site provides `_data/navigation.yml` (top navigation), `_data/tutorials.yml` (tutorial list),
45
+ `_includes/badges.html` (optional) and its logos `assets/img/logo.svg`, `logo_dark.svg` and `logo_small.svg`.
46
+ Any theme file can be overridden by a file at the same path in the site. Extra styles go in `_sass/custom.scss`,
47
+ extra `<head>` tags in `_includes/head-custom.html`.
48
+
49
+ `docs/requirements.txt`, with the same version as `remote_theme`:
50
+
51
+ ```text
52
+ qdocs==0.2.0
53
+ ```
54
+
55
+ `docs/_gen/build.py`:
56
+
57
+ ```python
58
+ import os
59
+
60
+ from qdocs import Project, main
61
+
62
+ ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
63
+
64
+ PROJECT = Project(
65
+ package="qspec",
66
+ modules=["algebra", "analyze", "models", "physics"],
67
+ root=ROOT,
68
+ namespaced={"analyze", "models"}, # qspec.models.Model instead of qspec.Model.
69
+ type_aliases="qtypes", # Optional: link these type aliases in annotations to their module page.
70
+ )
71
+
72
+ if __name__ == "__main__":
73
+ main(PROJECT)
74
+ ```
75
+
76
+ ```bash
77
+ python docs/_gen/build.py [api | tutorials | logo | all]
78
+ ```
79
+
80
+ | Target | Source | Output |
81
+ |-------------|-------------------------------------------|--------------------------------------------------|
82
+ | `api` | docstrings and signatures of the package | `doc/functions/**`, `_includes/api-nav.html` |
83
+ | `tutorials` | `# docs: <name>` regions in `examples/` | `_includes/code/<name>.html` |
84
+ | `logo` | `assets/img/logo.svg` | `assets/img/logo_dark.svg` |
85
+
86
+ The module pages `doc/modules/<module>.html` and the overview `doc/doc.html` are written by hand with the `api`
87
+ layout, which adds the navigation. See `Project` in [`qdocs/project.py`](qdocs/project.py) for all options.
88
+
89
+ ### Customizations
90
+
91
+ Every class page has an Attributes section with the public class attributes, the annotated instance attributes
92
+ (including `__slots__`) and the properties of the class. Classes listed in `Project.namespaces` are documented like a
93
+ module of constants: no signature and no methods, only the description and the attributes. Enums are documented this
94
+ way automatically. Subclass `ApiBuilder` to change which attributes are listed (`attributes` returns a list of
95
+ `Attribute`) or how values are shown:
96
+
97
+ ```python
98
+ from qdocs import ApiBuilder, Project, main
99
+
100
+
101
+ class Builder(ApiBuilder):
102
+ def format_value(self, value) -> str:
103
+ if isinstance(value, Unit):
104
+ return f'<span class="default_value"><span class="class">Unit</span>(...)</span>'
105
+ return super().format_value(value)
106
+
107
+
108
+ main(PROJECT, Builder)
109
+ ```
110
+
111
+ `format_value` is used for default values in signatures and for attribute values. Color the parts of a value with
112
+ the classes `string`, `bool`, `num`, `class` and `func` inside a `default_value` span.
113
+
114
+ ## Docstrings
115
+
116
+ reST fields, with a small markup for the description texts:
117
+
118
+ ```python
119
+ def york_fit(x, y, sigma_x=None, ...):
120
+ r"""
121
+ A linear regression algorithm ... points $\vec{\mu}_i\in\mathbb{R}^2$ ...
122
+
123
+ $$\vec{\mu} = \begin{pmatrix}x\\y\end{pmatrix}.$$
124
+
125
+ The algorithm is described in
126
+ [<a href="https://doi.org/10.1119/1.1632486">York et al., Am. J. Phys. 72, 367 (2004)</a>].
127
+ See also [`linear_fit`].
128
+
129
+ :param x: The $x$ data.
130
+ :param sigma_x: The standard deviation $\sigma_x$ of the `x` data (unit of `x`).
131
+ :returns: (popt, pcov) The best y-intercept and slope and their covariance matrix.
132
+ :raises ValueError: If ...
133
+ :raises (ValueError, TypeError): Several exceptions in one field.
134
+ """
135
+ ```
136
+
137
+ - `` `code` `` and raw HTML (e.g. links to papers) are passed through.
138
+ - `$inline$` and `$$block$$` math is rendered by MathJax. Block math always stands on its own line on the website.
139
+ - `` [`name`] `` links to a documented object: `fit`, `King.fit`, `qspec.models.fit`, `qspec.physics.doppler`
140
+ or a module such as `qspec.analyze`. Unknown or ambiguous names stop the build.
141
+ - Blank lines separate paragraphs, lines starting with `- ` form a list.
142
+ - A leading `(name)` in `:returns:` labels the return value(s), otherwise it is shown as `out`.
143
+ - Types are taken from the annotations as written in the source.
144
+ - Methods without a docstring inherit the docstring of the overridden method.
145
+ - The signature and the parameters of a class are those of `__init__`, or of `__new__` if only that is overridden.
146
+ A class that overrides neither has no signature.
147
+ - Attributes are described by a string below their assignment or annotation in the class body, properties by their
148
+ docstring:
149
+
150
+ ```python
151
+ class Unit:
152
+ scale: float
153
+ """The scale factor of the unit relative to the SI base units."""
154
+ ```
155
+
156
+ The generator warns about parameters that are missing in the docstring or the signature.
157
+
158
+ ## Tutorial code
159
+
160
+ Mark a block in an example script and include it in a tutorial page:
161
+
162
+ ```python
163
+ # examples/tutorial_2.py
164
+ # docs: hfs-0
165
+ import qspec as qs
166
+
167
+ ...
168
+ # docs: end
169
+ ```
170
+
171
+ ```html
172
+ <!-- docs/tutorials/hfs.html -->
173
+ {% include code/hfs-0.html %}
174
+ ```
175
+
176
+ A script may contain several regions. The generator fails on unclosed or duplicate regions and on includes without a
177
+ matching region.
178
+
179
+ ## Developing the theme
180
+
181
+ ```bash
182
+ pip install -e .
183
+ python -m qdocs css # _sass/qdocs/pycode.scss from the Pygments styles in qdocs/tutorials.py.
184
+ python -m qdocs preview ../qspec/docs # Serve a site with this checkout instead of its remote_theme.
185
+ python -m qdocs preview ../qunits/docs build
186
+ ```
187
+
188
+ `preview` copies the theme and the site into a temporary folder, rerun it after changes.
189
+
190
+ All colors are CSS custom properties in [`assets/css/style.scss`](assets/css/style.scss): the light values on `:root`,
191
+ the dark values in the `dark-colors` mixin. The code highlighting styles are `STYLE` and `STYLE_DARK` in
192
+ [`qdocs/tutorials.py`](qdocs/tutorials.py).
193
+
194
+ To release, run the workflow on main (Actions > Build and release > Run workflow) and choose the version bump. It
195
+ publishes the package to PyPI and creates the tag `vX.Y.Z` and a GitHub release. Then update `remote_theme` and
196
+ `requirements.txt` of the sites. The version of a checkout is derived from the latest tag with hatch-vcs.
197
+
198
+ The base styles and the Noto Sans fonts are from [jekyll-theme-minimal](https://github.com/pages-themes/minimal)
199
+ (CC0 1.0).
@@ -0,0 +1,15 @@
1
+ qdocs/__init__.py,sha256=h0mazpvmfNm4WeuddS6_hWymUM8b40N2w6FvrORFoAI,206
2
+ qdocs/__main__.py,sha256=Clw2h6_dHJWaP4ff1CBrYTyiItXzzKNJdG1-F8IRNsQ,3202
3
+ qdocs/annotations.py,sha256=sTRtyGvlWYT38BmUDaatNhjkJJmSIA2jfJ65bZ_TT6s,5767
4
+ qdocs/build.py,sha256=xCoeHZDph7qh786713EYUUavcpYD-SbSFNqW0Qk1tyY,13808
5
+ qdocs/collect.py,sha256=Aff1gy6AOQCm514tHkGCkRCSxJVWeDfkXmzm9NDrOe4,7006
6
+ qdocs/docstring.py,sha256=oCxT0EcewEQ76Zvnr68Zbv6S8mUIjqUs-DldfI6oSao,3577
7
+ qdocs/markup.py,sha256=FvVXf7RZUhJiRJqG89dRvzYUg4eu4LKb_LfdCU5L98g,3596
8
+ qdocs/project.py,sha256=VDfggMTY-GYUFIDNEiDdXvJs4M3FcYmkO2LYNevDZFQ,2108
9
+ qdocs/tutorials.py,sha256=xp46eproAbpscdQOlmQpV4WJcgK6Z4Fi8giw7ykEG2g,4713
10
+ qdocs/templates/function.html,sha256=aARZXPB8RQsyIygwTCey4ibsUJoDI6cStQUMOIxWBrI,2334
11
+ qdocs/templates/nav.html,sha256=G-Dxyfub2xKByWjAh0WPacH_rv1fw3F0QT-VEXFzlSQ,1895
12
+ qdocs-0.2.0.dist-info/METADATA,sha256=Z4lHeUPZYWRXwG1VVbmiBXZxwgTUOiINMCkhO38mLJk,7922
13
+ qdocs-0.2.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
14
+ qdocs-0.2.0.dist-info/licenses/LICENSE,sha256=Y6GfM9rblr8I2sWwUkhEax_3-e-L2eFoWaw0f8ds9Fw,1081
15
+ qdocs-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patrick Matthias Müller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.