Skip to main content

A simple dataclasses wrapper for easier documentation of dataclasses

Project description

This is a work-in-progress library to add documentation functionality to dataclasses introduced in Python 3.7. The library can be used as a drop-in replacement for the standard dataclasses and can be installed from PyPI.

$ pip install literate_dataclasses

Literate dataclasses modify their own class docstrings and add attribute docs in [Google code style](https://google.github.io/styleguide/pyguide.html) with the goal of removing redundant code. The docs can be written as follows:

from literate_dataclasses import dataclass, field

@dataclass(test_arg = "hello")
class Test:
    """My dataclass

    Some comment.

    Args:
        See dataclass signature.
    """

    x: int = field(default = 42, doc = \
    """Some value x."""
    )

    y: int = field(default = 72, doc = \
    """Some value x."""
    )

    name: int = field(default = 'foo', doc = \
    """The object name.""",
    )

test = Test(x = 5, y = 3)
help(Test)

which will generate the output

Help on class Test in module __main__:

class Test(builtins.object)
|  Test(x: int = 42, y: int = 72, name: int = 'foo') -> None
|
|  My dataclass
|
|  Some comment.
|
|  Args:
|      x: Some value x.
|      y: Some value x.
|      name: The object name.

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

literate_dataclasses-0.0.3a0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

literate_dataclasses-0.0.3a0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file literate_dataclasses-0.0.3a0.tar.gz.

File metadata

  • Download URL: literate_dataclasses-0.0.3a0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for literate_dataclasses-0.0.3a0.tar.gz
Algorithm Hash digest
SHA256 e03cd7cc1d045428dda678106a763386b861d40061e1cea9d1f530584c9a42cb
MD5 da6d7af0c0395346625906359a242334
BLAKE2b-256 40f37634ec72f09873402a5716f43b8c948247daec8c73d0b610fd6fbc1e13f5

See more details on using hashes here.

File details

Details for the file literate_dataclasses-0.0.3a0-py3-none-any.whl.

File metadata

  • Download URL: literate_dataclasses-0.0.3a0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for literate_dataclasses-0.0.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 98fa4364be5aa980b3c0839c4478bf7a4fd86c22a8d360106846728f9e239e7d
MD5 4d0629c4832e3c6b9dc8c74c61c9b68d
BLAKE2b-256 1f1deed41d1b9c0fadc6eb6a42ed2bb5d3c2b73c64a412f76d7c633aef6e22b6

See more details on using hashes here.

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