Skip to main content

Generate Docstrings with type-hint information.

Project description

Docstring Generator Extension

C++ Tests Build Extension PyPI version Python versions License: MIT

docstring_generator_ext is a high-performance Python extension written in C++ (using pybind11) designed to automatically generate and inject docstrings into Python source files. It leverages Python's ast module to extract type-hint information and function signatures to create well-formatted docstrings in various styles.

Features

  • Automatic Docstring Injection: Parses Python files and inserts docstrings for functions and methods.
  • Type-Hint Awareness: Extracts type information from annotations and default values.
  • Multiple Styles: Supports popular docstring formats:
    • reST (reStructuredText)
    • Google style
    • NumPy style
  • High Performance: Core logic implemented in C++ for fast processing.
  • Preserves Existing Content: Can update existing docstrings while trying to preserve manually added descriptions (using a special $ marker convention).

Installation

Prerequisites

  • Python 3.13 or higher
  • A C++ compiler with C++20 support (e.g., GCC, Clang, or MSVC)
  • pybind11

Building from Source

  1. Clone the repository:

    git clone https://github.com/FelixTheC/docstring_generator_ext.git
    cd docstring_generator_ext
    
  2. Install the build package:

    pip install build
    
  3. Build the package:

    python -m build
    
  4. Install the built wheel:

    pip install dist/docstring_generator_ext-*.whl
    

Usage

After installation, you can use the extension in your Python scripts:

import docstring_generator_ext

# Path to the Python file you want to process
file_path = "path/to/your_script.py"

# Choose a style: GOOGLE, NUMPY, or reST
style = docstring_generator_ext.DocstringFormatStyle.GOOGLE

# Generate and inject docstrings
docstring_generator_ext.parse_file(file_path, style)

Docstring Styles

The extension provides an enum DocstringFormatStyle to choose the desired output:

  • docstring_generator_ext.DocstringFormatStyle.reST
  • docstring_generator_ext.DocstringFormatStyle.GOOGLE
  • docstring_generator_ext.DocstringFormatStyle.NUMPY

Authors

  • FelixTheC

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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

docstring_generator_ext-1.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distributions

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

docstring_generator_ext-1.0.2-cp314-cp314-win_amd64.whl (137.8 kB view details)

Uploaded CPython 3.14Windows x86-64

docstring_generator_ext-1.0.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

docstring_generator_ext-1.0.2-cp314-cp314-macosx_11_0_arm64.whl (156.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

docstring_generator_ext-1.0.2-cp314-cp314-macosx_10_15_x86_64.whl (166.4 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

docstring_generator_ext-1.0.2-cp313-cp313-win_amd64.whl (134.2 kB view details)

Uploaded CPython 3.13Windows x86-64

docstring_generator_ext-1.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (182.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

docstring_generator_ext-1.0.2-cp313-cp313-macosx_11_0_arm64.whl (156.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

docstring_generator_ext-1.0.2-cp313-cp313-macosx_10_13_x86_64.whl (166.4 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

File details

Details for the file docstring_generator_ext-1.0.2.tar.gz.

File metadata

  • Download URL: docstring_generator_ext-1.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docstring_generator_ext-1.0.2.tar.gz
Algorithm Hash digest
SHA256 543972de250d5343e1ccfca426cb393e7c4ac38df5e3a9ae8039220a13f968d0
MD5 c2a3d58586f0fbbc1d661d4d28ee3873
BLAKE2b-256 44e6093358d1064fde675a2842b42efedf7702a4255328529ec9e67331759218

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2.tar.gz:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 506888c8a131fa4d907db200fb9f43841a6f3ada9e9f9be1539ee93475420ae2
MD5 477d82766082a09f672c2fa74d5e718b
BLAKE2b-256 f374636286d6684d32b03d828ae8cf7365ee2740b514ccfa1498126abab2167c

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp314-cp314-win_amd64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 988cef69cb98a5c2f6471c74584fd176feb2a8e5da8a44deba36a9e622834966
MD5 5576242cc16bcda8e26b853d737432cf
BLAKE2b-256 03ddd654a4f1bac8eb17bbd9e1e42622f713379a2aceca7367b61516ea823e6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec237b534ed6bd9ccdae9323412a9b0c44c7511d0261de706b2dac52cd017c21
MD5 aeb9aa0c68557d7e992ffecfbedd596d
BLAKE2b-256 e86785d3bda0759be367cf62b25a73e350188ce22295649815a6938b7dabf332

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 791125ce7f8fa47e630de4d3c836e426b6a440adbe5797f6453c9ae4c41f3459
MD5 4be168964d13b2b35c1c6d90172f6a90
BLAKE2b-256 6503b5cabb4c8b56b930a189218764b526808739f7d2ac1194e74b0064b61896

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp314-cp314-macosx_10_15_x86_64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f2940ea96baa52eedea6df851fab2e40e7aff2f6cb9d306f3351520fbb998b71
MD5 d5bba03ba92ada91b92b4f6bf8bd237a
BLAKE2b-256 30ef1d26380c254344829442cc9c1085e0f264e88587559425cff34950ab660b

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp313-cp313-win_amd64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 48d158d3e83981e8a53f81eff454257e2db0b55565354d0bc7c4ee51eb050386
MD5 8f7ba1a0bd104bb40c94515b0e4774ae
BLAKE2b-256 b8d810912a72ab77cc7cadd78938ab71176704b0aae4311d75e49a7a72bff9f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e0d5af15a93ce7c546c886f5c00625be3fa0f1bb6a2a3866c6aa009f7358a98
MD5 4664cdc48198f4e6fdf6487a3aaa9bc3
BLAKE2b-256 f895194b9a84c48dd211b02843765cb4479b9a8fd780f4a8ddf29d462a4b016f

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_generator_ext-1.0.2-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for docstring_generator_ext-1.0.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5ad9d0dfb9621643c269a41dc1daeee9ced3d5fe476aae011aa64b4f1a2f9912
MD5 35be0460d601950a75aea04592d3e369
BLAKE2b-256 f0ffbf220728830d83a743b71133e55f1b675a8b3f03411c1471561a74afa61e

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator_ext-1.0.2-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: python-publish-ext.yml on FelixTheC/docstring_generator_ext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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