Skip to main content

Auto documentation

Generate the markdown documentation (like Sphinx) to be used for vitepress, using GPT4. It uses the OpenAI API to generate the documentation based on the docstrings of the code.

Usage

Install the package using pypi

pip install autopress

Configure the package. The OpenAI API key will be asked if not already set.

autodoc configure

The configure command will ask for the OpenAI API key and let you change the default prompt for the OpenAI API.

The commands can be listed using

autopress --help
Commands:
  Autopress.from_class      Use this method to generate a docstring from...
  Autopress.from_docstring  Use this method to generate a docstring from...
  Autopress.from_file       Open a markdown file and replace the tags...
  Autopress.from_method     Use this method to generate a docstring from...
  configure                 Set your configuration settings

The main command is Autopress.from_file which will replace the tags in the markdown file with the actual documentation. Go in the root of the package and run the following command:

cd demo
autopress Autopress.from_file --file README.md --output README_out.md

The above command will generate the documentation for the README.md file and save it in the README_out.md file.

Example

The below tag will be replaced with the actual documentation of the method convert_tag from the module autopress.utils.

Before:

<MethodAutopress module="autopress.utils" method="convert_tag" />

After:

<!--<MethodAutopress module="autopress.utils" method="convert_tag"  id="9d66f8"/>-->
<!--<AutoDoc.Content id="9d66f8">-->

### `autopress.utils.convert_tag`
Converts a tag to a docstring and replaces it in the content. This operation is useful when modifying file contents dynamically by substituting placeholders or tags with actual docstrings.

### Parameters

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `content` | `str` | | The content of the file. |
| `tag` | `str` | | The tag to convert. |
| `docstring` | `str` | | The docstring to replace the tag with. |
| `existing_id` | `re.Match` | | The existing ID of the tag. |

### Returns

| Type | Description |
|------|-------------|
| `str` | The content with the tag replaced by the docstring. |

<!--</AutoDoc.Content id="9d66f8">-->

You can excute again the command and the autpress will update the content.

Distribution on pypi

Make sure the version number is updated in the init.py file and in the setup.py file.

The distribution on done with continuous integration using github actions. The secret PYPI_API_TOKEN is set in the repository settings.

Then, to trigger the release, we need to create a tag with the version number. The release will be automatically created and the package will be uploaded to pypi.

For example, to release version 1.0.0, we need to do the following:

git tag v1.0.0
git push origin v1.0.0

You can also create a release with a new tag in the github interface.

Release files for autopress 0.1.0

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

Source distribution (sdist)

Source distribution for autopress 0.1.0
File Size Uploaded
autopress-0.1.0.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autopress 0.1.0
File Interpreter ABI Platform
autopress-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.9 kB

Release files / autopress-0.1.0.tar.gz

Download URL autopress-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
60d440ce582ad514c12ffa77d3c75429332e7c18c33e9e7cc2a90ca2d44459b0
BLAKE2b-256 checksum
How to use checksums
29923606b5f1965ab55bba6fc224755c83994353b8e416637036aadef9ae0736
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / autopress-0.1.0-py3-none-any.whl

Download URL autopress-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
544998f192a7c695bdf089f7bc480f1bf82df64896174cd56c78b8bf4ee9de95
BLAKE2b-256 checksum
How to use checksums
804574cd769bed0649c4e77e4e33cf6fc767c5fb9c7155b34e1992371d0236cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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