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

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.0.tar.gz (35.1 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.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_fortran_domain-0.0.0.tar.gz
  • Upload date:
  • Size: 35.1 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.0.tar.gz
Algorithm Hash digest
SHA256 76008ec8b06d14e2e520318559d966070728c0a6e644a41052096cc2c8c6c03b
MD5 b4c87e3c25a7cd86a3e585437b8d0656
BLAKE2b-256 1ac0c692d58a1475380ecebba5293fac2a8e018bf0b5f849639ab91d7252a69f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_fortran_domain-0.0.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.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_fortran_domain-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9aa435e3829e6f2694e324ce56bcb8d27b49d8dfc8e9cd86ecd08b5765ccbb0a
MD5 0fc33be5797ef2a3e0c3346f6c28cd3f
BLAKE2b-256 320091973a3cef60cf873846c04b99cc321d276ed77111d150c6cba9e0faffbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_fortran_domain-0.0.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