Python
Content Extraction
In addition to snippets manipulation that is applicable to any language, Znai can extract content of methods.
:include-python: python/example.py {entry: "Animal.says", bodyOnly: true}
print("hello")
class Animal: """ animal top level class doc string ``` code block ``` """ def says(self): """ animal **talks** `code` """ print("hello")
Description Extraction
Znai provides plugin to extract PyDoc content. Use it to extract high level description and merge it with the rest of the documentation. Convert method parameters into API Parameters
:include-python-doc-params: python/pydoc-params.py {entry: "my_func", title: "result and parameters"}
def my_func(label, price): """ text inside my *func* doc * list one * list two Parameters ---------- label : str label to use to *render* item in the store price : fin.money.Money price associated with the **item** Returns ------- str status of the operation `OK` for good """ return "OK"
Auto Reference
Znai provides plugins to automatically create reference documentation for methods and classes.
:include-python-method: fin.money.render_money
render money to a string
money represented as text
amount
amount to print
message to use for audit
def render_money(amount: Money, message: str = "") -> str: """ render money to a string Parameters -------------- amount: amount to print message: message to use for audit Returns ------- money represented as text """ return f"{message} {amount.amount} {amount.currency}"