简体   繁体   中英

Documentation of variable in function in epydoc

How to document instance variable defined in function using epydoc. I used the following but in the variable section of generated html documentation only __package__ = None is shown.

def fun()
     x = 22    #: Document defining the purpose of x

This is specified on EpyDoc website:

Variables may also be documented using comment docstrings. If a variable assignment is immediately preceeded by a comment whose lines begin with the special marker '#:', or is followed on the same line by such a comment, then it is treated as a docstring for that variable:

#: docstring for x
x = 22
x = 22 #: docstring for x

You can't and you don't. Epydoc and similar tools are for creating API documentation, ie documentation for people using your functions (classes, …). For using a function it doesn't matter what the names local to the function stand for as those are not part of the public interface. The interface is just the arguments and the return value. The actual implementation is a black box and should be exchangeable as long as the function does what its documentation promises.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM