Skip to content

Commit bc443b1

Browse files
authored
Add package setup (#67)
* implement setup * fix document path * use setup in action * use action path to run setup * add missing dependency * update README * update version * use pyproject toml instead of a setup script * add entrypoint * add workflow * test publish workflow * publish on releases * update metadata * delete obsolete files
1 parent 8839046 commit bc443b1

File tree

8 files changed

+1532
-23
lines changed

8 files changed

+1532
-23
lines changed

.github/workflows/publish.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch: # Allow running on-demand
5+
push:
6+
tags:
7+
- "*"
8+
9+
env:
10+
PYTHON_VERSION: 3.11.4
11+
12+
jobs:
13+
build-and-publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Code checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Setup python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ env.PYTHON_VERSION }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip poetry
27+
poetry install
28+
29+
- name: Set Poetry config
30+
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
31+
32+
- name: Publish package
33+
run: poetry publish --build

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Mystral AI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,10 @@ https://github.com/mystral-ai/devtale/assets/11546115/e3cb1354-d9ef-406f-90d7-e9
1010

1111
## Installation
1212

13-
Create and enter to a conda env:
13+
Use the following command:
1414

1515
```bash
16-
conda create -n devtale python=3.11 -y
17-
conda activate devtale
18-
```
19-
20-
Install requirements
21-
22-
```bash
23-
pip install -r requirements.txt
16+
pip install devtale
2417
```
2518

2619
## Usage
@@ -34,7 +27,7 @@ pip install -r requirements.txt
3427
- Run the following command to document a file or document all the files in a folder:
3528

3629
```bash
37-
python cli.py -p [path/to/your/code] -o [path/to/docs]
30+
devtale -p [path/to/your/code] -o [path/to/docs]
3831
```
3932

4033
To document an entire repository/directory include the `-r` (recursive) flag. The program generates a JSON file per code file with the documentation data; If you want to also add the documentation inside a copy of the code file, then please include the `-f` (fuse) flag. In case you already have the JSON docstrings, you can also fuse them separately using the corresponding [script](scripts/)
@@ -54,7 +47,7 @@ jobs:
5447
permissions: write-all
5548
steps:
5649
- name: Document
57-
uses: mystral-ai/[email protected].1
50+
uses: mystral-ai/[email protected].2
5851
with:
5952
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
6053
path: ${{ github.workspace }}
@@ -67,7 +60,7 @@ The `recursive` option allows you to document the entire repository. Alternative
6760

6861
## Cost
6962

70-
You can estimate project documentation costs using the `--estimate` flag with the `devtale` command, which won't make any GPT calls. Please note that this estimate is approximate, as it doesn't include GPT output tokens nor code items JSON tokens generated by the GPT call in the `devtale/utils.py/extract_code_elements` function.
63+
You can estimate project documentation costs using the `--estimate` flag when using the `devtale` command in terminal, which won't make any GPT calls. Please note that this estimate is approximate, as it doesn't include GPT output tokens nor code items JSON tokens generated by the GPT call in the `devtale/utils.py/extract_code_elements` function.
7164

7265
If you skip the estimate and simply run 'devtale,' the final log will display the total cost. This total cost considers GPT output tokens and the tokens added by the code items JSON.
7366

@@ -76,13 +69,13 @@ For example:
7669
Running the following command:
7770

7871
```bash
79-
python cli.py -r -f -p devtale/devtale --estimate
72+
devtale -r -f -p devtale/devtale --estimate
8073
```
8174

8275
will provide you with a cost estimate of $2.44733 USD. It won't document anything since it doesn't trigger any GPT calls. On the other hand, running:
8376

8477
```bash
85-
python cli.py -r -f -p devtale/devtale
78+
devtale -r -f -p devtale/devtale
8679
```
8780

8881
will give you the total cost of $2.95762 USD. This command triggers GPT calls and, consequently, documents the directory.

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ runs:
3434
- name: Install dependencies
3535
run: |
3636
python -m pip install --upgrade pip
37-
pip install -r ${{ github.action_path }}/requirements.txt
37+
pip install devtale
3838
shell: bash
3939

4040
- name: Document
4141
run: |
4242
if ${{ inputs.recursive }}; then
4343
echo "Documenting repository"
44-
python ${{ github.action_path }}/cli.py -r -p ${{ inputs.path }} -o ${{ inputs.path }} -f
44+
devtale -r -p ${{ inputs.path }} -o ${{ inputs.path }} -f
4545
else
4646
echo "Documenting folder/path"
47-
python ${{ github.action_path }}/cli.py -p ${{ inputs.path }} -o ${{ inputs.path }} -f
47+
devtale -p ${{ inputs.path }} -o ${{ inputs.path }} -f
4848
fi
4949
env:
5050
OPENAI_API_KEY: ${{ inputs.openai_api_key }}

cli.py renamed to devtale/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66

77
import click
8-
from dotenv import load_dotenv
8+
from dotenv import find_dotenv, load_dotenv
99

1010
from devtale.constants import (
1111
ALLOWED_EXTENSIONS,
@@ -546,7 +546,7 @@ def main(
546546
debug: bool = False,
547547
cost_estimation: bool = False,
548548
):
549-
load_dotenv()
549+
load_dotenv(find_dotenv(usecwd=True))
550550

551551
if not os.environ.get("OPENAI_API_KEY"):
552552
os.environ["OPENAI_API_KEY"] = getpass.getpass(

0 commit comments

Comments
 (0)