OpenFn / OpenFn/lightning

Add endpoint for generating adaptor docs

Open
#492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

The adaptor-docs panel in the Edit Job (sitting next to the code editor) currently generates documentation in the client, with no caching. This can take several seconds to load (I think best case is about 6, worst case is about 30).

The 0.0.20 version of @openfn/cli has to ability to generate and cache documentation server-side, making it relatively easy to shift the logic up to the server and greatly speeding up the docgen process.

Endpoint requirements

The adaptor-docs component needs to call up to the /docs/:adaptor/:version endpoint on Lightning.

The server should return the JSON output of the CLI's docgen command.

CLI Commands

The CLI provides a docgen command which will generate JSON documentation for an adaptor. It saves it to disk in the CLI's repo.

If a JSON file exists for a given adaptor and version, it will not be generated. Concurrency should be safe: if a separate process requests docs for an adaptor while docgen is in process, the second request will wait for the first to complete (this is rough but tit works!!).

The CLI will return as the final line of output the path to the JSON. So all Lightning has to is call the CLI, tail the path, read it in and return it.

This command should do it:

openfn docgen adaptor@version | tail -n 1

Repo Dir

By default, the CLI will generate docs to the repo at something like /tmp/openfn/repo. You can override this path by setting the OPENFN_REPO_DIR env var to a more sensible value.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Lightning's routes and the adaptor-docs client call, then review the @openfn/cli 0.0.20 docgen command and its JSON output. Check the /docs/:adaptor/:version requirements and OPENFN_REPO_DIR behavior. Done means the endpoint returns the CLI-generated documentation and handles concurrent requests through the CLI's caching behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.