Skip to main content

It parses and composes docstrings in Google, Numpydoc, ReST and Epydoc.

Project description

The project is a fork from the original project - https://github.com/rr-/docstring_parser/

Based on the provided document, here is a README outline for the Python package it describes:


PyDocSmith

PyDocSmith is a versatile Python package designed for parsing, detecting, and composing docstrings in various styles. It supports multiple docstring conventions, including reStructuredText (reST), Google, NumPydoc, and Epydoc, providing flexibility in documentation practices for Python developers.

Features

  • Docstring Style Detection: Automatically detect the style of docstrings (e.g., reST, Google, NumPydoc, Epydoc) using simple heuristics.
  • Docstring Parsing: Convert docstrings into structured representations, making it easier to analyze and manipulate documentation.
  • Docstring Composition: Render structured docstrings back into text, allowing for automated docstring generation and modification.
  • Attribute Docstrings: Parse attribute docstrings defined at class and module levels, enhancing the documentation of class properties and module-level variables.

Installation

pip install PyDocSmith

Usage

Detecting Docstring Style

Detect the docstring style of a given text:

from PyDocSmith import detect_docstring_style, DocstringStyle

docstring = """
This is an example docstring.
:param param1: Description of param1
:return: Description of return value
"""
style = detect_docstring_style(docstring)
print(style)  # Outputs: DocstringStyle.EPYDOC

Parsing Docstrings

Parse a docstring into its components:

from PyDocSmith import parse, DocstringStyle

parsed_docstring = parse(docstring, style=DocstringStyle.AUTO)
print(parsed_docstring)

Composing Docstrings

Render a parsed docstring back into text:

from PyDocSmith import compose

docstring_text = compose(parsed_docstring, style=DocstringStyle.REST)
print(docstring_text)

Advanced Features

  • Parse From Object: PyDocSmith can parse docstrings directly from Python objects, including classes and modules, incorporating attribute docstrings into the structured representation.
  • Custom Rendering Styles: Customize the rendering of docstrings with compact or detailed styles, and specify custom indentation for the generated docstring text.

Contributing

Contributions are welcome! Please submit pull requests or report issues on the project's GitHub page.

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

PyDocSmith-0.1.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

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

PyDocSmith-0.1-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

Details for the file PyDocSmith-0.1.tar.gz.

File metadata

  • Download URL: PyDocSmith-0.1.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for PyDocSmith-0.1.tar.gz
Algorithm Hash digest
SHA256 4756c8d0442f53f164c83d9436f7c6ef4e1e7b65a76cba2a9eb6cbabc8d012fc
MD5 57cd37c28e60e5bf5d1d39857d5348bb
BLAKE2b-256 1876df63b422883b02b73b26a26f777970f58e802bfad65391a5962a06f48c6d

See more details on using hashes here.

File details

Details for the file PyDocSmith-0.1-py3-none-any.whl.

File metadata

  • Download URL: PyDocSmith-0.1-py3-none-any.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for PyDocSmith-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52c82de8c4dd5c11b936ad3f4952e7972dee381109cb323b520dce2977cfc5e9
MD5 e4ffd34987e8eddc09fde4abbb7017a8
BLAKE2b-256 ab018d0fa30bbe040ab5c4b4374a8acf5ee7f39acbe0d4a95f1557b2296c056a

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