Render Python source files as Markdown with inline LaTeX math.
Project description
mathdocs
mathdocs renders ordinary Python source files as Markdown with inline LaTeX
math. The renderer reads annotations, decorators, stubs, and sidecar metadata
statically — it never imports or executes the target module. Installing the
package gives you both the helper API and the mathdocs CLI.
Installation
pip install mathdocs
CLI
mathdocs render examples/linear_model.py # print rendered Markdown
mathdocs symbols examples/linear_model.py # list discovered symbols
mathdocs check examples/linear_model.py # report diagnostics
Helper API
Import the helpers in ordinary Python code:
from mathdocs import Symbol, Tensor, render_as, render_figure
theta = Symbol(r"\theta", text="angle")
stress = Tensor(r"\sigma", indices=("i", "j"))
@render_as(latex=r"x^2")
def square(x: float) -> float:
return x * x
render_figure(
"artifacts/training_loss.svg",
alt="Training loss curve",
caption="Loss decreases over eight training epochs.",
)
Top-level render_figure(...) calls are static placement directives. They tell
the renderer where to include an already generated plot, diagram, screenshot, or
other image in the final Markdown document. render_image(...) and
render_plot(...) remain available as aliases.
python -m mathdocs <script.py> runs a Python script with the script
directory added to sys.path, which is useful for examples that generate
local artifacts before the renderer reads the source:
python -m mathdocs examples/generated_plot.py
The MathDocs project (including the VS Code extension) lives at https://github.com/bofrim/mathdocs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathdocs-0.1.0.tar.gz.
File metadata
- Download URL: mathdocs-0.1.0.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
855bedfbdc7d725240ae139904568d256fa2fdeede2c4ec892c629136668edeb
|
|
| MD5 |
ed851dfed426c1351138ba272202b0be
|
|
| BLAKE2b-256 |
bcbe004237cd5df84911a0291e306d403d6154ad68731157b451cd7fa86b39e8
|
Provenance
The following attestation bundles were made for mathdocs-0.1.0.tar.gz:
Publisher:
release.yml on bofrim/mathdocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathdocs-0.1.0.tar.gz -
Subject digest:
855bedfbdc7d725240ae139904568d256fa2fdeede2c4ec892c629136668edeb - Sigstore transparency entry: 1415032394
- Sigstore integration time:
-
Permalink:
bofrim/mathdocs@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bofrim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mathdocs-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: mathdocs-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de31c153357c519c081a0971e953ec1bf46683cfc087dcf062410cf350e10710
|
|
| MD5 |
c26c6baf4783d91786b5d53fb9992e25
|
|
| BLAKE2b-256 |
aa3f8438159a8fb3fd560854b3888e0413bdaba1308920b8e3774751a0fdd9e4
|
Provenance
The following attestation bundles were made for mathdocs-0.1.0-py3-none-win_amd64.whl:
Publisher:
release.yml on bofrim/mathdocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathdocs-0.1.0-py3-none-win_amd64.whl -
Subject digest:
de31c153357c519c081a0971e953ec1bf46683cfc087dcf062410cf350e10710 - Sigstore transparency entry: 1415032748
- Sigstore integration time:
-
Permalink:
bofrim/mathdocs@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bofrim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dab1d6d42ef41961915308375f4df87658acba29b3bea4e7f217baef860a7ba
|
|
| MD5 |
e3299ee82a070db71d58855de65d4c92
|
|
| BLAKE2b-256 |
af289aa25f0c1271728b005ceb1b42534d070577f48eb4ba554c4920b8f82db7
|
Provenance
The following attestation bundles were made for mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on bofrim/mathdocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
6dab1d6d42ef41961915308375f4df87658acba29b3bea4e7f217baef860a7ba - Sigstore transparency entry: 1415032485
- Sigstore integration time:
-
Permalink:
bofrim/mathdocs@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bofrim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c27853ea8cad17c20c1e9b0d3f860d0af013cd1093015ab061cfb95ae7bb78
|
|
| MD5 |
6238be37847c013ef1396eab8ca96542
|
|
| BLAKE2b-256 |
3b58d2b1911130bbdfdc39c245733755f45afcc1a772d394d747d8d343990665
|
Provenance
The following attestation bundles were made for mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on bofrim/mathdocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
78c27853ea8cad17c20c1e9b0d3f860d0af013cd1093015ab061cfb95ae7bb78 - Sigstore transparency entry: 1415032663
- Sigstore integration time:
-
Permalink:
bofrim/mathdocs@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bofrim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e799d15b88c5cf60d4baa8890e933b8c8e32798948830d90eb01cd1ba671a132
|
|
| MD5 |
ffd4289f30787f604bfb84632f4b8fb2
|
|
| BLAKE2b-256 |
8a5554063e5787e9eb9f42d94a05f290527b9233abf07db8c9bb77c0ac8ccef7
|
Provenance
The following attestation bundles were made for mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on bofrim/mathdocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
e799d15b88c5cf60d4baa8890e933b8c8e32798948830d90eb01cd1ba671a132 - Sigstore transparency entry: 1415032583
- Sigstore integration time:
-
Permalink:
bofrim/mathdocs@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bofrim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a086e73cae6f3e8be3a69c99d7299775f815a905 -
Trigger Event:
push
-
Statement type: