diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0eefd2f..d00d482 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,12 @@ A plugin's policy bundles are the ones its `policies` list in `instances.yaml` n Release docs (notes, API reference, configuration reference, feature and upgrade guides, catalog rows and version cuts) are mostly written by the factory when a release ships. You can still open a pull request for any of them. +## Writing tutorials + +Tutorials are hands-on walks through a task, in `docs/tutorials/`. They are general pages like the introduction and the glossary: not versioned, served under the **Tutorials** tab. The sidebar is `tutorialsSidebar` in `sidebars.js`: add your page's id there, or it builds but stays out of the navigation. + +Write a tutorial to the [tutorials page](STYLE.md#tutorials-page) skeleton in STYLE.md. Use the MDX components the tutorials are built from rather than raw HTML: they are showcased, rendering live with a usage snippet for each, in [docs/tutorials/components.mdx](docs/tutorials/components.mdx), and registered on every page's MDX scope, so no tutorial imports them. + ## Pull requests 1. Branch from `main` and keep each pull request to one change: one release, one fix or one new page. diff --git a/STYLE.md b/STYLE.md index dde5299..b726ce7 100644 --- a/STYLE.md +++ b/STYLE.md @@ -80,6 +80,25 @@ Mark a setting added in this line with *(new in 0.21)* in its Purpose cell, and ## Related ``` +### Tutorials page + +One hands-on walk through a task, in `docs/tutorials/` (the **Tutorials** tab). It starts from a clean state and ends with a result the reader can inspect in the UI. Use the tutorial components (showcased in `docs/tutorials/components.mdx`) instead of raw HTML: `Steps` for the stages, `CopyBlock` for commands and files, `CodeGroup` when a step has more than one file, `Tabs` for variants of one step, the callouts for caveats and `Accordion` for details only some readers need. + +```md +# + + + +## Before you start + +## + +## Check your work + +## Next steps + +``` + ### Upgrade guide For minor and major releases. One page per target line, for example "Upgrade to 0.21". diff --git a/docs/tutorials/components.mdx b/docs/tutorials/components.mdx new file mode 100644 index 0000000..8947e7d --- /dev/null +++ b/docs/tutorials/components.mdx @@ -0,0 +1,342 @@ +--- +sidebar_label: Components +description: Every code block and MDX component a tutorial page can use, rendering live, each with the snippet that produced it. +--- + +# Tutorial components + +This page is for docs authors. Every block a tutorial can use is here, rendering live so you can click through it, each with the snippet that produced it. Copy a snippet into your page and change the words. Nothing needs an import: `src/theme/MDXComponents/index.tsx` registers all of them on the MDX scope of every page. + +Start a new tutorial from the [Tutorials overview](./index.md) and follow the **Tutorials page** skeleton in `STYLE.md`. The component sources are in `src/components/tutorials/`; each file's header comment says what the component is for, and the plain helpers next to them have `yarn test` cases. + +## CopyBlock + +One snippet the reader copies in one click: a command, a config file or file contents, with a title row and a copy button that stays visible. Pass the snippet as the `code` prop, or as text children (a template literal that spans several lines); shared leading indentation is dropped, so it copies exactly what the reader sees. `language` picks the highlighting (`sh`, `yaml`, `json`, ...) and `title` labels the block. + + + {`yarn build`} + + +```mdx title="Usage" + + {`yarn build`} + +``` + +## CodeGroup + +The files of one step, shown as tabs so the page stays short. The reader opens the file they need, and each tab keeps its own copy button. `items` takes one `{title, code, language}` object per file; `defaultTab` names the tab to open first. + + + +```mdx title="Usage" + +``` + +## Tabs and Tab + +The variants of one step, shown as tabs: install with yarn or with npm, run on Ubuntu or on RHEL. The reader opens the one that matches their setup. `defaultTab` opens one first; the tab row moves with the arrow keys and jumps to either end with **Home** and **End**. Each `` carries a `title` and its content. + + + + + + + + + + + + + + +```mdx title="Usage" + + + + + + + + + + + + +``` + +## Card and CardGroup + +A link shown as a clickable card: the "what to do next" at the end of a tutorial. An internal `href` starts with a single `/` and navigates in place; any other `href` opens in a new tab. `icon` is a short glyph before the title. `CardGroup` lays the cards in a grid; `cols` is how many columns a wide screen shows (1 to 4, default 2). + + + + + The tutorial groups and where to start. + + + + + What the Continuous Compliance Framework (CCF) does, for readers new to it. + + + + + Omit `href` for a card that only explains something. + + + + +```mdx title="Usage" + + + + The tutorial groups and where to start. + + + + + What the Continuous Compliance Framework (CCF) does, for readers new to it. + + + + + Omit `href` for a card that only explains something. + + + +``` + +## Steps and Step + +A task broken into numbered stages, read top to bottom: the circle numbers each step and the line joins them, so the reader sees how far they have come. A step's content is ordinary Markdown, so it can hold commands, prose or a callout. + + + + + Run the build from the repo root: + + + + + + + Serve the built site locally. + + + + + + +```mdx title="Usage" + + + + Run the build from the repo root: + + + + + + + Serve the built site locally. + + + + + +``` + +## Callout, Note, Tip, Info, Warning and Danger + +The notes a tutorial makes beside its steps. The type picks the accent color and the icon; the five types follow the admonitions Docusaurus itself ships. `title` adds a bold line before the text. ``, ``, ``, `` and `` are `` with the type already set. + + + +Tutorials are unversioned: they document the current release. + + + + + +Pass `defaultOpen` to an Accordion when most readers need the detail inside it. + + + + + +Every component on this page is registered on the MDX scope, so no tutorial page imports it. + + + + + +The build checks relative Markdown links and fails on a broken one. Link `STYLE.md` by name from a tutorial, not as a relative link that leaves `docs/`. + + + + + +Never link a versioned page to `current`, the unreleased docs: link between instances to a released version line. + + + + + +Pass `type` yourself (`note`, `tip`, `info`, `warning` or `danger`) when you build the type in, for example from a page's own data. + + + +```mdx title="Usage" + + +Tutorials are unversioned: they document the current release. + + + + + +Pass `defaultOpen` to an Accordion when most readers need the detail inside it. + + + + + +Every component on this page is registered on the MDX scope, so no tutorial page imports it. + + + + + +The build checks relative Markdown links and fails on a broken one. Link `STYLE.md` by name from a tutorial, not as a relative link that leaves `docs/`. + + + + + +Never link a versioned page to `current`, the unreleased docs: link between instances to a released version line. + + + + + +Pass `type` yourself (`note`, `tip`, `info`, `warning` or `danger`) when you build the type in, for example from a page's own data. + + +``` + +## Accordion and AccordionGroup + +A question or a detail the reader opens only when they need it: what a flag does, what the output looks like. Each item is a native `details` element, so it works before the page's scripts load; `defaultOpen` starts one open. `AccordionGroup` joins several items into one bordered list. + + + + + So the item opens and closes before the page's scripts load, with no state to manage. + + + + + Yes: its content is ordinary Markdown, so it can hold a CopyBlock, a table or a callout. + + + + +```mdx title="Usage" + + + + So the item opens and closes before the page's scripts load, with no state to manage. + + + + + Yes: its content is ordinary Markdown, so it can hold a CopyBlock, a table or a callout. + + + +``` + +## Combine them + +The components nest, so one step can hold everything the reader needs: a stage of a `Steps` list with its command in a `CodeGroup`, a caveat in a `Warning` and the longer explanation in an `Accordion`. + + + + + Open `sidebars.js` and add the page's id to `tutorialsSidebar`, after the page that should precede it: + + + + + + A doc id is the file's path under `docs/` without the extension. A wrong one fails the build. + + + + + + Run `yarn build`: it reports the ids it can't resolve. + + + + + + +```mdx title="Usage" + + + + Open `sidebars.js` and add the page's id to `tutorialsSidebar`, after the page that should precede it: + + + + + + A doc id is the file's path under `docs/` without the extension. A wrong one fails the build. + + + + + + Run `yarn build`: it reports the ids it can't resolve. + + + + + +``` + +## Related + +- [Tutorials overview](./index.md): the tutorial groups and where a new tutorial belongs. +- `STYLE.md`: voice, the **Tutorials page** skeleton, media and links. +- `CONTRIBUTING.md`: where tutorials live and how a docs pull request is reviewed. diff --git a/sidebars.js b/sidebars.js index 839faa2..bc142d6 100644 --- a/sidebars.js +++ b/sidebars.js @@ -33,7 +33,7 @@ const sidebars = { // Curated by hand; the navbar "Tutorials" item links to this sidebar // (see the docSidebar item in docusaurus.config.ts). - tutorialsSidebar: ['tutorials/index'], + tutorialsSidebar: ['tutorials/index', 'tutorials/components'], }; module.exports = sidebars;