Metadata-Version: 2.1
Name: class-doc
Version: 0.2.6
Summary: Extract attributes docstrings defined in various ways
Home-page: https://github.com/danields761/class-doc
License: MIT
Author: Daniel Daniels
Author-email: danields761@gmail.com
Requires-Python: >=3.6,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: more-itertools (>=5.0.0)
Project-URL: Repository, https://github.com/danields761/class-doc
Description-Content-Type: text/markdown

# Class doc

Small set of helpers aimed to extract class attributes documentation from the class definition. This stuff tries to mimic [sphinx-autodoc behaviour](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute) as closely as possible (except instance attributes defined inside `__init__` function).

The main advantage of this project over [sphinx-autodoc] is that it is lightweight single-purpose dependency, while *autodoc* just a small part of really heavy project.

## Installation

This package is available on [PyPI]

```bash
pip install class-doc
```

## Examples

Shamely stolen from [sphinx-autodoc] docs

```python
class Foo:
    """Docstring for class Foo."""

    #: Doc comment for class attribute Foo.bar.
    #: It can have multiple lines.
    bar = 1

    flox = 1.5   #: Doc comment for Foo.flox. One line only.

    baz = 2
    """Docstring for class attribute Foo.baz."""
    
    baf = 3
    """
    Even
    multiline
    docstrings
    handled
    properly
    """



import class_doc
assert class_doc.extract_docs_from_cls_obj(Foo) == {
    "bar": ["Doc comment for class attribute Foo.bar.", "It can have multiple lines."],
    "flox": ["Doc comment for Foo.flox. One line only."],
    "baz": ["Docstring for class attribute Foo.baz."],
    "baf": ["Even", "multiline", "docstrings", "handled", "properly"]
}
```

## Development setup

Project requires [Poetry] for development setup.

* If you aren't have it already

```sh
pip install poetry
``` 

* Install project dependencies

```sh
poetry install
```

* Run tests

```sh
poetry run pytest .
```

* Great, all works!

<!-- Links -->
[PyPI]: http://pypi.org
[Poetry]: https://poetry.eustace.io/
[sphinx-autodoc]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute
