Repository navigation
feat(tutorials): showcase the tutorial components and document how to write tutorials #212
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
Open
ccf-factory
wants to merge
4
commits into
factory/stack/wi_2fa6b8bf808100304f9a/2
Choose a base branch
from
factory/stack/wi_2fa6b8bf808100304f9a/3
base: factory/stack/wi_2fa6b8bf808100304f9a/2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a07705a
feat(tutorials): showcase the tutorial components and document how to…
ccf-factory[bot] d11a2cd
self-review: address pass 1 findings
ccf-factory[bot] d7f1dcf
self-review: address pass 2 findings
ccf-factory[bot] d248b29
self-review: address pass 3 findings
ccf-factory[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| 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. | ||
|
|
||
| <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. | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
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
languageprop "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 supportsh: 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 onlytoken plainspans (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 assh,yamlorjson' 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
shfrom the examples - or make the claim true first: set themeConfig.prism.additionalLanguages: ['bash'] in docusaurus.config.ts (prismjs registers sh/shell as bash aliases, soshthen 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