简体   繁体   中英

Canonical way in Python to add or retrieve meta information to/from docstrings?

I'd like to add some meta information to my Python modules' docstrings, such as author, email, version. Is there a canonical way to do that? I searched quite a while, but couldn't find anything with definite authority, here or on the web.

PEP 426 -- Metadata for Python Software Packages 2.0 talks about it some. And it looks like __author__ , __version__ and some others are recognized by pydoc (V2.7). Also, there is epydoc and sphinx-doc .

Is there a standard way to include such information in the docstring? Or as global variables? If so, is there a list of accepted keywords / variable names?

Example:

#########
# Parts
# <description>
#
"""Helper module for selling car parts on the web.
   Author: Sue Baru
   EMail: sb@carparts.com
   Version: 1.0
"""

Update

This is not really an answer, but I ended up using the __author__ 'keyword' and nothing else. Versioning is accomplished by being checked into a git repo.

Sphinx does it this way (using reST):

"""A pypi demonstration vehicle.

.. moduleauthor:: Andrew Carter <andrew@invalid.com>

"""

See Documenting Your Project Using Sphinx and this cheatsheet for more.

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