Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup SWIG and Sphinx to generate docs for Python bindings #163

Merged
merged 3 commits into from
Jan 3, 2023

Conversation

kontura
Copy link
Contributor

@kontura kontura commented Nov 16, 2022

Setup SWIG and Sphinx to generate docs for Python bindings

Our current docs pipeline for c++ is:

c++ code (with docs annotations)
    |
    ▽
Doxygen gathers the docs into xml files
    |
    ▽
Sphinx (using a breathe extension) uses xmls to generate html

This adds a pipeline for Python bindings:

c++ code (with docs annotations)
    |
    ▽
Swig has a build in parser for Doxygen type of documentation and it
automatically inserts it when generating bindings (using -doxygen flag).
    |
    ▽
Sphinx (using a autodoc extension) generates Python docs directly from
python bindings.

Another option would be to use Doxygen for Python bindings as well.
However Doxygen isn't intended for Python and it generates the binding
xmls improperly resulting in uglier html docs.

Still it is not a perfect solution, the docs string are meant for C++
and the notation can look out of place in Python docs.
We are limited by what Swig generates so functions with multiple
arguments have a signature of function_name(*args) (arguments are
described correctly in the documentation it self).
Swig handles overloads by wrapping them into one function so it is
again only described in the docs for the particular functions (ideally
each overload would have its own function).

Resulting example:
image

@kontura kontura force-pushed the python_api_doc branch 2 times, most recently from 2b6f533 to 1f1627c Compare November 23, 2022 12:17
@kontura kontura changed the title Setup SWIG and Doxygen to generate docs for Python bindings Setup SWIG and Sphinx to generate docs for Python bindings Nov 23, 2022
@mcurlej mcurlej added this to the Fedora 38 milestone Nov 24, 2022
Our current docs pipeline for c++ is:

    c++ code (with docs annotations)
        |
        ▽
    Doxygen gathers the docs into xml files
        |
        ▽
    Sphinx (using a breathe extension) uses xmls to generate html

This adds a pipeline for Python bindings:

    c++ code (with docs annotations)
        |
        ▽
    Swig has a build in parser for Doxygen type of documentation and it
    automatically inserts it when generating bindings (using -doxygen flag).
        |
        ▽
    Sphinx (using a autodoc extension) generates Python docs directly from
    python bindings.

Another option would be to use Doxygen for Python bindings as well.
However Doxygen isn't intended for Python and it generates the binding
xmls improperly resulting in uglier html docs.

Still it is not a perfect solution, the docs string are meant for C++
and the notation can look out of place in Python docs.
We are limited by what Swig generates so functions with multiple
arguments have a signature of `function_name(*args)` (arguments are
described correctly in the documentation it self).
Swig handles overloads by wrapping them into one function so it is
again only described in the docs for the particular functions (ideally
each overload would have its own function).
We don't want it to be mixed with python (or other) docs.
@j-mracek j-mracek self-assigned this Nov 24, 2022
@gotmax23
Copy link
Contributor

This would be great to have. Even the generated docstrings without the Sphinx docs would be helpful.

@j-mracek
Copy link
Contributor

j-mracek commented Jan 3, 2023

LGTM

@j-mracek j-mracek merged commit 5c35916 into rpm-software-management:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants