Skip to main content

No project description provided

Project description

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.

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

autopress-0.1.0.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

autopress-0.1.0-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page