python - "Docstring processing tools" following PEP 257? -
pep 257 says:
docstring processing tools strip uniform amount of indentation second , further lines of docstring, equal minimum indentation of non-blank lines after first line. indentation in first line of docstring (i.e., first newline) insignificant , removed. relative indentation of later lines in docstring retained. blank lines should removed beginning , end of docstring.
a function trim
implementing algorithm shown in pep.
i can find questions people ask how format docstrings , referred pep 257 (e.g., this). see info tools try ensure docstrings follow pep 257 (e.g., this). can't find python library is "docstring processing tool" handles docstrings in way defined in pep 257 --- or @ least, can't find tool makes docstring processing functionality directly available.
is there library makes available function trim
shown in pep 257? can paste function file myself, i'd prefer know name of publically available library can grab , install (e.g., via pip
or easy_install
) if i'm using other computer want functionality, instead of copying , pasting pep. given function in pep coauthored bdfl, have thought there official or semi-official library this.
edit: reason want write decorator python-internal reformatting of docstrings of classes/functions. don't want generate html or else; want change actual docstrings of actual objects. want take plain-text __doc__
attribute of python object , reformat serve plain-text __doc__
attribute of python object. know how assign __doc__
, want know library call some_func.__doc__ = library.reformatdocstr(some_func.__doc__)
, library whatever wrapping etc. @ doing?
in looking answer related question, managed find answer one. trim
algorithm implemented in inspect.cleandoc
, of places.
Comments
Post a Comment