We can specify function parameter types using docstring in python:
def f1(a): """ :param a: an input. :type a: int :return: the input integer. :rtype: int """ return a
For f1
, autodoc creates the following document:
fun1(a) Parameters : a (int) â an input. Returns : the input integer. Return type: int
In python 3, types can also be specified using type hints:
def f2(a: int): """ :param a: an input. :return: the input integer. :rtype: int """ return a
When we run autodoc, it puts the type in the parameter declaration, but not in the description:
f2(a: int) Parameters : a â an input. Returns : the input integer. Return type: int
Is it possible to create documentation as f1
using annotation instead of docstring? I am using python 3.6. Thanks!
source share