pythonpython-sphinxdocstringnumpydoc

Python auto docstring with sphinx new line


I am wondering how can I have a new line when generating auto documentation using Sphinx. I am not using the default Sphinx docstring format reStructuredText, but I am using the Numpydoc format. I tried using '\n' yet it makes a line break, and I only need a new line. Here is an example of a Python module ...

""" This is the first sentences 
| this is the second sentence at line 2 ... note that vertical bar 
| this is the second sentence at line 3 ... note that vertical bar 
...... 
def function1 (input):
    """ this function docstring starts here
    | this is not sentence number 2 at the vertical bar is not working 
    | this is not sentence number 3 at the vertical bar is not working 
    | this is not sentence number 4 at the vertical bar is not working 
"""

Solution

  • Simply add a blank line after the first line:

    def function1 (input):
        """ this function docstring starts here
    
        | this is not sentence number 2 at the vertical bar is not working 
        | this is not sentence number 3 at the vertical bar is not working 
        | this is not sentence number 4 at the vertical bar is not working 
        """
    

    Body elements are separated by blank lines. The docstring consists of two body elements: a regular paragraph and a line block.