sphinx-stan

Sphinx domain for Stan, the probabilistic programming language

https://github.com/tillahoffmann/sphinx-stan

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Sphinx domain for Stan, the probabilistic programming language

Basic Info
  • Host: GitHub
  • Owner: tillahoffmann
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Size: 41 KB
Statistics
  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Created over 3 years ago · Last pushed over 3 years ago
Metadata Files
Readme License Citation

README.rst

sphinx-stan
===========

.. image:: https://github.com/tillahoffmann/sphinx-stan/actions/workflows/main.yml/badge.svg
    :target: https://github.com/tillahoffmann/sphinx-stan/
.. image:: https://badge.fury.io/py/sphinx-stan.svg
    :target: https://pypi.org/project/sphinx-stan/
.. image:: https://readthedocs.org/projects/sphinx-stan/badge/?version=latest
    :target: https://sphinx-stan.readthedocs.io/en/latest/?badge=latest

sphinx-stan is a `Sphinx `_ extension for documenting `Stan `_ code. It supports both standard Sphinx fields as well as the `doxygen `_ syntax `recommended by the Stan user guide `_.

.. warning::

    sphinx-stan is an early release; use it at your own risk. Bugs and feature requests can be filed on `GitHub `__.

Explicit documentation of functions
-----------------------------------

Functions can be documented explicitly using the :code:`:stan:function:: ...` directive. For example, the following statements generate the documentation shown below.

.. code-block:: rst

    .. stan:function:: real log(real x, real y)

        Evaluate the logarithm of :math:`x` with base :math:`y`.

        :param x: Value to take the logarithm of.
        :param y: Base of the logarithm.
        :return: :math:`\log_y\left(x\right)`.
        :throws: If :math:`x` or :math:`y` are negative.

.. stan:function:: real log(real x, real y)

    Evaluate the logarithm of :math:`x` with base :math:`y`.

    :param x: Value to take the logarithm of.
    :param y: Base of the logarithm.
    :return: :math:`\log_y\left(x\right)`.
    :throws: If :math:`x` or :math:`y` are negative.

Stan supports `overloading `_, and so does the documentation. For example, the following function evaluates the natural logarithm, implicitly setting :math:`y=e`.

.. stan:function:: real log(real x)

    Evaluate the natural logarithm of :math:`x`.

    :param x: Value to take the logarithm of.
    :return: :math:`\log\left(x\right)`.
    :throws: If :math:`x` is negative.

Using the :code:`:stan:func:\`...\`` role, we can reference specific overloaded implementations (such as :stan:func:`log(real, real)` or :stan:func:`log(real)`) by specifying the argument types.

.. note::

    sphinx-stan will try to resolve unqualified function references (such as :code:`:stan:func:\`log\``). A warning will be issued if the unqualified reference is ambiguous and the reference may point to any of the overloaded functions.

Automatic documentation
-----------------------

Functions can also be documented by loading them from a :code:`*.stan` file. For example, the following statements document two functions stored in :code:`example.stan`.

.. code-block:: rst

    .. stan:autodoc:: example.stan
        :members: mat_pow; log1p_series(real, int)

.. stan:autodoc:: example.stan
    :members: mat_pow; log1p_series(real, int)

Documentation for each function must preceed it and be wrapped in :code:`/** ... */` comments. The content of the example file is:

.. literalinclude:: example.stan
    :language: stan

Syntax
------

.. code-block:: rst

    .. stan:function:: 

        

        :param : 
        :param : 
        :return: 
        :throws:

          - 
          - 

Alternatively, functions may also be documented using the doxygen syntax (see the `Stan user guide `_ for details).

.. code-block:: rst

    .. stan:autodoc:: 
        :members: 

If :code:`:members:` is omitted, all functions in the file are documented in the order they appear. Function names are matched using the same logic as for the :code:`:stan:func:\`...\`` cross-referencing logic. If the file contains overloaded functions and only an unqualified name is provided (i.e., without argument types), all overloaded functions with the given identifier will be documented in the order they appear.

Installation
------------

The extension can be installed in two steps:

1. Run :code:`pip install sphinx-stan` from the command line to install the package.
2. Add :code:`"sphinxcontrib.stan"` to the list of `extensions `__ in your Sphinx configuration, typically :code:`conf.py`. You can view the configuration used to build this documentation `here `__.

Owner

  • Name: Till Hoffmann
  • Login: tillahoffmann
  • Kind: user
  • Location: Boston, MA
  • Company: Harvard T.H. Chan School of Public Health

Building network models at @HarvardChanSchool with a focus on open and reproducible science. Formerly @imperial, @spotify.

Citation (CITATION.cff)

# yaml-language-server: $schema=https://citation-file-format.github.io/1.2.0/schema.json
cff-version: 1.2.0
message: If you use this software, please cite it as below.
title: "sphinx-stan: Sphinx domain for Stan, the probabilistic programming language."
url: "https://github.com/tillahoffmann/sphinx-stan"
authors:
- family-names: Hoffmann
  given-names: Till
  orcid: https://orcid.org/0000-0003-4403-0722
preferred-citation:
  type: article
  authors:
  - family-names: Hoffmann
    given-names: Till
    orcid: https://orcid.org/0000-0003-4403-0722
  - family-names: Onnela
    given-names: Jukka-Pekka
    orcid: https://orcid.org/0000-0001-6613-8668
  doi: 10.48550/arXiv.2301.08836
  journal: arXiv
  start: "2301.08836"
  title: Scalable Gaussian Process Inference with Stan
  year: 2023

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 3
  • Total pull requests: 7
  • Average time to close issues: about 13 hours
  • Average time to close pull requests: 12 minutes
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • tillahoffmann (2)
Pull Request Authors
  • tillahoffmann (7)
Top Labels
Issue Labels
enhancement (2)
Pull Request Labels
enhancement (2)

Dependencies

requirements.in pypi
  • build *
  • doit-interface *
  • sphinx_rtd_theme *
requirements.txt pypi
  • alabaster ==0.7.12
  • attrs ==22.1.0
  • babel ==2.10.3
  • bleach ==5.0.1
  • build ==0.8.0
  • certifi ==2022.9.24
  • charset-normalizer ==2.1.1
  • cloudpickle ==2.2.0
  • colorama ==0.4.6
  • commonmark ==0.9.1
  • docutils ==0.17.1
  • doit ==0.36.0
  • doit-interface ==0.1.8
  • exceptiongroup ==1.0.0rc9
  • flake8 ==5.0.4
  • idna ==3.4
  • imagesize ==1.4.1
  • importlib-metadata ==5.0.0
  • iniconfig ==1.1.1
  • jaraco-classes ==3.2.3
  • jinja2 ==3.1.2
  • keyring ==23.9.3
  • markupsafe ==2.1.1
  • mccabe ==0.7.0
  • more-itertools ==9.0.0
  • packaging ==21.3
  • pep517 ==0.13.0
  • pkginfo ==1.8.3
  • pluggy ==1.0.0
  • pycodestyle ==2.9.1
  • pyflakes ==2.5.0
  • pygments ==2.13.0
  • pyparsing ==3.0.9
  • pytest ==7.2.0
  • pytz ==2022.5
  • readme-renderer ==37.2
  • requests ==2.28.1
  • requests-toolbelt ==0.10.1
  • rfc3986 ==2.0.0
  • rich ==12.6.0
  • six ==1.16.0
  • snowballstemmer ==2.2.0
  • sphinx ==5.3.0
  • sphinx-rtd-theme ==1.0.0
  • sphinxcontrib-applehelp ==1.0.2
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.0
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
  • tomli ==2.0.1
  • twine ==4.0.1
  • urllib3 ==1.26.12
  • webencodings ==0.5.1
  • zipp ==3.10.0
setup.py pypi
  • sphinx *
.github/workflows/main.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite