Package: devtale
devtaleEvery software product depends on some legacy, undocumented code repositories, whose authors left the company years ago.Who isn't afraid to make a change, if the code is unreadable?devtalegenerates repo documentation with LLMs. Currently supporting Python, Go, PHP, JS, TypeScript and React projects.https://github.com/mystral-ai/devtale/assets/11546115/e3cb1354-d9ef-406f-90d7-e92576587549InstallationUse the following command:pipinstalldevtaleUsageTerminalNote: currently, devtale only supports GPT-4 as LLM.Create a.envfile in the root directory and set yourOPENAI_API_KEYthere.Run the following command to document a file or document all the files in a folder:devtale-p[path/to/your/code]-o[path/to/docs]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 correspondingscriptWorkflowNote: You must check the box"Allow GitHub Actions to create and approve pull requests"in your repository's setting -> actions for this to work.In the repository setting -> Secrets and Variables -> Actions -> CreateOPENAI_API_KEYrepository secretAdd the following step in your workflow. Ensure to specify the write permission to avoid 403 errors when attempting to push the devtale PR.jobs:code-documentation:runs-on:ubuntu-latestpermissions:write-allsteps:-name:Documentuses:mystral-ai/devtale@v0.1.2with:OPENAI_API_KEY:${{ secrets.OPENAI_API_KEY}}path:${{ github.workspace}}recursive:truetarget_branch:mainsave_tales:falseTherecursiveoption allows you to document the entire repository. Alternatively, you can specify a specific path to document a single file or folder and setrecursivetofalse. The workflow action will automatically create thedevtale/documentationbranch and push a new pull request for your review towards thetarget_branch, including the added documentation.CostYou can estimate project documentation costs using the--estimateflag when using thedevtalecommand 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 thedevtale/utils.py/extract_code_elementsfunction.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.For example:Running the following command:devtale-r-f-pdevtale/devtale--estimatewill 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:devtale-r-f-pdevtale/devtalewill give you the total cost of $2.95762 USD. This command triggers GPT calls and, consequently, documents the directory.Dependency on GPT-4We found thatGPT-3.5can't extract code components and generate docstring in a reliable manner, whileGPT-4can do so. Hence, devtale currently only works withGPT-4. Beware that the cost associated with running devtale on a large code repository may be prohibitive. To reduce this cost, devtale usesgpt-3.5-turbo-0613for generating top-level file summaries and README files andgpt-4-1106-previewfor the rest.PipelineIn a high-level overview, devtale works in the following way: