Skip to main content

Templated docstrings for Python classes.

Project description


Python Version wemake-python-styleguide PyPI - License

Templated docstrings for Python classes.


  • Describe your business logic in docstrings of your classes and exceptions;
  • When printing an object or an exception, the library will substitute the placeholders in the docstring text with runtime values,
  • And you (or your user) will see a human-readable text.


pip install documented


from dataclasses import dataclass
from documented import DocumentedError

class InsufficientWizardryLevel(DocumentedError):
    🧙 Your level of wizardry is insufficient ☹

        Spell: {self.spell}
        Minimum level required: {self.required_level}
        Actual level: {self.actual_level} {self.comment}

    Unseen University will be happy to assist in your training! 🎓

    spell: str
    required_level: int
    actual_level: int

    def comment(self) -> str:
        if self.actual_level <= 0:
            return '(You are Rincewind, right? Hi!)'
            return ''

raise InsufficientWizardryLevel(
    spell='Animal transformation',

which prints:

InsufficientWizardryLevel           Traceback (most recent call last)
<ipython-input-1-d8ccdb953cf6> in <module>
---> 29 raise InsufficientWizardryLevel(
     30     spell='Animal transformation',
     31     required_level=8,

🧙 Your level of wizardry is insufficient ☹

    Spell: Animal transformation
    Minimum level required: 8
    Actual level: 0 (You are Rincewind, right? Hi!)

Unseen University will be happy to assist in your training! 🎓

For more examples, see:

This project was generated with wemake-python-package.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

documented-0.1.4.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

documented-0.1.4-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page