Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathdocs-0.1.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mathdocs-0.1.0-py3-none-win_amd64.whl (1.8 MB view details)

Uploaded Python 3Windows x86-64

mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

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

Hashes for mathdocs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 855bedfbdc7d725240ae139904568d256fa2fdeede2c4ec892c629136668edeb
MD5 ed851dfed426c1351138ba272202b0be
BLAKE2b-256 bcbe004237cd5df84911a0291e306d403d6154ad68731157b451cd7fa86b39e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mathdocs-0.1.0.tar.gz:

Publisher: release.yml on bofrim/mathdocs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mathdocs-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 de31c153357c519c081a0971e953ec1bf46683cfc087dcf062410cf350e10710
MD5 c26c6baf4783d91786b5d53fb9992e25
BLAKE2b-256 aa3f8438159a8fb3fd560854b3888e0413bdaba1308920b8e3774751a0fdd9e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mathdocs-0.1.0-py3-none-win_amd64.whl:

Publisher: release.yml on bofrim/mathdocs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mathdocs-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6dab1d6d42ef41961915308375f4df87658acba29b3bea4e7f217baef860a7ba
MD5 e3299ee82a070db71d58855de65d4c92
BLAKE2b-256 af289aa25f0c1271728b005ceb1b42534d070577f48eb4ba554c4920b8f82db7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mathdocs-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 78c27853ea8cad17c20c1e9b0d3f860d0af013cd1093015ab061cfb95ae7bb78
MD5 6238be37847c013ef1396eab8ca96542
BLAKE2b-256 3b58d2b1911130bbdfdc39c245733755f45afcc1a772d394d747d8d343990665

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mathdocs-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e799d15b88c5cf60d4baa8890e933b8c8e32798948830d90eb01cd1ba671a132
MD5 ffd4289f30787f604bfb84632f4b8fb2
BLAKE2b-256 8a5554063e5787e9eb9f42d94a05f290527b9233abf07db8c9bb77c0ac8ccef7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page