Kobi K
Kobi K

Reputation: 7931

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?

Upvotes: 1

Views: 880

Answers (1)

ljk321
ljk321

Reputation: 16770

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

Upvotes: 3

Related Questions