Can Sphinx napoleon document function returning multiple arguments?

Python only returns a single object. If you call serv,msg = foo(myinput) Then you are explicitly expanding the expression_list tuple which is generated when the function returns with this code return servers,msg You docstring should read some thing like this (with the Napoleon Google Style) “”” one line summary longer explanation Args: a (int): parameter … Read more

Documenting class attributes with type annotations

I do not think you can put an Attribute section inside of your docstring to get your desired results. I tried giving each attribute a doc comment and specified the type and desired comment. class DataHolder: “”” Class to hold some data Each attribute needs its own doc comment with its type “”” #: bool: … Read more

How should I document lists, optionals, and yields using Google-style Sphinx? [closed]

I know this is quite old, but did you take a look at this example? Particularly 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 … Read more

Sphinx autosummary “toctree contains reference to nonexisting document” warnings

Sorry for such a late answer (if it can be considered that) but I found this link that discusses what may be happening to you: https://github.com/phn/pytpm/issues/3#issuecomment-12133978 The idea that if you have some special Doc scraper in your documentation code that is building autosummary documentation after autosummary has already run may be something to look … Read more

How to express multiple types for a single parameter or a return value in docstrings that are processed by Sphinx?

Python 3.10 | (pipe, binary or) Union type hint syntax sugar Once you get access, this will be the way to go, it is sweet: def f(i: int|str) -> int|str: if type(i) is str: return int(i) + 1 else: return str(i) The PEP: https://peps.python.org/pep-0604/ Documented at: https://docs.python.org/3.11/library/typing.html#typing.Union Union type; Union[X, Y] is equivalent to X … Read more

Custom PyCharm docstring stubs (i.e. for google docstring or numpydoc formats)

With PyCharm 5.0 we finally got to select Google and NumPy Style Python Docstrings templates. It is also mentioned in the whatsnew section for PyCharm 5.0. How to change the Docstring Format: File –> Settings –> Tools –> Python Integrated Tools There you can choose from the available Docstrings formats: Plain, Epytext, reStructuredText, NumPy, Google … Read more

tech