context7-submit
context7-submit is a D library and the ctx7-submit program. Both post a documentation URL to Context7’s Add Library API. The DevCentr window’s use of the library is Context7 documentation submit.
The package source is dev-centr/context7-submitunchecked. It is prepared for the DUB registry and is not registered there yet.
Program
ctx7-submit <url> [options]
The API key is CONTEXT7_API_KEY. A private Git token is CONTEXT7_GIT_TOKEN. Neither value is a command argument.
Options
| Option | Effect |
|---|---|
|
|
|
Mark a Git repository as private. |
|
Skip version-specific documentation pages. |
|
Generate docs from a private repository. |
|
For a website, index only pages under this URL. This is the HTML documentation root. |
|
Context7 deployment. The default is |
|
Print one JSON result on stdout. The result includes |
|
Print the run log on stderr. |
|
Suppress the human summary. |
|
Print usage and exit 0. |
|
Print |
How a URL is classified
The program checks the URL in this order and stops at the first match:
| URL | Kind |
|---|---|
Path ends in |
|
Path contains |
|
Host is |
That forge |
Scheme is |
|
Anything else with a scheme |
|
A documentation site with several path segments is a website. --website-base-url is rejected for every kind except website. A forge that is not GitHub, GitLab, or Bitbucket is a website unless the path ends in .git, in which case the kind is git.
Exit codes
| Code | Meaning |
|---|---|
0 |
Submitted, or the source was already indexed. |
1 |
The request failed. |
2 |
Usage error. A missing URL, an unknown option, or a URL without a scheme. |
3 |
Authentication required. |
4 |
Rate limited. |
On success without --json, stdout is the library id and nothing else. Diagnostics, including the log path, go to stderr.
Environment
| Variable | Purpose | Required | If unset |
|---|---|---|---|
|
Authenticates the submission. Create the key at context7.com/dashboardunchecked. |
Yes |
The program exits 3 and does not send the request. |
|
Git token for a private repository. It is placed in the request body and is not written to the log. |
No |
The submission is sent without a token. |
|
Set to |
No |
The terminal shows the outcome only, unless |
|
When |
No |
Verbose output stays off unless requested. |
Logs are one file per run, pruned to the newest 20, under %LOCALAPPDATA%\ctx7-submit\logs\ on Windows, ~/Library/Logs/ctx7-submit/ on macOS, and $XDG_STATE_HOME/ctx7-submit/logs/ elsewhere (~/.local/state when XDG_STATE_HOME is unset). A sibling .jsonl file holds the same events.
Library
Depend on the library configuration:
dependency "context7-submit" path="../context7-submit"
subConfiguration "context7-submit" "library"
import context7.submit;
SubmitOptions options;
options.websiteBaseUrl = "https://dlang.org/spec/";
auto result = submitSource(SubmitRequest(
"https://dlang.org/spec/spec.html",
"website",
options,
apiKey
));
SubmitRequest is the URL, an optional kind, SubmitOptions, the API key, and an optional baseUrl (default https://context7.comunchecked). SubmitOptions carries the private flag, the git token, skip-version-filtering, generate-docs, and websiteBaseUrl. Boolean fields are omitted from the JSON body unless the matching has* flag is set.
SubmitResult.ok is true for a new submission and for a source that is already indexed (alreadyExists, HTTP 409). libraryName is the Context7 id, such as /acme/docs. errorCode is validation_error, unauthorized, rate_limit_exceeded, network_error, invalid_response, or http_error.
Pass an HttpPost delegate as the second argument to submitSource to test without calling Context7. The delegate receives the endpoint URL, the JSON body, and the API key, and returns the response body plus the HTTP status.