11

GitHub - matiasvlevi/gptdoc: Generate JSDOC comments with OpenAI models.

 1 year ago
source link: https://github.com/matiasvlevi/gptdoc
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

gptdoc.png

Generate JSDOC comments with OpenAI models

Keep a Human in the loop, results might not be accurate

Preview

Functions labeled with /** @gpt */ get an autogenerated doc comment

Before After
/** @gpt */
function Greet(name) {
    console.log(`Hello ${name}`);
}
/**
 * @autogenerated
 * @summary Generates a greeting to the passed in name
 * @param {string} name - The name to greet
 */
function Greet(name) {
    console.log(`Hello ${name}`);
}

Install in project

Install gptdoc as a dev dependency

npm i --save-dev gptdoc 

Execute

node node_modules/gptdoc [args]

Config

You can specify a configuration file:

node node_modules/gptdoc -c .myconfig

If none provided, the script will look for .gptdoc

Sample Config file

{
    "DEBUG": false,
    "framework": "JSDOC",
    "language": "JS",
    "files": {
        "src": "./src",
        "dest": "./gpt"
    },
    "openai": {
        "temperature": 0.7,
        "top_p": 1,
        "max_tokens": 256,
        "model": "text-davinci-003"
    }
}

Find more info about the config here

API Key

Add a .env file in your root directory

OPENAI_API_KEY="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

or set the OPENAI_API_KEY as a system environement variable.

find your API key here

Document this project!

Running docself in the cloned repo will document source files in ./src/

npm run docself

Running test in the cloned repo will document ./example/example.js

npm run test



License MIT


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK