qdocs
The website theme and generator of qspec and qunits. This repository is both:
- a Jekyll theme (
_layouts/,_includes/,_sass/,assets/) that GitHub Pages loads withremote_theme, and - a Python package (
qdocs/) that generates the API pages and the tutorial code blocks of a site.
Use it in a site
docs/_config.yml:
title: qunits
logo: /assets/img/logo.svg # The dark logo is logo_dark.svg next to it.
description: A performant, verbose and generic physical unit system.
show_downloads: true # The PyPi, GitHub and .zip links.
accent_color: "#2a7fff" # The color of the logo.
copyright: 2026 Patrick Müller. All rights reserved.
remote_theme: patmlr/qdocs@v0.2.0 # Pin a tag, so theme changes do not reach the site unnoticed.
plugins:
- jekyll-remote-theme
- jekyll-seo-tag
The site provides _data/navigation.yml (top navigation), _data/tutorials.yml (tutorial list),
_includes/badges.html (optional) and its logos assets/img/logo.svg, logo_dark.svg and logo_small.svg.
Any theme file can be overridden by a file at the same path in the site. Extra styles go in _sass/custom.scss,
extra <head> tags in _includes/head-custom.html.
docs/requirements.txt, with the same version as remote_theme:
qdocs==0.2.0
docs/_gen/build.py:
import os
from qdocs import Project, main
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
PROJECT = Project(
package="qspec",
modules=["algebra", "analyze", "models", "physics"],
root=ROOT,
namespaced={"analyze", "models"}, # qspec.models.Model instead of qspec.Model.
type_aliases="qtypes", # Optional: link these type aliases in annotations to their module page.
)
if __name__ == "__main__":
main(PROJECT)
python docs/_gen/build.py [api | tutorials | logo | all]
| Target | Source | Output |
|---|---|---|
api |
docstrings and signatures of the package | doc/functions/**, _includes/api-nav.html |
tutorials |
# docs: <name> regions in examples/ |
_includes/code/<name>.html |
logo |
assets/img/logo.svg |
assets/img/logo_dark.svg |
The module pages doc/modules/<module>.html and the overview doc/doc.html are written by hand with the api
layout, which adds the navigation. See Project in qdocs/project.py for all options.
Customizations
Every class page has an Attributes section with the public class attributes, the annotated instance attributes
(including __slots__) and the properties of the class. Classes listed in Project.namespaces are documented like a
module of constants: no signature and no methods, only the description and the attributes. Enums are documented this
way automatically. Subclass ApiBuilder to change which attributes are listed (attributes returns a list of
Attribute) or how values are shown:
from qdocs import ApiBuilder, Project, main
class Builder(ApiBuilder):
def format_value(self, value) -> str:
if isinstance(value, Unit):
return f'<span class="default_value"><span class="class">Unit</span>(...)</span>'
return super().format_value(value)
main(PROJECT, Builder)
format_value is used for default values in signatures and for attribute values. Color the parts of a value with
the classes string, bool, num, class and func inside a default_value span.
Docstrings
reST fields, with a small markup for the description texts:
def york_fit(x, y, sigma_x=None, ...):
r"""
A linear regression algorithm ... points $\vec{\mu}_i\in\mathbb{R}^2$ ...
$$\vec{\mu} = \begin{pmatrix}x\\y\end{pmatrix}.$$
The algorithm is described in
[<a href="https://doi.org/10.1119/1.1632486">York et al., Am. J. Phys. 72, 367 (2004)</a>].
See also [`linear_fit`].
:param x: The $x$ data.
:param sigma_x: The standard deviation $\sigma_x$ of the `x` data (unit of `x`).
:returns: (popt, pcov) The best y-intercept and slope and their covariance matrix.
:raises ValueError: If ...
:raises (ValueError, TypeError): Several exceptions in one field.
"""
-
`code`and raw HTML (e.g. links to papers) are passed through. -
$inline$and$$block$$math is rendered by MathJax. Block math always stands on its own line on the website. -
[`name`]links to a documented object:fit,King.fit,qspec.models.fit,qspec.physics.doppleror a module such asqspec.analyze. Unknown or ambiguous names stop the build. -
Blank lines separate paragraphs, lines starting with
-form a list. -
A leading
(name)in:returns:labels the return value(s), otherwise it is shown asout. -
Types are taken from the annotations as written in the source.
-
Methods without a docstring inherit the docstring of the overridden method.
-
The signature and the parameters of a class are those of
__init__, or of__new__if only that is overridden. A class that overrides neither has no signature. -
Attributes are described by a string below their assignment or annotation in the class body, properties by their docstring:
class Unit: scale: float """The scale factor of the unit relative to the SI base units."""
The generator warns about parameters that are missing in the docstring or the signature.
Tutorial code
Mark a block in an example script and include it in a tutorial page:
# examples/tutorial_2.py
# docs: hfs-0
import qspec as qs
...
# docs: end
<!-- docs/tutorials/hfs.html -->
{% include code/hfs-0.html %}
A script may contain several regions. The generator fails on unclosed or duplicate regions and on includes without a matching region.
Developing the theme
pip install -e .
python -m qdocs css # _sass/qdocs/pycode.scss from the Pygments styles in qdocs/tutorials.py.
python -m qdocs preview ../qspec/docs # Serve a site with this checkout instead of its remote_theme.
python -m qdocs preview ../qunits/docs build
preview copies the theme and the site into a temporary folder, rerun it after changes.
All colors are CSS custom properties in assets/css/style.scss: the light values on :root,
the dark values in the dark-colors mixin. The code highlighting styles are STYLE and STYLE_DARK in
qdocs/tutorials.py.
To release, run the workflow on main (Actions > Build and release > Run workflow) and choose the version bump. It
publishes the package to PyPI and creates the tag vX.Y.Z and a GitHub release. Then update remote_theme and
requirements.txt of the sites. The version of a checkout is derived from the latest tag with hatch-vcs.
The base styles and the Noto Sans fonts are from jekyll-theme-minimal (CC0 1.0).
Metadata
Release files for qdocs 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qdocs-0.2.0.tar.gz | 18.8 kB | With provenance | Details for qdocs-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qdocs-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for qdocs-0.2.0-py3-none-any.whl |
Total release size: 42.3 kB
Release files / qdocs-0.2.0.tar.gz
| Download URL | qdocs-0.2.0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66f4c6282c29f4436b64a8680c0cc2b39442e5fe968af31231abc1827c07f0f4
|
|
BLAKE2b-256 checksum How to use checksums |
6272627bf3a4216fe904f8e2d59947a51005e14756f4f20afdf138a7e94c1138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / qdocs-0.2.0-py3-none-any.whl
| Download URL | qdocs-0.2.0-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff8367a286232821515be9bf93e7f39adfc2d8805930c0526fa7e8f35dc098f2
|
|
BLAKE2b-256 checksum How to use checksums |
26a3cfe94d85a8508f09b00da4cae089e7edcb1c8dcc6388ac0949c92b6f3648
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for qdocs 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for qdocs-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.