documented
Templated docstrings for Python classes.
Example
examples/open-the-pod-bay-doors.py
from dataclasses import dataclass
from documented import Documented, DocumentedError
@dataclass
class PodBayDoorsStillClosed(DocumentedError):
"""
Iβm sorry, {self.user_name}.
Iβm afraid I canβt do that.
"""
user_name: str
class OpenThePodBayDoors(Documented):
"""Open the pod bay doors please, HAL."""
print(OpenThePodBayDoors())
raise PodBayDoorsStillClosed(user_name='Dave')
python
Open the pod bay doors please, HAL.
Traceback (most recent call last):
File "π/open-the-pod-bay-doors.py", line 22, in <module>
raise PodBayDoorsStillClosed(user_name='Dave')
PodBayDoorsStillClosed: Iβm sorry, Dave.
Iβm afraid I canβt do that.
Installation
documented
is on PyPI.
pip install documented
poetry add documented
pipenv install documented
pdm add documented
conda install -c conda-forge documented
Flow
graph TD
docstring("Class π <code>docstring</code>") --> dedent("β€ dedent")
dedent --> C("βοΈ Interpolate<br><code>{self.placeholders}</code>")
C --> str("<code>__str__()</code>")
str -- "for<br><code>DocumentedError</code>" --> raise("π₯ raise")
str -- "for<br><code>Documented</code>" --> print("π¨οΈ print | log")
print --> rich("as Markdown β console<br>with π₯οΈ <code>rich</code>")
raise --> try("π try β¦ except")
raise -- Stacktrace --> print
try --> print
style raise stroke:#CC0000
click dedent "https://docs.python.org/3/library/textwrap.html#textwrap.dedent"
click C "templating/"
click rich "compatibility/rich/"
click str "https://docs.python.org/3/reference/datamodel.html#object.__str__"
click try "try-except/"
click docstring "docstring/"
Used by
The asterisk below denotes projects which are mine
Linked Data workspace
Pythonic alternative to Make
Know more?
Let's talk
Bug? Feature request?
Anything else?
See my site: yeti.sh