Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
# <Tutorial title: what the reader can do at the end>

<What the tutorial ends with, in one or two sentences, and who it's for.>

## Before you start
<!-- The CCF version, the access the reader needs (roles, or a running system), and any earlier tutorial to do first. -->
## <Step titles, in order>
<!-- One `##` per stage: what the reader does, then what they should see. Name UI labels in bold. Give each command its own CopyBlock. -->
## Check your work
<!-- How the reader sees the result in the UI, and what it means. -->
## Next steps
<!-- CardGroup links to the tutorials that build on this one. -->
```

### Upgrade guide

For minor and major releases. One page per target line, for example "Upgrade to 0.21".
Expand Down
342 changes: 342 additions & 0 deletions docs/tutorials/components.mdx
Original file line number Diff line number Diff line change
@@ -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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Must-fix] DOCS-ACC-001 · Claim doesn't match the documented version

Line 14 tells authors that CopyBlock's language prop "picks the highlighting (sh, yaml, json, ...)" and the live demos and usage snippets use language="sh" throughout (lines 16-24, 33, 55-60, 131-138, 149-156). The source does not support sh: the site's highlighter is the Prism bundle pinned by yarn.lock (prism-react-renderer, 53 languages - no sh, bash or shell; yaml, json and js are present) and docusaurus.config.ts sets no themeConfig.prism.additionalLanguages (checked at main: only theme/darkTheme, lines 218-220). This round's production build of this very page confirms it: every language="sh" block SSRs with only token plain spans (no syntax colours) while language="js" tokenises correctly. The page's own demos render unhighlighted under the copy-paste guidance it gives. (The merged CopyBlock.tsx/CodeGroup.tsx comments carry the same 'such as sh, yaml or json' wording on main; fix them in the same follow-up.)

Why: Readers configure and operate CCF from these pages. A wrong default, flag, endpoint or permission sends an operator to a setting that does not exist or behaves differently at their version.
Fix: Either say what actually highlights - list languages from the shipped Prism set (yaml, json, js, ...) and drop sh from the examples - or make the claim true first: set themeConfig.prism.additionalLanguages: ['bash'] in docusaurus.config.ts (prismjs registers sh/shell as bash aliases, so sh then highlights site-wide, including the existing ```sh fences on the api/agent pages), keep the demos, and correct the same wording in CopyBlock.tsx and CodeGroup.tsx on main.

ccf-review · 08fe3964f3fb · rules@unknown


<CopyBlock title="Build the site" language="sh">
{`yarn build`}
</CopyBlock>

```mdx title="Usage"
<CopyBlock title="Build the site" language="sh">
{`yarn build`}
</CopyBlock>
```

## 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.

<CodeGroup
defaultTab="Terminal"
items={[
{title: 'Terminal', code: 'yarn build', language: 'sh'},
{title: 'package.json', code: '"build": "docusaurus build",', language: 'json'},
]}
/>

```mdx title="Usage"
<CodeGroup
defaultTab="Terminal"
items={[
{title: 'Terminal', code: 'yarn build', language: 'sh'},
{title: 'package.json', code: '"build": "docusaurus build",', language: 'json'},
]}
/>
```

## 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 `<Tab>` carries a `title` and its content.

<Tabs defaultTab="yarn">
<Tab title="yarn">

<CopyBlock language="sh" code={`yarn build`} />

</Tab>
<Tab title="npm">

<CopyBlock language="sh" code={`npm run build`} />

</Tab>
</Tabs>

```mdx title="Usage"
<Tabs defaultTab="yarn">
<Tab title="yarn">

<CopyBlock language="sh" code={`yarn build`} />

</Tab>
<Tab title="npm">

<CopyBlock language="sh" code={`npm run build`} />

</Tab>
</Tabs>
```

## 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).

<CardGroup cols={2}>
<Card title="Tutorials overview" icon="🧭" href="/tutorials">

The tutorial groups and where to start.

</Card>
<Card title="Introduction" href="/introduction">

What the Continuous Compliance Framework (CCF) does, for readers new to it.

</Card>
<Card title="A card without a link holds text" icon="✍️">

Omit `href` for a card that only explains something.

</Card>
</CardGroup>

```mdx title="Usage"
<CardGroup cols={2}>
<Card title="Tutorials overview" icon="🧭" href="/tutorials">

The tutorial groups and where to start.

</Card>
<Card title="Introduction" href="/introduction">

What the Continuous Compliance Framework (CCF) does, for readers new to it.

</Card>
<Card title="A card without a link holds text" icon="✍️">

Omit `href` for a card that only explains something.

</Card>
</CardGroup>
```

## 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.

<Steps>
<Step title="Build the site">

Run the build from the repo root:

<CopyBlock language="sh" code={`yarn build`} />

</Step>
<Step title="Preview it">

Serve the built site locally.

<CopyBlock language="sh" code={`yarn serve`} />

</Step>
</Steps>

```mdx title="Usage"
<Steps>
<Step title="Build the site">

Run the build from the repo root:

<CopyBlock language="sh" code={`yarn build`} />

</Step>
<Step title="Preview it">

Serve the built site locally.

<CopyBlock language="sh" code={`yarn serve`} />

</Step>
</Steps>
```

## 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. `<Note>`, `<Tip>`, `<Info>`, `<Warning>` and `<Danger>` are `<Callout>` with the type already set.

<Note>

Tutorials are unversioned: they document the current release.

</Note>

<Tip title="Open one by default">

Pass `defaultOpen` to an Accordion when most readers need the detail inside it.

</Tip>

<Info>

Every component on this page is registered on the MDX scope, so no tutorial page imports it.

</Info>

<Warning title="Relative links stay inside docs/">

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/`.

</Warning>

<Danger>

Never link a versioned page to `current`, the unreleased docs: link between instances to a released version line.

</Danger>

<Callout type="info" title="The long form">

Pass `type` yourself (`note`, `tip`, `info`, `warning` or `danger`) when you build the type in, for example from a page's own data.

</Callout>

```mdx title="Usage"
<Note>

Tutorials are unversioned: they document the current release.

</Note>

<Tip title="Open one by default">

Pass `defaultOpen` to an Accordion when most readers need the detail inside it.

</Tip>

<Info>

Every component on this page is registered on the MDX scope, so no tutorial page imports it.

</Info>

<Warning title="Relative links stay inside docs/">

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/`.

</Warning>

<Danger>

Never link a versioned page to `current`, the unreleased docs: link between instances to a released version line.

</Danger>

<Callout type="info" title="The long form">

Pass `type` yourself (`note`, `tip`, `info`, `warning` or `danger`) when you build the type in, for example from a page's own data.

</Callout>
```

## 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.

<AccordionGroup>
<Accordion title="Why a native details element?">

So the item opens and closes before the page's scripts load, with no state to manage.

</Accordion>
<Accordion title="Can an accordion hold more than text?" defaultOpen>

Yes: its content is ordinary Markdown, so it can hold a CopyBlock, a table or a callout.

</Accordion>
</AccordionGroup>

```mdx title="Usage"
<AccordionGroup>
<Accordion title="Why a native details element?">

So the item opens and closes before the page's scripts load, with no state to manage.

</Accordion>
<Accordion title="Can an accordion hold more than text?" defaultOpen>

Yes: its content is ordinary Markdown, so it can hold a CopyBlock, a table or a callout.

</Accordion>
</AccordionGroup>
```

## 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`.

<Steps>
<Step title="Add the page to the sidebar">

Open `sidebars.js` and add the page's id to `tutorialsSidebar`, after the page that should precede it:

<CodeGroup
items={[
{
title: 'sidebars.js',
code: "tutorialsSidebar: [\n 'tutorials/index',\n 'tutorials/components',\n],",
language: 'js',
},
]}
/>

<Warning title="Keep the ids exact">

A doc id is the file's path under `docs/` without the extension. A wrong one fails the build.

</Warning>

<Accordion title="How do I check the id?">

Run `yarn build`: it reports the ids it can't resolve.

</Accordion>

</Step>
</Steps>

```mdx title="Usage"
<Steps>
<Step title="Add the page to the sidebar">

Open `sidebars.js` and add the page's id to `tutorialsSidebar`, after the page that should precede it:

<CodeGroup
items={[
{
title: 'sidebars.js',
code: "tutorialsSidebar: [\n 'tutorials/index',\n 'tutorials/components',\n],",
language: 'js',
},
]}
/>

<Warning title="Keep the ids exact">

A doc id is the file's path under `docs/` without the extension. A wrong one fails the build.

</Warning>

<Accordion title="How do I check the id?">

Run `yarn build`: it reports the ids it can't resolve.

</Accordion>

</Step>
</Steps>
```

## 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.
2 changes: 1 addition & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading