-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate API Documentation #237
base: main
Are you sure you want to change the base?
Conversation
- next at /api/xstate/next - latest 5.1.0 at /api/xstate - archived 5.0.0 at /api/xstate/5.0.0
the breadcrumbs generated in Markdown by api-documenter are more precise
without this, api extractor will find package.json a level up and use the name/canonicalReference "stately-docs" instead of "xstate"
@audionerd is attempting to deploy a commit to the Stately Team on Vercel. A member of the Team first needs to authorize it. |
Re: the sidebar, I have an unfinished API Documenter plugin based on this example which outputs If that can be finished up and added then the docs will be pretty usable. Takes advantage of API Documenter's |
Note that the Docusaurus build will fail unless you make this tweak first: statelyai/xstate#4374 |
API Documenter offers a new plugin system which we can use to customize its output for better display in Docusaurus, both for its generated Markdown and to generate a sidebar. Using this Rush Stack example as a guide, I set up a basic plugin specific to XState and Docusaurus which is run by Demo here: https://audionerd.github.io/statelyai-docs/api/xstate With this change, the API Doc output and sidebar are usable, and the generated URLs should be stable enough to rely on moving forward. |
Will probably use JSDoc and TypeDoc instead of TSDoc and API Documenter. API Documenter requires TSDoc, but Visual Studio Code IntelliSense does not really understand TSDoc, leading to confusing rendering in the editor. API Documenter is missing a few important conversions from TSDoc to Markdown (e.g.: no support for Markdown lists or PR for TypeDoc plugin setup is here: #288 |
Summary
Provide API documentation for https://stately.ai generated from analysis of the source code and inline comments of XState packages.
For users:
For maintainers:
For this PR, our scope is to publish API docs for only the
xstate
package (packages/core
) from thenext
branch of thexstate
repo.Demo: https://audionerd.github.io/statelyai-docs/api/xstate/xstate
Scope Exclusions
No other packages
Other XState packages, such as
@xstate/react
, are not included (yet). Their existing handwritten Markdown indocs/
will remain.No other versions
In future, Docusaurus Multi-Instances could be set up to version the API docs, e.g. for
@xstate/react
:No v4 API
XState v4 API docs will not be generated (yet).
No CI or GitHub Actions integration (yet)
Updating API docs will be a manual process (for the first iteration).
Implementation
The
xstate
package has been added as a submodule indocs
.To generate API docs, before
yarn start
oryarn build
, run:This command generates XState API Documentation as Markdown files to the
api/xstate
directory.The script uses API Extractor to generate the API documentation by analyzing the TypeScript files and inline comments of a package. It first creates a
*.api.json
doc model file, which is then used by API Documenter to generate Markdown files. We use the Docusaurus Multi-Instance feature to configure theapi/xstate
directory of Markdown files as its own docs instance, and the same approach can be used to support versioned docs for all XState packages in the future.The generated Markdown files will be checked into the
docs
repo so that updates to non-API docs can happen quickly, without running theupdate-api-docs
script again.Risks
API Extractor assumes inline comments are in TSDoc format, which differs somewhat from the JSDoc currently used by XState. If switching to TSDoc is problematic, TypeDoc and this TypeDoc Docusaurus plugin could be considered instead of API Extractor.
Reference
Tasks
Future work
@xstate/react
) and provide a list of all packages at/api/index.md