npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gptdocwriter

v0.6.0

Published

GPT 4 Turbo-powered API documentation generator

Downloads

22

Readme

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.