speedyleion / sphinx-c-autodoc

Use C with sphinx.ext.autodoc
The Unlicense
9 stars 1 forks source link

sphinx-c-autodoc

|build-status| |coverage| |black| |docs|

Dual-licensed under MIT or the UNLICENSE <https://unlicense.org>_.

.. inclusion_begin

A basic attempt at extending Sphinx and autodoc to work with C files.

The idea is to add support for similar directives that autodoc_ provides. i.e.

A function in my_c_file.c:

.. code-block:: c

/**
 * A simple function that adds.
 *
 * @param a: The initial value
 * @param b: The value to add to `a`
 *
 * @returns The sum of `a` and `b`.
 *
 */
int my_adding_function(int a, int b) {
    return a + b;
    }

Could be referenced in documentation as:

.. code-block:: rst

.. autocfunction:: my_c_file.c::my_adding_function

With the resulting documentation output of:

.. Note this isn't using the c:function directive because that doesn't work on pypi

int my_adding_function(int a, int b) A simple function that adds.

:Parameters:
    * **a** - The initial value
    * **b** - The value to add to `a`

:Returns: The sum of `a` and `b`

.. _autodoc: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html .. _Sphinx: https://www.sphinx-doc.org/en/master/index.html

Requires

Similar Tools

.. |build-status| image:: https://github.com/speedyleion/sphinx-c-autodoc/actions/workflows/ci.yml/badge.svg :alt: Build Status :target: https://github.com/speedyleion/sphinx-c-autodoc/actions/workflows/ci.yml

.. |coverage| image:: https://codecov.io/gh/speedyleion/sphinx-c-autodoc/branch/main/graph/badge.svg :alt: Coverage :target: https://codecov.io/gh/speedyleion/sphinx-c-autodoc

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :alt: Code Style :target: https://github.com/psf/black

.. |docs| image:: https://readthedocs.org/projects/sphinx-c-autodoc/badge/?version=latest :alt: Documentation Status :target: https://sphinx-c-autodoc.readthedocs.io/en/latest/?badge=latest

.. inclusion_end

Full Documentation

The complete documentation can be found at https://sphinx-c-autodoc.readthedocs.io/en/latest