Automated Python Documentation in README file
What's this?
Automated docstring extraction and creation/update of documentation of python modules in the README File.
Why should I use it?
Because it's nice to have a quick overview of all the functions, classes and methods of your module documented in the README file ;-)
How does it work?
doc_to_md.py loops through all Python files in the Repository, and extracts the function calls & the corresponding short description from the docstrings. These are added to a dictionary and afterwards converted to a Markdown Table. Finally, the section Functions & Classes is appended / updated in the README File.
There are two options how to use it:
a) CI Pipeline
b) Python Package
a) include it in your CI Pipeline (GitHub, GitLab, Bitbucket or Azure Devops)
Check out this Step-by-step guide on how to integrate doc_to_readme in your Repository.
b) install & use the Python Package
pip install doc-to-readme
- Use within Python
import doc_to_md.doc_to_md as dtm
dtm.update_markdown_file(
file="README.md",
root_dir=None, # Directory used as root for searching modules, defaults to folder containing README.md
exclude_modules=None, # List of modules to be excluded
specified_modules=None, # Only these modules will be included
separate=True # Create one table per module
)
- Command Line
python -m doc_to_md.doc_to_md -f "README.md" [-r ROOT_DIR] [-e EXCLUDE_MODULES] [-m SELECTED_MODULES] [--separated]
-r ROOT_DIR # Directory used as root for searching modules, defaults to folder containing README.md
-e EXCLUDE_MODULES # List of modules to be excluded
-m SELECTED_MODULES # Only these modules will be included
--separated # Create one table per module
Copyright © 2023 by Mirjam Ziselsberger
This code is free to use under the terms of the MIT license.
Functions & Classes
doc_to_md.py
| Type | Name/Call | Description |
|---|---|---|
| function | loop_through_repo(
file: str,
root_dir: str = None,
exclude_modules: Optional[Tuple[str, ...]] = None,
specified_modules: Optional[Tuple[str, ...]] = None
) -> None |
Collect documentation from functions & classes. |
| function | add_summary_to_md(
overview_dict: Dict[str, Optional[Union[str, Dict[str, str]]]],
markdown: str,
separate: bool = True
) |
Add Table with all Functions & Classes to Markdown file. |
| function | update_markdown_file(
file: str = "../../README.md",
root_dir: str = None,
exclude_modules: Optional[Tuple[str, ...]] = (
"test",
"functions_for_testing",
"classes_for_testing",
"doc_to_md"
),
specified_modules: Optional[Tuple[str, ...]] = None,
separate: bool = True
) |
Add/update 'Functions & Classes' Section in Markdown file. |
| function | parse_through_file(file: str) -> Dict[str, Dict[str, str]] |
Parse through file, return dict with classes and functions. |
test_dtm.py
| Type | Name/Call | Description |
|---|---|---|
| class | LoopThroughRepo |
None |
| method (LoopThroughRepo) | setUp(self) -> None |
None |
| method (LoopThroughRepo) | test_loop_through_repo(self) |
None |
| method (LoopThroughRepo) | test_loop_through_repo_specified_modules(self) |
None |
| method (LoopThroughRepo) | test_loop_through_repo_exclude_modules(self) |
None |
Created with: doc_to_readme
MIT © 2023 Mirjam Ziselsberger
Last Update: 2024-12-14
Metadata
Release files for doc-to-readme 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| doc_to_readme-1.2.0.tar.gz | 301.5 kB | Without provenance | Details for doc_to_readme-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| doc_to_readme-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for doc_to_readme-1.2.0-py3-none-any.whl |
Total release size: 309.4 kB
Release files / doc_to_readme-1.2.0.tar.gz
| Download URL | doc_to_readme-1.2.0.tar.gz |
|---|---|
| Size | 301.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9080754fe8b31a2b8f7048a40e32c7ee148a5df1346de80eefe38b76afb1274
|
|
BLAKE2b-256 checksum How to use checksums |
8fdd507d6579e82534e9e9dfe12bd9774fb750dfa1c7f3ca407296b785badb8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / doc_to_readme-1.2.0-py3-none-any.whl
| Download URL | doc_to_readme-1.2.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f754926114a34c6a2743568a180aceeaebe510ce41cc642873e989754bc7f85f
|
|
BLAKE2b-256 checksum How to use checksums |
de0902cc675b9b954a3407f6e540ffbc4a4ef15acdffea2f9335a2ca17c831de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for doc-to-readme 1.2.0
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.