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.1.tar.gz (36.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.1-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_fortran_domain-0.0.1.tar.gz
  • Upload date:
  • Size: 36.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.1.tar.gz
Algorithm Hash digest
SHA256 2fb9cb936f637e1e21356117b754a6c0d92fd842462e05487c144529efcee918
MD5 6295f1a41b33dd0fb3ea4c621c388599
BLAKE2b-256 4f584d54414609fa533c1b6ced54369c5bdafc8d3883c1af778d847786b8480c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sphinx_fortran_domain-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75741fc9b9dcaf0461115bf720f4155e5fc87f0505c4fe64712daf40dae476d9
MD5 46ae75aba23a8d42e31117fdb070f16c
BLAKE2b-256 e2a803c828d5731e66cc3e09aef48ac635a0574f3b3326a3e97bc7e3f2023161

See more details on using hashes here.

Provenance

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