A modern Sphinx domain for Fortran
Project description
Sphinx Fortran Domain
Fortran-lang's base Sphinx domain to document Fortran projects.
WARNING: This project is under construction, at this stage you can use it but expect missing features or some rendering bugs. Your friendly feedback will be very important to get this project in shape.
Install
For regular usage:
pip install sphinx-fortran-domain
For editable install for development:
pip install -e .
Build the docs
Install with documentation dependencies:
pip install -e ".[docs]"
Build HTML documentation:
cd docs
make html
Enable the extension
In conf.py:
extensions = [
"sphinx_fortran_domain",
]
# Where your Fortran sources live (directories, files, or glob patterns)
fortran_sources = [
"../src", # directory
"../example/*.f90", # glob pattern
]
# Exclude sources from parsing (directories, files, or glob patterns)
fortran_sources_exclude = [
"../example/legacy", # directory
"../example/skip_this.f90", # file
"../example/**/generated_*.f90", # glob
]
# Select a lexer (built-in: "regex")
fortran_lexer = "regex"
# Doc comment convention
# Examples: '!>' or '!!' or '!@'
fortran_doc_chars = [">", "!"]
Directives and roles
Manual declarations (create targets for cross-references):
.. f:function:: add_vectors(vec1, vec2)
.. f:subroutine:: normalize_vector(vec)
Autodoc-style views from parsed sources:
.. f:module:: example_module
.. f:submodule:: stdlib_quadrature_trapz
.. f:program:: test_program
Cross-references:
See :f:mod:`example_module` and :f:subr:`normalize_vector`.
Writing a lexer plugin
See the full step-by-step guide in the documentation: docs/api/lexers.rst.
External packages can register a lexer at import/setup time:
from sphinx_fortran_domain.lexers import register_lexer
def setup(app):
register_lexer("my-lexer", lambda: MyLexer())
Then use fortran_lexer = "my-lexer".
Math in doc comments
This extension parses Fortran doc comments as reStructuredText fragments, so Sphinx
roles/directives work inside docs (including math when sphinx.ext.mathjax is enabled).
Supported math styles:
- Recommended (reST):
!> .. math:: \hat{v} = \frac{\vec{v}}{|\vec{v}|}
Inline math also works via :math::
!> The magnitude is :math:`|\vec{v}| = \sqrt{x^2 + y^2 + z^2}`.
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
Built Distribution
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 sphinx_fortran_domain-0.0.2.tar.gz.
File metadata
- Download URL: sphinx_fortran_domain-0.0.2.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c882b73690f1084ac24f571d491e86c7e30bff0e981013b1f0defe0e054a045
|
|
| MD5 |
2cda29d14e2d15495677741a5579e35f
|
|
| BLAKE2b-256 |
69ab70ad2ad05b8dc680d70f6648f1b10c0dfaa1c38d8ed14e94b7fda06fc6e5
|
Provenance
The following attestation bundles were made for sphinx_fortran_domain-0.0.2.tar.gz:
Publisher:
publish.yml on fortran-lang/sphinx-fortran-domain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_fortran_domain-0.0.2.tar.gz -
Subject digest:
1c882b73690f1084ac24f571d491e86c7e30bff0e981013b1f0defe0e054a045 - Sigstore transparency entry: 1010508619
- Sigstore integration time:
-
Permalink:
fortran-lang/sphinx-fortran-domain@ff2b101d0cbaa5faab91ec3cdb2a2a618876e15b -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/fortran-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff2b101d0cbaa5faab91ec3cdb2a2a618876e15b -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_fortran_domain-0.0.2-py3-none-any.whl.
File metadata
- Download URL: sphinx_fortran_domain-0.0.2-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dbb1bac9c56b7a5ea2f8e1eda9fad3e3468c6400799bab546fd90ddebcf81c3
|
|
| MD5 |
da166360a082fe15af3a47de995a4604
|
|
| BLAKE2b-256 |
b74a3589ccec4dce6c8b95b215ea2424a5bbad6157065cc27530ad15a427980e
|
Provenance
The following attestation bundles were made for sphinx_fortran_domain-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on fortran-lang/sphinx-fortran-domain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_fortran_domain-0.0.2-py3-none-any.whl -
Subject digest:
9dbb1bac9c56b7a5ea2f8e1eda9fad3e3468c6400799bab546fd90ddebcf81c3 - Sigstore transparency entry: 1010508688
- Sigstore integration time:
-
Permalink:
fortran-lang/sphinx-fortran-domain@ff2b101d0cbaa5faab91ec3cdb2a2a618876e15b -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/fortran-lang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff2b101d0cbaa5faab91ec3cdb2a2a618876e15b -
Trigger Event:
push
-
Statement type: