Skip to main content

fml_doc_gen

Documentation Documentation Status
Testing codecov
Package PyPI Latest Release
Downloads PyPI Downloads
Supported Versions Python Version

Authors

  • Farhan Bin Faisal
  • Michael Suriawan
  • Lukman Lateef

Summary

fml_doc_gen is a Python package designed to simplify the process of writing docstrings for user-defined functions. It offers an automated way to generate docstring templates or fully detailed docstrings through integration with the OpenAI API. By streamlining documentation, it helps developers save time, improve code readability, and maintain consistent documentation standards across projects.

Installation

$ pip install fml_doc_gen 

Usage

generate_docstring_template can be used to generate docstring template for your function shown below:

import fml_doc_gen
from fml_doc_gen.fml_doc_gen import generate_docstring_template

def square(base: int, pow: int) -> int:
    return base ** pow

print(generate_docstring_template(square, output_file=None))

OpenAI Dependency:

fml_doc_gen requires an OpenAI API key to generate docstrings. You can set your API key using the OPENAI_API_KEY environment variable. Check our our documentation here for more information.

Functions Included

  • generate_docstring_template(func: Callable, output_file: str, auto_generate: bool = False) -> str: The main end-user function that generates either a docstring template with placeholders or a fully detailed docstring if auto_generate is set to True.

  • read_user_function(func: Callable) -> FunctionDTO: Reads and extracts the signature and existing docstring (if any) of a given user-defined function.

  • generate_template(func_signature: str) -> str: Creates a docstring template with placeholders for parameters, return values, and a brief description based on the function signature.

  • write_docstring_to_file(docstring: str, output_file: str) -> None: Writes the generated docstring to a specified file.

Python Ecosystem

fml_doc_gen fits into the Python ecosystem as a specialized tool for automating function documentation. While other Python packages like sphinx and pydoc exist for generating documentation from docstrings, there are no widely known packages that automatically generate docstrings themselves using AI. This makes fml_doc_gen unique in its approach by leveraging OpenAI's capabilities to produce high-quality docstrings with minimal effort from the developer.

If you are aware of a similar tool, feel free to contribute to our documentation by suggesting it!

Discussion and Improvements

Found a bug? or have an idea on how to improve fml_doc_gen further? Feel free to open an issue with the appropriate label (bug or features) under the issue section here.

Running Tests

To run tests and check code coverage, use the following command in the project root:

poetry run pytest --cov=fml_doc_gen --cov-report=term-missing tests/

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

fml_doc_gen was created by Farhan Faisal, Lukman Lateef, and Michael Suriawan. It is licensed under the terms of the MIT license.

Credits

fml_doc_gen was created with cookiecutter and the py-pkgs-cookiecutter template.

Metadata

Release files for fml-doc-gen 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fml-doc-gen 3.1.1
File Size Uploaded Provenance Actions
fml_doc_gen-3.1.1.tar.gz 6.6 kB Without provenance Details for fml_doc_gen-3.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fml-doc-gen 3.1.1
File Interpreter ABI Platform Actions
fml_doc_gen-3.1.1-py3-none-any.whl Python 3 none any Details for fml_doc_gen-3.1.1-py3-none-any.whl

Total release size: 15.7 kB

Release files / fml_doc_gen-3.1.1.tar.gz

Download URL fml_doc_gen-3.1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8f95ba003d97324597e499672164d0f3868a04fdc681cfadc05ccac1782cd3f4
BLAKE2b-256 checksum
How to use checksums
3c48ed192ae335091135283b72be6d542103403cebbe57215fa7d60bebf97210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / fml_doc_gen-3.1.1-py3-none-any.whl

Download URL fml_doc_gen-3.1.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2c0232b048a1dbdee658c7707375b6af052212b744a7b15618ff30a87958b4d
BLAKE2b-256 checksum
How to use checksums
52e928f437adde180d15bf7e3d572c786cc9d4c656057913cbb3b589441a7c2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for fml-doc-gen 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page