0.6.0 • Published 5 months ago

gptdocwriter v0.6.0

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

Documentation Generation Tool with GPT 4 Turbo!

d-status d-downloads

This uses the beta thread and assistant features of the official openai node API. See Reference

For global usage:

npm i -g gptdocwriter

Set API Key (saved to the library folder (keep private!!) in config.txt):

gptdocwriter --apiKey sk-abcdefg

Then, from your desired folder:

gptdocwriter --initialFiles [index.js,utils.js] --extensions [.js,.jsx] --excluded [dist,node_modules] --model gpt-4-1106-preview

entryPoint defaults to current working directory

Features

  • Set an API key for authenticating with the OpenAI API.
  • Generate documentation based on specified entry points, file types, and other criteria.
  • Exclude certain files or directories from being documented.
  • Define custom models, output formats, and additional instructions for the AI to follow.

Usage

The various command line arguments include. Combine as needed. Call --apiKey first. Fundamentally this tool just creates a thread to read files and output a file for each file read, with context building with each file. At the end we write a README.md which should account for the knowledge of your files that GPT accumulated over the process.

# Set the API key for OpenAI services
gptdocwriter --apiKey sk-abcdefg

# Alternatively 
gptdocwriter apiKey=sk-abcdefg
#defaults to current working directory
gptdocwriter --entryPoint path/to/src

# Generate documentation for specific files before crawling extensions in the order they appear
gptdocwriter --initialFiles [utils.js,gptdocument.js]

# Exclude files or directories from being documented
gptdocwriter --excluded [server.js,node_modules,dist]

# Specify which file extensions to include in the documentation
gptdocwriter --extensions [js,ts,tsx,jsx]

# Choose the GPT-4 model variant to use. We are rate limiting for the latest preview for you.
gptdocwriter --model gpt-4-turbo-1106

# Clear current assistant before/after generating documentation (will be cleared if instructions are updated)
gptdocwriter --cleanup

# Restart the thread at the last file read. Do this after a crash if you want to recover your position in the last thread, else it will be deleted on next call
gptdocwriter --continue

# Tailor the prompt for the AI instead of the default prompt
gptdocwriter --instructions Write detailed documentation about each file

# Include additional specific instructions
gptdocwriter --extraInstructions Mention the CLI input arguments

# Specify the project name within the readme
gptdocwriter --name gptdocwriter

# Change the output format to another extension than .md, e.g. we could transpose files from one programming language to another 
gptdocwriter --outputFormat .py

# Adjust the readme content template
gptdocwriter --readme Summarize this in a digestible format for folks who got a D in English

# Rate Limit requests (default 12.5sec for GPT 4 preview, change as necessary, we'll adapt too as rate limits are uncapped)
gptdocwriter --rateLimit 20

# Don't clear the thread at the end (default false else it would keep context on the next folder)
gptdocwriter --keepThread

cap

Or set in utils.js and execute this locally via node gptdocument.js xxx

Or module usage:

import {generateDocumentation} from 'gptdocwriter'

// CLI usage to call generateDocumentation
generateDocumentation(
    process.cwd(), 
    ['utils.js'],  //scan the rest of the files after this specified order is completed
    ['.js', '.ts', '.mjs', '.jsx', '.tsx'], 
    ['dist','node_modules']
);

The prompt for all of this is experimental so tweak it as you need. Results can vary wildly though we tried to make it consistent enough to be passable, but you will need to edit your files afterward (which you should be doing anyway for serious documentation, this only provides an enhanced template).

See a repo where I applied this to a fairly hefty codebase: JS Maze Generator with A* solver

GPT generated docs below, with extra instructions to use strict iambic pentameter:

  • Generated with: node gptdocument.js --excluded server.js,node_modules,dist --initialFiles package.json,utils.js --cleanup --extraInstructions Write EVERYTHING in iambic pentameter verse without exception.

GPT Doc Writer 📜✍️

In lands of code where silence reigns, The GPT Doc Writer deigns, To turn the tide of documentation's chore, Into an art, less bore, more lore.

Quick Start 🚀

To weave the magic of this script's employ, Ensure to set the API deploy. Run commands below, command line's your stage, To document your code, turn a new page.

gptdocwriter --apiKey YOUR_API_KEY
gptdocwriter --entryPoint path/to/src --initialFiles utils.js,gptdocument.js
# ...and any other options you wish to engage

Installation 🛠

In terminal's embrace, these words recite, And lo, the GPT Doc Writer takes flight:

npm install -g gptdocwriter
# or, for the bards who seek yonder ridge:
yarn add gptdocwriter

Usage 📖

Invoke with args that you understand, From where to start, what files to demand. Exclude, include, with precision's touch, And see how well it documents much.

Documentation Directory 🗂

Herein the structure, clear and deft, With markdown files, right and left:

Use Cases 🎯

  • In times of rush, when docs are drear, This tool comes forth to lend an ear.
  • For projects vast as the sea's own realm, GPT Doc Writer takes the helm.
  • And should you wish to transit code, To another language, to lighten the load, With output formats, it strides in stride, From .js to .py, worlds do collide.

In Summation's Grasp 🌟

With snazzy flare and emojis bright, This README lends developers light. Installation, usage at the top reside, Use cases follow, in this README's guide.

With GPT Doc Writer, fear recedes, For it documents as thou proceeds. And for the travelers through code's night, This README will serve as lantern's light.

0.5.10

5 months ago

0.5.11

5 months ago

0.5.18

5 months ago

0.5.19

5 months ago

0.5.16

5 months ago

0.5.17

5 months ago

0.5.14

5 months ago

0.5.15

5 months ago

0.5.12

5 months ago

0.5.13

5 months ago

0.5.40

5 months ago

0.5.6

5 months ago

0.5.5

5 months ago

0.5.32

5 months ago

0.5.33

5 months ago

0.5.30

5 months ago

0.5.31

5 months ago

0.5.8

5 months ago

0.5.7

5 months ago

0.5.9

5 months ago

0.5.38

5 months ago

0.5.39

5 months ago

0.5.36

5 months ago

0.5.34

5 months ago

0.5.35

5 months ago

0.5.21

5 months ago

0.5.22

5 months ago

0.5.20

5 months ago

0.5.29

5 months ago

0.5.27

5 months ago

0.5.28

5 months ago

0.5.25

5 months ago

0.5.26

5 months ago

0.5.23

5 months ago

0.5.24

5 months ago

0.6.0

5 months ago

0.5.4

5 months ago

0.5.3

5 months ago

0.5.2

5 months ago

0.5.1

6 months ago

0.5.0

6 months ago

0.4.1

6 months ago

0.4.0

6 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.3.0

6 months ago

0.2.3

6 months ago

0.2.2

6 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.1.9

6 months ago

0.1.8

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago