Replies: 2 comments
|
Similar to |
0 replies
|
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The Q3 roadmap says that
vp docwill support multiple documentation generators and that each project can select one, following the package-manager approach. Before writing an RFC, I think we should define which problem Vite+ is solving and which semantics should remain stable across generators.This proposal calls each Vite+ integration a documentation adapter. VitePress, TypeDoc, and similar projects remain the underlying tools or generators. An adapter is the Vite+ layer that detects one of those tools, declares its supported actions, and maps the common
vp docactions to its native CLI.I hope this discussion can serve as a starting point for the pre-RFC design conversation and help shape the eventual RFC.
There is no established meaning for a
doccommand:npm docsopens a package's documentation URL.cargo docgenerates API reference HTML.go docanddeno doccan print API information in the terminal.dev,build, andpreviewfor a documentation site.vp dev.Because these tools solve different problems,
vp docshould not silently mean "open a URL", "generate API docs", or "start a site" based on whether Vite+ guesses that the project is a library or an application.Proposed value
vp docshould provide a stable entry point for a project's documentation workflow through a selected adapter.This gives projects:
Vite+ should own adapter selection and orchestration. Each adapter should own tool detection, capability declaration, and command mapping. The underlying tool should continue to own content, API extraction, rendering, themes, and tool-specific options.
This is similar to the package-manager model in one important way: Vite+ resolves the adapter selected by the project, the adapter maps a common operation to the underlying tool, and Vite+ executes it. It should not imply that documentation tools have the same capabilities or interchangeable configuration.
Proposed command model
buildshould be the only required adapter capability.devandpreviewshould be optional capabilities declared by each adapter.vp doc buildshould include the underlying tool's native validation. For example, unresolved links or undocumented public APIs should make the command fail when the tool's configured strictness treats them as errors.The initial contract should not expose a separate
vp doc checkaction.deno doc --lintprovides standalone documentation linting, while TypeDoc validation runs during conversion or rendering and VitePress dead-link detection runs as part of a build. Vite+ should not hide that difference by running an implicit temporary build or inventing its own generic documentation linter.Bare
vp docshould not generate files or start a long-running process. It should report the resolved adapter, its underlying tool, where the selection came from, and the actions that adapter supports. A--jsonform would make the same information usable by agents and tooling.For an unsupported action, Vite+ should fail explicitly instead of emulating it or choosing another adapter:
Tool-specific arguments should be an escape hatch after
--. Teams should prefer the underlying tool's native config file for repeatable settings.Adapter selection
The project should be able to make the selection explicit in
vite.config.ts:I propose this resolution order:
doc.adapterfrom the applicable Vite+ config.vp doc initwould be the explicit mutating operation. It may prompt for an adapter, add the required underlying tool as a development dependency through the project's package manager, and write the adapter selection after confirmation.Normal commands such as
vp doc buildmust not install packages or modify project configuration. The selected adapter should execute the project-local tool, preserve its stdout, stderr, and exit status, and report a clear error when the underlying tool is not installed. The tool version should remain controlled bypackage.jsonand the lockfile, not by Vite+.The Vite+ config should initially store orchestration data such as the selected adapter. Tool-specific settings should remain in files such as
.vitepress/config.tsortypedoc.json.Libraries, applications, and monorepos
Vite+ should not infer a documentation product from the project type.
For the first version, I suggest one primary documentation adapter per applicable Vite+ config. The underlying tool may compose other tools through its native plugins or build process. Named documentation targets could be added later if real projects need multiple independently invoked outputs in the same package.
Monorepo targeting should follow the existing built-in command model:
At a workspace root:
docconfig represents an integrated workspace documentation site.defaultPackage.docmay select a fixed documentation package.vp -C ... doc ...choices in non-interactive environments.vp doc buildshould not implicitly build every package in a workspace. Projects that need that behavior can define a Vite Task or package script and run it recursively withvp run. Vite+ should not invent automatic cross-generator site merging in the first version.Adapter contract
An adapter needs to provide only a small contract:
The contract should be validated with at least one site-generator adapter and one API-generator adapter, for example VitePress and TypeDoc, before it is considered stable. This would expose invalid assumptions that are hidden when designing around only one category of tool.
Non-goals for the first version
npm docs;go doc;checkcommand;dev,build, orpreviewcommands.Questions for the RFC
vp doconly report the selected adapter, underlying tool, and capabilities, or should it alias one action?doc.adapteralways be required?build,dev, andpreviewthe right stable capability names?My recommendation is to keep the first contract narrow: explicit adapter selection, a required
buildaction, capability-based optional actions, native tool configuration, and existing Vite+ workspace targeting. That provides a useful common workflow without pretending that all documentation tools do the same job.Appendix: existing documentation CLI prior art
The following commands informed this proposal. Commands with similar names expose materially different products: opening existing documentation, querying APIs, generating API references, running a documentation site, or publishing generated output.
Commands named
docordocsnpm docspackage.jsonname. It supports multiple packages and workspace selection but does not generate documentation. Its alias isnpm home.rustup doccargo doctarget/doc. It supports--open,--no-deps, private items, and explicit workspace/package/exclusion scopes.go docgo doc -httpserves HTML locally.deno doc--lintto diagnose public types and JSDoc. It accepts multiple entry points andnpm:orjsr:packages.dart docdoc/api.--dry-runreports problems without saving output. Serving the result requires a separate HTTP server.crystal docsindex.json, usingsrc/**/*.crby default or explicit source entry points.nim doc--projectcovers a project, with related LaTeX and JSON commands available separately.gleam docs buildgleam publishpublishes documentation with the package.sbt docCompile / doc.Equivalent workflows under other names
python -m pydoc-w, starts a local server with-p, or starts a server and browser with-b. It documents modules resolved in the active import environment.javadocexportsormain, expand source files, and combine package-mode results.mix docswith ExDoccabal haddockcabal haddocktargets selected packages, whilecabal haddock-projectcombines all local packages under./haddocks.dune build @doc.mlddocuments with packages.dune ocaml docprovides the same workflow through a dedicated command.swift package generate-documentation--target.vitepress dev,build, andpreviewmanage a Markdown documentation site. They do not extract an API reference from source code.vp dev, rather than adding a standalonedoccommand.Cross-cutting observations
doc: it may open existing documentation, print API information, generate static output, run a site, validate content, or publish artifacts.npm docs. Opening a package URL is therefore npm-specific behavior, not a common JavaScript package-manager operation.These differences are why the proposal makes adapter selection explicit and gives each adapter a small, capability-based command contract instead of defining
vp docas a wrapper around one existing tool.All reactions