A trivial question that I don't know - document a function/method

Mats Wichmann mats at wichmann.us
Mon Oct 24 13:17:29 EDT 2022


On 10/23/22 14:20, Paulo da Silva wrote:
> Às 21:58 de 22/10/22, Paulo da Silva escreveu:
>> Hi all!
>>
>> What is the correct way, if any, of documenting a function/method?
>>
> 
> Thank you all for the, valuable as usual, suggestions.
> I am now able to make my choices.
> 
> Paulo

It also matters whether you expect the docstring to stand on its own, or 
to be processed by a doc-generation tool (like Sphinx).  In the former 
case, make it look nice in a way that suits you. In the latter case, use 
the reStructuredText conventions that exist (there are at least three 
common styles) for the document processor.  While these styles are 
intended to also be very human-readable, they may not be exactly how you 
wanted to format things for visual display when looking directly at 
code, so it's worth thinking about this up front.

See for example:

https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html





More information about the Python-list mailing list