简体   繁体   中英

Sphinx autofunction generate python docstring without newlines

I have a simple python package with 1 module containing the following function:

def sample_addition(num1=1, num2=2):
    """adding 2 numbers as an example

    this function will add 2 numbers in case of failre it will raise an exception
    @param num1: first number
    @type num1: float
    @param num2: second number
    @type num2: float
    @return: addition result
    @rtype: float
    """
    return num1 + num2

When using .. autofunction:: sample_addition and make html it results in:

general.sample_addition(num1=1, num2=2)
adding 2 numbers as an example

this function will add 2 numbers in case of failre it will raise an exception @param num1: first number @type num1: float @param num2: second number @type num2: float @return: addition result @rtype: float

I have installed and used sphinx_epytext inside the conf.py -> extensions but it didn't help to convert and show the Epytext properly

Question:

How can i allow it to see the new lines from the docstring?

Just like markdown and rst, it requires newline to seperate differert paragraphs, you need to add newline between this function... and @param ... like this:

def sample_addition(num1=1, num2=2):
    """adding 2 numbers as an example

    this function will add 2 numbers in case of failre it will raise an exception

    @param num1: first number
    @type num1: float
    @param num2: second number
    @type num2: float
    @return: addition result
    @rtype: float
    """

return num1 + num2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM