Reference and usage guide for the runtime-scoped docs module that exposes help pages, jsdoc entries, and plugin metadata.
The docs module gives JavaScript code a uniform way to inspect runtime documentation sources. It is available through require("docs") in runtimes that wire the documentation registrar, which now includes goja-repl tui.
This guide explains what the module exposes, what kinds of entries it returns, and how to use it in practice.
The module is a view over one or more documentation providers:
Each result tells you which source it came from. The module does not flatten everything into one opaque blob.
const docs = require("docs")
docs.sources()
Typical result:
[
{
id: "default-help",
kind: "glazed-help",
title: "Default Help",
summary: "Embedded REPL help pages",
runtimeScoped: false,
metadata: null,
},
{
id: "plugin-manifests",
kind: "plugin",
title: "Plugin Manifests",
summary: "Runtime-scoped plugin metadata",
runtimeScoped: true,
metadata: null,
},
]
docs.sources()Return every registered documentation source descriptor.
Use this first when you want to know what data is available in the current runtime.
docs.search(query)Search across one or more sources.
Accepted query fields:
textsourceIdskindstopicstagslimitExample:
docs.search({
text: "plugin",
kinds: ["plugin-module", "plugin-method"],
limit: 10,
})
docs.get(ref)Fetch one entry by explicit reference object:
docs.get({
sourceId: "default-help",
kind: "help-section",
id: "repl-usage",
})
This returns null when the entry does not exist.
docs.byID(sourceId, kind, id)Convenience form of docs.get(...) when you already know the reference components.
Example:
docs.byID("plugin-manifests", "plugin-module", "plugin:examples:kv")
docs.bySlug(sourceId, slug)Convenience helper for Glazed help pages:
docs.bySlug("default-help", "repl-usage")
docs.bySymbol(sourceId, symbol)Convenience helper for jsdoc symbol entries:
docs.bySymbol("workspace-jsdoc", "smoothstep")
Every returned entry uses the same top-level structure:
{
ref: { sourceId, kind, id },
title,
summary,
body,
topics,
tags,
path,
kindLabel,
related,
metadata,
}
The shared shape is stable, but metadata is source-specific.
const docs = require("docs")
const replUsage = docs.bySlug("default-help", "repl-usage")
replUsage.title
replUsage.summary
replUsage.body
replUsage.metadata.commands
replUsage.metadata.flags
Plugin entries are especially useful because they let you inspect manifests without reverse-engineering the JS callable surface.
docs.byID("plugin-manifests", "plugin-module", "plugin:examples:kv")
docs.byID("plugin-manifests", "plugin-export", "plugin:examples:kv/store")
docs.byID("plugin-manifests", "plugin-method", "plugin:examples:kv/store.get")
This is where rich method summaries, bodies, and tags now show up.
docs.search({
sourceIds: ["plugin-manifests"],
})
docs.search({
sourceIds: ["default-help"],
text: "repl",
})
docs.search({
sourceIds: ["plugin-manifests"],
kinds: ["plugin-method"],
text: "store",
})
| Problem | Cause | Solution |
|---|---|---|
require("docs") fails | The runtime was created without the documentation registrar | Use goja-repl tui, or attach the GOJA-11 registrar in your own runtime builder |
plugin-manifests source is missing | No plugins were loaded in that runtime | Pass --plugin-dir or install plugins under ~/.go-go-goja/plugins/... |
docs.bySymbol(...) returns null | No jsdoc store was attached under that source ID | Attach a jsdoc provider when constructing your runtime or query docs.sources() first |
| A plugin method has no body | The plugin did not publish method docs | Add sdk.MethodDoc(...) in the plugin SDK declaration |
repl-usagegoja-plugin-user-guidegoja-plugin-developer-guide