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

docai

v2.3.0

Published

Generate documentation from your code with AI

Downloads

344

Readme

DocAi

DocAi is a tool that allows you to automatically generate markdown-formatted documentation for your code.

Installation

npm install --save-dev docai

External LLM Mode

Prerequisites

Your code will be sent to an external provider; ensure that you have the rights to do so.

Usage Examples

Module

To document only some files:

import docai from 'docai'

await docai({
  llm: {
    apiKey: 'YOUR_API_KEY'
    modelProvider: 'mistral' | 'openAI' | 'groq'
    modelName: 'mistral-tiny' | 'gpt-4' | ...
  },
  outputDir: './generated',
  files: ['./test2.ts', './test.js']
})

To document your entire project, provide an entrypoint:

await docai({
  llm: {
    apiKey: 'YOUR_API_KEY'
    modelProvider: 'mistral' | 'openAI' | 'groq'
    modelName: 'mistral-tiny' | 'gpt-4' | ...
  },
  outputDir: './generated',
  entryPoint: './index.js'
})

To document routes from your serverless project:

await docai({
  llm: {
    apiKey: 'YOUR_API_KEY'
    modelProvider: 'mistral' | 'openAI'| 'groq'
    modelName: 'mistral-tiny' | 'gpt-4' | ...
  },
  outputDir: './generated',
  serverlessEntryPoint: './serverless.yml'
})

Optional Options

  • baseDir: Defaults to the current directory. Otherwise, provide the directory path.
  • llm:
    • temperature: Temperature setting for the used model (0 by default).
  • deleteTmpFolder: Flag to decide whether or not to delete the temporary folder.
  • tmpFolderPath: Path for the temporary folder.
  • template: Prompt template send to the LLM to document the code, default value can be found here

CLI

Minimal Configuration: Run these commands at the root of your project:

API_KEY="YOUR_API_KEY" docai --output ./documentation --entrypoint ./src/index.js --modelProvider openAI --modelName gpt-3.5-turbo

or with Mistral

API_KEY="YOUR_API_KEY" docai --output ./documentation --entrypoint ./src/index.js --modelProvider mistral --modelName mistral-tiny

or with Groq

API_KEY="YOUR_API_KEY" docai --output ./documentation --entrypoint ./src/index.js --modelProvider groq --modelName mixtral-8x7b-32768

For a serverless project:

API_KEY="YOUR_API_KEY" docai --output ./documentation --modelProvider openAI --modelName gpt-3.5-turbo --serverless ./serverless.yml

Parameters:

  • entrypoint: Entry point of your application. (Required)
  • serverless: Path to the serverless.yml file for parsing routes in serverless projects. (Required)
  • output: Destination folder path. (Required)
  • modelName: Name of the LLM model to use. (Required)
  • modelProvider: Name of the LLM Provider to use - openAI, mistral, groq. (Required)
  • baseDir: Defaults to the current directory. Otherwise, provide the directory path. (Optional)
  • temperature: Temperature setting for the used model (0 by default). (Optional)
  • noDeleteTmp: Flag to decide whether or not to delete the temporary folder. (Optional)
  • tmpFolderPath: Path for the temporary folder. (Optional)
  • template: Prompt template send to the LLM to document the code, default value can be found here. (Optional)

Environment Variables:

Only the API_KEY environment variable is required.

Local Mode

You can run DocAi in local, with Ollama.

Please follow instructions from the Ollama documentation to install and run a model.

Usage :

Open a terminal tab, and run a model with Ollama.

Ex: ollama run llama2

Then run DocAI with CLI or Module

CLI

docai --output ./documentation --entrypoint ./src/index.js --modelName llama2 --local --baseUrl http://localhost:11434

Parameters:

  • entrypoint: Entry point of your application. (Required)
  • serverless: Path to the serverless.yml file for parsing routes in serverless projects. (Required)
  • output: Destination folder path. (Required)
  • local: Flag to local mode. (Required)
  • modelName: Name of the LLM model to use. (Required)
  • baseDir: Defaults to the current directory. Otherwise, provide the directory path. (Optional)
  • baseUrl: Ollama REST API endpoint, default to http://localhost:11434 (Optional)

Module

import docai from 'docai'

 await docai({
   local: {
     modelName: 'llama2'
     baseUrl: 'http://localhost:11434' // default value, optional field
   },
   outputDir: './generated',
   files: ['./test2.ts', './test.js']
 })

Note: If you work in local mode, you can not pass llm object parameter.

Examples

You can examine the code found in _mock/test/raw/src and compare it to the documented version in _mock/test/generated/src.

Upcoming Features:

  • Multiple entry points.
  • Multilingual capabilities.
  • Frontend application documentation.
  • ...

Feedback and Contribution:

We value your feedback and contributions! If you encounter any issues or have suggestions for improvements, please feel free to submit an issue on our GitHub repository.