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.

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

sphinx_fortran_domain-0.0.2.tar.gz (38.3 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.0.2-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

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

Hashes for sphinx_fortran_domain-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1c882b73690f1084ac24f571d491e86c7e30bff0e981013b1f0defe0e054a045
MD5 2cda29d14e2d15495677741a5579e35f
BLAKE2b-256 69ab70ad2ad05b8dc680d70f6648f1b10c0dfaa1c38d8ed14e94b7fda06fc6e5

See more details on using hashes here.

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

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.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_fortran_domain-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9dbb1bac9c56b7a5ea2f8e1eda9fad3e3468c6400799bab546fd90ddebcf81c3
MD5 da166360a082fe15af3a47de995a4604
BLAKE2b-256 b74a3589ccec4dce6c8b95b215ea2424a5bbad6157065cc27530ad15a427980e

See more details on using hashes here.

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

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