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

@adasuite/documenter

v1.0.6

Published

Documenter is a program that uses the OpenAI API to generate documentation for all the files in your project. With Documenter, you can easily keep track of your project's documentation and have it all in one place.

Downloads

12

Readme

Documenter.js

@adasuite/documenter is a JavaScript package that allows you to generate and save documentation for a project directory. It provides several methods for configuring the documentation process and saving the generated documentation to various locations.

Link to Documentation and Showcase

Installation

To install @adasuite/documenter, you can use npm or yarn:


npm install @adasuite/documenter
yarn add @adasuite/documenter

To integrate with Notion:

Usage

To use @adasuite/documenter, you will need to require it in your code:

const Documentation = require("@adasuite/documenter");

To integrate it with Notion:

  1. Go to https://www.notion.so/my-integrations alt text

  2. Click "New Integration" alt text Name the integration, and, optionally, upload ban image. Then select an Associated workspace for the integration to work under.

  3. Change the capabilities of the integration to: alt text

  4. Save the API key, and pass it to Documentation.configure({keys:{notion:"key"}}) alt text

  5. Navigate to the page in which you want your documentation to be stored: alt text

  6. Copy the page_id and pass it to Documentation.configure({filters:{notion:{page_id:"page_id"}}}) alt text

Documentation.configure()

You can then use the Documentation.configure() method to set various options for the documentation process. The available options are:

keys an object containing API keys for OpenAI and Notion. root_folder_path: the root directory for the documentation process.

filter object

filter: an object containing conditions for ignoring certain files or folders and specifying options for summarization and error reporting for OpenAI and Notion.

filter.ignore: [(file_or_folder)=>{},...] the ignore property is an array of functions that takes in a name of a folder or file and then returns a conditionals regarding the names. These functions allow you to filter out certain files or folder.

filter.openai: the openai property can contain openai.summarize = true|false, which if true will summarize each file. openai.listErrors = true|false, which if true will list all the possible errors in each file. openai.customPrompt = (text) => ${text} is a function that takes in the contents of a file in the form of a string, and then returns a prompt including the string.

filter.notion: the notion property can contain notion.page_id = string, which if defined will save the documentation to the page with that page_id.

Documentation.generateDirectoryTree()

Once you have configured the documentation process, you can generate the documentation using the Documentation.generateDirectoryTree() method. This method generates a tree structure representing the directory of the project.

Documentation.getQuote()

You can retrieve a quote for the documentation process in dollars using the Documentation.getQuote() method. You can use this method to prevent the document process if it goes over a set budget.

Documentation.document() method.

This method returns a promise that resolves with the generated documentation.

Documentation.saveDirectoryTree() and Documentation.saveToNotion()

Finally, you can save the generated documentation using the Documentation.saveDirectoryTree() method and Documentation.saveToNotion() method, which saves the documentation to a specified page in Notion.

Example

Here is an example of how you might use @adasuite/documenter in your code:

In root_folder/documenter.js:

const Documentation = require("@adasuite/documenter");

Documentation.configure({
  keys: {
    openai: "<key>",
    notion: "<key>",
  },
  root_folder_path: "./",
  filter: {
    ignore: [
      (file_or_folder) => {
        return (
          file_or_folder === "node_modules" ||
          file_or_folder === ".next" ||
          file_or_folder === "styles" ||
          file_or_folder === ".gitignore" ||
          file_or_folder === "next.config.js" ||
          file_or_folder === "package-lock.json" ||
          file_or_folder === "package.json" ||
          file_or_folder === ".babelrc" ||
          file_or_folder === ".eslintrc.json" ||
          file_or_folder === ".git" ||
          (file_or_folder.indexOf(".") !== -1 &&
            file_or_folder.indexOf(".js") === -1) ||
          file_or_folder.indexOf(".json") !== -1
        );
      },
    ],
    openai: {
      summarize: true,
      listErrors: true,
    },
    notion: {
      page_id: "<page_id>",
    },
  },
});

Documentation.generateDirectoryTree().then((tree) => {
  let quote = Documentation.getQuote(); //In Dollars;
  Documentation.saveDirectoryTree();
  if (quote < /*$*/ 0.5)
    Documentation.document().then((tree) => {
      Documentation.saveDirectoryTree();
      Documentation.saveToNotion(tree);
    });
});

This code configures the documentation process with the specified options, generates the documentation, and saves it to the specified page in Notion if the quote is less than $0.5.

Note

It is important to note that the @adasuite/documenter package requires API keys for OpenAI and Notion to be used. These keys are not provided with the package and must be obtained separately. Please refer to the documentation for OpenAI and Notion for more information on how to obtain these keys.