cape.text: Module to print docstrings to STDOUT¶
This module provides several functions for modifying Python docstrings. One of
these, provided by the function markdown(), which removes much of the
reST syntax used to make this documentation and prints a more readable message
for command-line help messages.
There is another function setdocvals() which can be used to rapidly
substitute strings such as _atol_ with a value for atol taken from a
dict.
- cape.text.get_nstart(line, c)¶
Count number of instances of character c at start of a line
- Call:
>>> nc = get_nstart(line, c)
- Inputs:
- line:
str|unicode String
- c:
str Character
- line:
- Outputs:
- nc: nonnegative
int Number of times c occurs at beginning of string (can be 0)
- nc: nonnegative
- Versions:
2017-02-17
@ddalle: First version
- cape.text.markdown(doc)¶
Remove some extraneous markup for command-line help messages
- Call:
>>> txt = markdown(doc)
- Inputs:
- doc:
str Docstring
- doc:
- Outputs:
- txt:
str Help message with some of the RST features removed for readability
- txt:
- Versions:
2017-02-17
@ddalle: First version
- cape.text.markdown_try(doc)¶
Remove some extraneous markup for command-line help messages
- Call:
>>> txt = markdown_try(doc)
- Inputs:
- doc:
str Docstring
- doc:
- Outputs:
- txt:
str Help message with some of the RST features removed for readability
- txt:
- Versions:
2017-02-17
@ddalle: First version
- cape.text.setdocvals(doc, vals)¶
Replace tags such as
"_tol_"with values from a dictionary- Call:
>>> txt = setdocvals(doc, vals)
- Inputs:
- doc:
str Docstring
- vals:
dict Dictionary of key names to replace and values to set them to
- doc:
- Outputs:
- txt:
str string with
"_%s_"%k->str(vals[k]))for k in vals
- txt:
- Versions:
2017-02-17
@ddalle: First version