1

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 
"""
bad_coder
  • 11,289
  • 20
  • 44
  • 72
Kernel
  • 591
  • 12
  • 23
  • Will [line blocks](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#line-blocks) do what you want? – Steve Piercy Aug 13 '18 at 01:26
  • Thanks, the vertical bar works for module docstring, yet it didn't work for function docstring. I donot know why. I know that the line blocks based on [vertical bar is part of the restructured Text](https://stackoverflow.com/questions/7033239/how-to-preserve-line-breaks-when-generating-python-docs-using-sphinx). – Kernel Aug 13 '18 at 01:54
  • 2
    Please provide examples in your question. – Steve Piercy Aug 13 '18 at 08:03

1 Answers1

2

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.

mzjn
  • 48,958
  • 13
  • 128
  • 248