feat(docs): invoke docs({ plugins }) - #164
Merged
Merged
Conversation
0.4.0 declared the `plugins` option and the `DocsPlugin` type but never called a plugin's `setup`, so a consumer generating a section (an OpenAPI reference, say) had to run it from `integrations` instead. `setup` now runs inside `astro:config:setup`, after the framework has planned its own routes and before the runtime payload is sealed. `addNavGroup` groups land in `sidebar.extra`; `addMdxComponents` entries are module specifiers, served through a new `virtual:eqty-docs/plugin-components` module that the route-level component map spreads in last. A component cannot be passed as an object, because the runtime loads from node_modules and imports what the virtual module names; passing one fails with a message naming the plugin, as does a malformed `plugins` entry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
captjt
requested review from
Shrinks99 and
matthewmr-eqty
and removed request for
matthewmr-eqty
September 24, 2026 20:38
matthewmr-eqty
approved these changes
Sep 24, 2026
matthewmr-eqty
left a comment
Contributor
There was a problem hiding this comment.
Looks great, glad the plugins actually run now. I haven't run my OpenAPI pages against the Guardian specs yet, so looking forward to comparing the two.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@eqtylab/docs0.4.0 declares apluginsoption and exports theDocsPlugin/DocsPluginContexttypes, but nothing ever calls a plugin'ssetup. A consumer that passesplugins: [...]gets a build that silently registers nothing. This wires the hook up.Why
We hit this while moving the Guardian docs (eqtylab/governance-platform-docs) onto the framework. Its API reference is written as a
DocsPlugin, and the only way to run it today is a small adapter that callssetupfrom an ordinary Astro integration. That works, but an option that is accepted and ignored is a trap for the next consumer, and the extension point is the right home for generated sections that the framework does not ship itself (changelogs, CLI references, and so on).This is independent of the native OpenAPI work in #158 → #160, which takes the content-collection route rather than the plugin hook; the two merge cleanly (checked with
git merge-treeagainstfeat/mic-73-openapi-pages). Once that chain lands, Guardian will drop its own plugin in favour of the built-in pages, and this hook remains for everything else.Changes
src/internal/run-plugins.ts(new): validatespluginsentries, runs eachsetupin order insideastro:config:setupwith the raw hook params asctx.astro, and collects contributions. Runs after the framework has planned its own routes and before the runtime payload is sealed.addNavGroupgroups are appended tosidebar.extra, so they reach the runtime through the existing config virtual module.addMdxComponentsnow takes module specifiers (Record<string, string>), served through a newvirtual:eqty-docs/plugin-componentsmodule thatmdx-components.tsspreads in last. A component object cannot cross into the runtime, which loads from node_modules, so passing one fails with a message naming the plugin and the component. This narrows the previouslyunknown-typed map; nothing could have used it before.Verification
tests/plugins.test.ts(ordering, replacement, error paths, virtual-module source);pnpm --filter @eqtylab/docs testpasses all 108 docs tests. Lint, format check andpnpm --filter @eqtylab/docs buildpass.docs({ plugins: [openApiPlugin(...)] })instead of the adapter. The plugin logged as registered through the hook and the build emitted the same 241 pages, including all 143 operation pages with correct sidebar state.🤖 Generated with Claude Code