How should I write down lists, options, and tutorials using Google-style Sphinx?

How do I specify list types, optional arguments, and return types for generators in Google-style dockstrons using Sphinx-Napoleon?

I tried

List[type] list of type Optional[type] type, optional 

and

 Yields: type: 

respectively; but they all produce an unsatisfactory result that is not consistent with the rest of the generated documentation. for example

 Optional[type] 

just gives

Optional [type]

no link for type .

I tried every built-in theme and had the same problems.

How should I document these elements using google-style docstrings with Sphinx-Napoleon?

+45
generator types documentation python-sphinx
Dec 04 '15 at 23:38
source share
1 answer

I know this is pretty old, but have you looked at this example ? In particular, the lines:

 def __init__(self, param1, param2, param3): """Example of docstring on the __init__ method. The __init__ method may be documented in either the class level docstring, or as a docstring on the __init__ method itself. Either form is acceptable, but the two should not be mixed. Choose one convention to document the __init__ method and be consistent with it. Note: Do not include the `self` parameter in the ``Args`` section. Args: param1 (str): Description of `param1`. param2 (:obj:`int`, optional): Description of `param2`. Multiple lines are supported. param3 (:obj:`list` of :obj:`str`): Description of `param3`. """ self.attr1 = param1 self.attr2 = param2 self.attr3 = param3 #: Doc comment *inline* with attribute #: list of str: Doc comment *before* attribute, with type specified self.attr4 = ['attr4'] self.attr5 = None """str: Docstring *after* attribute, with type specified.""" 
+1
Sep 08 '17 at 19:40
source share



All Articles