PyDocSmith


NamePyDocSmith JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/SingularityX-ai/PyDocSmith
SummaryIt parses and composes docstrings in Google, Numpydoc, ReST and Epydoc.
upload_time2024-05-24 15:54:45
maintainerNone
docs_urlNone
authorSuman Saurabh
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            The project is a fork from the original project - https://github.com/rr-/docstring_parser/



# 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

```bash
pip install PyDocSmith
```

## Usage

### Detecting Docstring Style

Detect the docstring style of a given text:

```python
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:

```python
from PyDocSmith import parse, DocstringStyle

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

### Composing Docstrings

Render a parsed docstring back into text:

```python
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.

## Things that have been modified wrt to docstring_parser

1. Better heuristics to detect docstring style
2. Google Docstring has been modified to accommodate Notes, Examples
3. Sometime GoogleDoc string doesn't have proper indentation specially when generated from LLMs like GPT or Mistral. PyDocSmith can fix those bad docstrings.
4. Additional test-cases were added to accommodate a different style of GoogleDocstring

I have updated it based on use case for - https://www.penify.dev

## Contributing

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SingularityX-ai/PyDocSmith",
    "name": "PyDocSmith",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Suman Saurabh",
    "author_email": "ss.sumansaurabh92@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/22/90/f5b001a5e3d172b950e6504668e57f499e66fa38dfd4e869456028e56c40/pydocsmith-0.1.3.tar.gz",
    "platform": null,
    "description": "The project is a fork from the original project - https://github.com/rr-/docstring_parser/\n\n\n\n# PyDocSmith\n\nPyDocSmith 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.\n\n## Features\n\n- **Docstring Style Detection:** Automatically detect the style of docstrings (e.g., reST, Google, NumPydoc, Epydoc) using simple heuristics.\n- **Docstring Parsing:** Convert docstrings into structured representations, making it easier to analyze and manipulate documentation.\n- **Docstring Composition:** Render structured docstrings back into text, allowing for automated docstring generation and modification.\n- **Attribute Docstrings:** Parse attribute docstrings defined at class and module levels, enhancing the documentation of class properties and module-level variables.\n\n## Installation\n\n```bash\npip install PyDocSmith\n```\n\n## Usage\n\n### Detecting Docstring Style\n\nDetect the docstring style of a given text:\n\n```python\nfrom PyDocSmith import detect_docstring_style, DocstringStyle\n\ndocstring = \"\"\"\nThis is an example docstring.\n:param param1: Description of param1\n:return: Description of return value\n\"\"\"\nstyle = detect_docstring_style(docstring)\nprint(style)  # Outputs: DocstringStyle.EPYDOC\n```\n\n### Parsing Docstrings\n\nParse a docstring into its components:\n\n```python\nfrom PyDocSmith import parse, DocstringStyle\n\nparsed_docstring = parse(docstring, style=DocstringStyle.AUTO)\nprint(parsed_docstring)\n```\n\n### Composing Docstrings\n\nRender a parsed docstring back into text:\n\n```python\nfrom PyDocSmith import compose\n\ndocstring_text = compose(parsed_docstring, style=DocstringStyle.REST)\nprint(docstring_text)\n```\n\n## Advanced Features\n\n- **Parse From Object:** PyDocSmith can parse docstrings directly from Python objects, including classes and modules, incorporating attribute docstrings into the structured representation.\n- **Custom Rendering Styles:** Customize the rendering of docstrings with compact or detailed styles, and specify custom indentation for the generated docstring text.\n\n## Things that have been modified wrt to docstring_parser\n\n1. Better heuristics to detect docstring style\n2. Google Docstring has been modified to accommodate Notes, Examples\n3. Sometime GoogleDoc string doesn't have proper indentation specially when generated from LLMs like GPT or Mistral. PyDocSmith can fix those bad docstrings.\n4. Additional test-cases were added to accommodate a different style of GoogleDocstring\n\nI have updated it based on use case for - https://www.penify.dev\n\n## Contributing\n\nContributions are welcome! Please submit pull requests or report issues on the project's GitHub page.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "It parses and composes docstrings in Google, Numpydoc, ReST and Epydoc.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/SingularityX-ai/PyDocSmith"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a6f5a00009017dfca808ba58e21b56daf19556f4b19f831f861189f69db2356",
                "md5": "86a34bc3bf8dace62fcf5160de9b148b",
                "sha256": "db0c14bca3e5475fd2749bd63ec53bfb187fce3d766c58195013176b9a83bdce"
            },
            "downloads": -1,
            "filename": "PyDocSmith-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86a34bc3bf8dace62fcf5160de9b148b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 40477,
            "upload_time": "2024-05-24T15:54:43",
            "upload_time_iso_8601": "2024-05-24T15:54:43.035935Z",
            "url": "https://files.pythonhosted.org/packages/8a/6f/5a00009017dfca808ba58e21b56daf19556f4b19f831f861189f69db2356/PyDocSmith-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2290f5b001a5e3d172b950e6504668e57f499e66fa38dfd4e869456028e56c40",
                "md5": "5a80f6d691786833f51e1f68d9ebc4e0",
                "sha256": "875dcf4d8baaf9545c44b326ab6d9fa040332d6e4ff3c83d07159d796f82ef5a"
            },
            "downloads": -1,
            "filename": "pydocsmith-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "5a80f6d691786833f51e1f68d9ebc4e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 33040,
            "upload_time": "2024-05-24T15:54:45",
            "upload_time_iso_8601": "2024-05-24T15:54:45.045327Z",
            "url": "https://files.pythonhosted.org/packages/22/90/f5b001a5e3d172b950e6504668e57f499e66fa38dfd4e869456028e56c40/pydocsmith-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-24 15:54:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SingularityX-ai",
    "github_project": "PyDocSmith",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pydocsmith"
}
        
Elapsed time: 0.24085s