# documented
[![Python Version](https://img.shields.io/pypi/pyversions/documented.svg)](https://pypi.org/project/documented/)
[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
![PyPI - License](https://img.shields.io/pypi/l/documented)
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
```bash
pip install documented
```
## Example
```python
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`](https://github.com/wemake-services/wemake-python-package).
Raw data
{
"_id": null,
"home_page": "https://github.com/anatoly-scherbakov/documented",
"name": "documented",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Anatoly Scherbakov",
"author_email": "altaisoft@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/be/f1/ee7c58862854fb5778aee40c15a0926415eaa9ed03d8a33bae5728f8e685/documented-0.1.4.tar.gz",
"platform": null,
"description": "# documented\n\n[![Python Version](https://img.shields.io/pypi/pyversions/documented.svg)](https://pypi.org/project/documented/)\n[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)\n![PyPI - License](https://img.shields.io/pypi/l/documented)\n\nTemplated docstrings for Python classes.\n\n## Features\n\n- Describe your business logic in docstrings of your classes and exceptions;\n- When printing an object or an exception, the library will substitute the placeholders in the docstring text with runtime values,\n- And you (or your user) will see a human-readable text.\n\n## Installation\n\n```bash\npip install documented\n```\n\n\n## Example\n\n```python\nfrom dataclasses import dataclass\nfrom documented import DocumentedError\n\n\n@dataclass\nclass InsufficientWizardryLevel(DocumentedError):\n \"\"\"\n \ud83e\uddd9 Your level of wizardry is insufficient \u2639\n\n Spell: {self.spell}\n Minimum level required: {self.required_level}\n Actual level: {self.actual_level} {self.comment}\n\n Unseen University will be happy to assist in your training! \ud83c\udf93\n \"\"\"\n\n spell: str\n required_level: int\n actual_level: int\n\n @property\n def comment(self) -> str:\n if self.actual_level <= 0:\n return '(You are Rincewind, right? Hi!)'\n else:\n return ''\n\n\nraise InsufficientWizardryLevel(\n spell='Animal transformation',\n required_level=8,\n actual_level=0,\n)\n```\n\nwhich prints:\n\n```\n---------------------------------------------------------------------\nInsufficientWizardryLevel Traceback (most recent call last)\n<ipython-input-1-d8ccdb953cf6> in <module>\n 27 \n 28 \n---> 29 raise InsufficientWizardryLevel(\n 30 spell='Animal transformation',\n 31 required_level=8,\n\nInsufficientWizardryLevel: \n\ud83e\uddd9 Your level of wizardry is insufficient \u2639\n\n Spell: Animal transformation\n Minimum level required: 8\n Actual level: 0 (You are Rincewind, right? Hi!)\n\nUnseen University will be happy to assist in your training! \ud83c\udf93\n```\n\nFor more examples, see: https://anatoly-scherbakov.github.io/documented/\n\nThis project was generated with [`wemake-python-package`](https://github.com/wemake-services/wemake-python-package).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Templated docstrings for Python classes.",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/anatoly-scherbakov/documented",
"Repository": "https://github.com/anatoly-scherbakov/documented"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5e0de61fc5e2e6423fdb68d6bae00e3f7c6d61fb1be1737f987d38473aab227e",
"md5": "f25783958543dde41effd94e69d08236",
"sha256": "de3fd47c1f11f01c3237a8857d6dc730809c32b252d5b53e16bccdf6b6bb0894"
},
"downloads": -1,
"filename": "documented-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f25783958543dde41effd94e69d08236",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0",
"size": 5103,
"upload_time": "2023-10-02T20:16:29",
"upload_time_iso_8601": "2023-10-02T20:16:29.205702Z",
"url": "https://files.pythonhosted.org/packages/5e/0d/e61fc5e2e6423fdb68d6bae00e3f7c6d61fb1be1737f987d38473aab227e/documented-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bef1ee7c58862854fb5778aee40c15a0926415eaa9ed03d8a33bae5728f8e685",
"md5": "1d0d94de2b71696de5d62a3f03bfee4b",
"sha256": "f02ff67419b5d2403e6fad6c992fb5d3392673a2825ebb7d93a97f825102d4f2"
},
"downloads": -1,
"filename": "documented-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "1d0d94de2b71696de5d62a3f03bfee4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0",
"size": 3909,
"upload_time": "2023-10-02T20:16:32",
"upload_time_iso_8601": "2023-10-02T20:16:32.211283Z",
"url": "https://files.pythonhosted.org/packages/be/f1/ee7c58862854fb5778aee40c15a0926415eaa9ed03d8a33bae5728f8e685/documented-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-02 20:16:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "anatoly-scherbakov",
"github_project": "documented",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "documented"
}