Python Sphinx autodoc functions in module

I am just starting with the sphinx and want to learn.

I would like to split my various functions into different sections in my index.rst file. Therefore, each function has its own header.

So for example, if I have a python file called test.py, and inside this file I have 2 functions

def foo():
    """This prints bar"""
    print("bar")

def bar():
    """This prints foo"""
    print("foo")

How could I, within index.rst, separate 2 functions in my test.py file.

:mod:`test` -- foo
.. automodule:: test.foo
   :members:
   :undoc-members:
   :show-inheritance: 
:mod:`test` -- bar
.. automodule:: test.bar
   :members:
   :undoc-members:
   :show-inheritance: 

If I can figure out how to separate functions so that it looks cleaner in index.html, that would be great! As of now, the output is not very clean if I just ran the following:

:mod:`test` -- these are my functions
--------------------------------------------
.. automodule:: test
   :members:
   :undoc-members:
   :show-inheritance:
+4
source share
1 answer

autofunction. :

 
The test module
===============

The test module contains...

.. currentmodule:: test

The foo function
----------------

.. autofunction:: foo

The bar function
----------------

.. autofunction:: bar
+7

All Articles