Skip to main content

A modern Sphinx domain for Fortran

Project description

Sphinx Fortran Domain

Fortran-lang's base Sphinx domain to document Fortran projects.

Status: This project is preparing its first official 0.1.x release. The core API is usable and tested; feedback and issue reports are welcome.

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}`.

Community

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

sphinx_fortran_domain-0.1.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

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

sphinx_fortran_domain-0.1.0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_fortran_domain-0.1.0.tar.gz.

File metadata

  • Download URL: sphinx_fortran_domain-0.1.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_fortran_domain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8898f89c3e2f522671c45358e4df6cd0a2d75080e0c857e5a45ef3e93a536d87
MD5 78989f4d7b74079a2fb89258d83fd4d3
BLAKE2b-256 2affb6a96a3d39f01798c13db1a3b1924babc7e35e98106df109a3cf56242211

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on fortran-lang/sphinx-fortran-domain

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

File details

Details for the file sphinx_fortran_domain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_fortran_domain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84eae4c1554557b5e6fdb8e5cacb121f349d9b4348bfe045897c4fdd95496541
MD5 990d7cf5efa4ceb0c36f21263bc0b704
BLAKE2b-256 8cf5df9af639f6fa876824b7b48c35a38abf6c1ee97d0060757aa372aed9bb6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_fortran_domain-0.1.0-py3-none-any.whl:

Publisher: publish.yml on fortran-lang/sphinx-fortran-domain

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