Using Sphinx to automatically generate a separate document for each function

前端 未结 2 1191
南笙
南笙 2020-12-03 19:06

I\'ve been building a Python module with many different functions.

I\'m using Sphinx and readthedocs to provide documentation. I\'ve made decent progress, but curre

相关标签:
2条回答
  • 2020-12-03 19:21

    I think the sphinx-automodapi Sphinx extension may do what you need. Essentially to document a module you would just do:

    .. automodapi:: mypackage.mymodule
    

    and it will generate the table and individual pages for each function.

    Disclaimer: I am an author of sphinx-automodapi

    0 讨论(0)
  • 2020-12-03 19:37

    In the answer to Sorting display by class using sphinx with 'autodoc'? it is explained how to generate documentation for classes with one page per class, using autosummary with autosummary_generate=True.

    This mechanism works for functions too. Use something like this:

    EoN API documentation
    =====================
    
    .. currentmodule:: EoN
    
    .. autosummary::
       :toctree: functions
    
       my_function1
       my_function2
       my_function3
       ...
    

    You have to enumerate each function in the autosummary directive, but the corresponding *.rst files are generated automatically (in the functions subdirectory).

    0 讨论(0)
提交回复
热议问题