Skip to main content

Templated docstrings for Python classes.

Project description

documented

Coverage Python Version wemake-python-styleguide PyPI - License

Templated docstrings for Python classes.

Features

  • 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.

Installation

pip install documented

Example

from dataclasses import dataclass
from documented import DocumentedError


@dataclass
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

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


raise InsufficientWizardryLevel(
    spell='Animal transformation',
    required_level=8,
    actual_level=0,
)

which prints:

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

InsufficientWizardryLevel: 
🧙 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: https://anatoly-scherbakov.github.io/documented/

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.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

documented-0.1.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file documented-0.1.3.tar.gz.

File metadata

  • Download URL: documented-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-53-generic

File hashes

Hashes for documented-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4844ef5e84910a8827a6f55661cfa536315da70ab638f907a9e113d7107f137c
MD5 d9e90944a28dc8298b9b41fd1d7373ab
BLAKE2b-256 24e286055c7ccfc97b72ead17889aac59dcd1ca07df6d33190e3ffea163e0ee0

See more details on using hashes here.

File details

Details for the file documented-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: documented-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-53-generic

File hashes

Hashes for documented-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3bdcb8d68b0b82d0d52927767704c1a7bb1defa6722cee0eb157dfee1a1945b0
MD5 bd23160f23edeb5fa953e84dabb89d31
BLAKE2b-256 b5f46800296cb062e2fe74e421efdca528bdbbb1f6a3c7e1243450d67e6cc930

See more details on using hashes here.

Supported by

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