compogen

command module
v0.0.0-...-40d8cf1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 2 Imported by: 0

README

compogen

compogen is a generation tool for Instill AI component schemas. It uses the information in a component schema to automatically generate the component documentation.

Installation

go install github.com/instill-ai/component/tools/compogen@latest

Generate the documentation of a component

compogen can generate the README of a component by reading its schemas. The format of the documentation is MDX, so the generated files can directly be used in the Instill AI website.

compogen readme path/to/component/config path/to/component/README.mdx
Validation & guidelines

In order to successfully build the README of a component, the definition.json and tasks.json files must be present in the component configuration directory.

The definition.json file must contain an array with one object in which the following fields must be present and comply with the following guidelines:

  • id.
  • title.
  • description - It should contain a single sentence describing the component. The template will use it next to the component title ({{ .Title }}{{ .Description }}.) so it must be written in imperative tense.
  • releaseStage - Must be the string representation of one of the nonzero values of ComponentDefinition.ReleaseStage, defined in protobufs.
  • type - Component definitions must contain this field and its value must match one of the (string) values, defined in protobufs.
  • availableTasks - This array must have at least one value, which should be one of the root-level keys in the tasks.json file.
  • sourceUrl - Must be a valid URL. It must not end with a slash, as the definitions path will be appended.

Certain optional fields modify the document behaviour:

  • public, when true, will set the draft property to false.
  • The content of prerequisites will be displayed in an info block next to the resource configuration details.
  • A table will be built for the setup properties described in setup.json. They must contain an instillUIOrder field so the row order is deterministic.
Injecting extra content

Some components might require or benefit from having extra sections in their documentation. For instance, one might want to dedicate a section to add a guide to configuring an account in a 3rd party vendor or to explain in details a particular configuration of a component.

The extraContents flag in the readme subcommand lets compogen inject the content of a document into the generated file. The content will be added verbatim, so it should complain with the MDX syntax.

This flag takes a key and a value, where the key specifies under which section (at the bottom) the content will be added. The value is the path to the content. The following section IDs are accepted:

  • intro
  • release
  • config
  • setup
  • Any task ID defined in tasks.json (e.g. TASK_CHUNK_TEXT)
  • bottom

More than one section can be extended with this flag:

compogen readme path/to/component/config path/to/component/README.mdx \
  --extraContents setup=path/to/component/.compogen/detailed-setup.mdx
  --extraContents TASK_DO_SOMETHING=path/to/component/.compogen/detailed-task.mdx

TODO

Next steps

  • compogen validate might be used validate any component configuration.
  • compogen new might be used to generate the skeleton of a component.
  • In the future we might want to generate documentation in different languages. This will require some thought.

Documentation

Overview

compogen is a generation tool for Instill AI component schemas. It is a command line application that should guide users through the usage, documentation and maintenance of Instill AI components.

Directories

Path Synopsis
pkg
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL