Docs Contribution Guidelines
Thank you for your interest in contributing to the documentation! You will be helping the open source community and other developers interested in learning more about b and using it.
This guide is specific to contributing to the documentation. If you're interested in contributing to b's codebase, check out the contributing guidelines in the b GitHub repository.
Documentation Workspace
b's documentation is built with Docusaurus. The content lives on the main branch under the docs/ directory, while the Docusaurus site configuration lives on the docs branch.
The workspace structure on the docs branch:
apps/docs: the Docusaurus site that builds the documentation website.packages: shared UI components, Tailwind config, and TypeScript config.
During deployment, the CI copies docs/ from main into apps/docs/content and builds the site.
Documentation Content
Writing Documentation
The documentation content is written in Markdown and MDX format and is located in the docs/ directory of the b repository on the main branch.
If you're not familiar with Markdown, check out this cheat sheet for a quick start. MDX files can contain JSX components and import statements — you can learn more about MDX in Docusaurus's guide.
Style Guide
When you contribute to the documentation content, make sure to follow the documentation style guide.
How to Contribute
If you're fixing errors in an existing documentation page, you can scroll down to the end of the page and click on the "Edit this page" link. You'll be redirected to the GitHub edit form of that page and you can make edits directly and submit a pull request (PR).
If you're adding a new page or contributing to the codebase, fork the repository, create a new branch, and make all changes necessary. Then create a PR in the b repository.
Base Branch
Documentation contributions always use main as the base branch. Make sure to also open your PR against the main branch.
Pull Request Conventions
When you create a pull request, prefix the title with docs:.
In the body of the PR, explain clearly what the PR does. If the PR solves an issue, use closing keywords with the issue number. For example, "Closes #1333".
Sidebar Configuration
When you add a new page to the documentation, you must add the new page in apps/docs/sidebars.js on the docs branch. The properties of the exported object indicate sidebar names, and the values are arrays of sidebar items.
You can learn more about the sidebar item syntax in the Docusaurus docs.
Terminology
When the documentation page is a conceptual or an overview documentation, the label in the sidebar should start with a noun.
When the documentation page is tutorial documentation, the label in the sidebar should start with a verb. Exceptions to this rule are integration documentation and upgrade guides.
Sidebar Icons
To add an icon to a sidebar item, check if the icon is already exported in apps/docs/src/theme/Icon. If not, add the new icon as a React component in apps/docs/src/theme/Icon/Icon<Name>/index.tsx, where <Name> is the camel-case name of your icon. The icon must use an SVG element with stroke or fill set to currentColor.
For example:
import React from "react"
interface IconProps {
width?: number
height?: number
}
export default function IconBolt(props: IconProps) {
return (
<svg
width={props.width || 20}
height={props.height || 20}
viewBox="0 0 20 20"
fill="none" xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M3.125..."
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
stroke="currentColor" />
</svg>
)
}
Then register it in apps/docs/src/theme/Icon/index.ts:
Finally, reference the icon via the sidebar_icon custom prop:
Sidebar Item Types
There are different sidebar item types used in the documentation:
-
Homepage Items: If a sidebar item is shown under the
homepagesidebar, set theclassNameproperty tohomepage-sidebar-item. -
Sidebar Title: Add
sidebar_is_title: trueto thecustomPropsobject. Typically combined with an icon. -
Back Item: Add
sidebar_is_back_link: trueandsidebar_icon: "back-arrow"tocustomProps. -
Group Divider: Use
type: "html"withsidebar_is_group_divider: trueincustomProps. -
Group Headline: Use
type: "category"withsidebar_is_group_headline: trueincustomProps. -
Soon Item: Use
type: "link",href: "#", andsidebar_is_soon: trueincustomPropsto indicate upcoming content.
Notes and Additional Information
When displaying notes and additional information, use Admonitions. Match the type to the note's importance:
dangerfor critical warningstipfor helpful information outside the page's scopenotefor all other notes
Images
If you are adding images to a documentation page, you can host the image on Imgur for free to include it in the PR. Our team will later upload it to our image hosting.
Code Blocks
Use Tabs with Code Blocks
To use Tabs with Code Blocks, use Docusaurus's Tabs and TabItem components. Pass the isCodeTabs={true} prop for correct styling.
For example:
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="install" label="Install Binary" default>
```bash
b install jq
```
</TabItem>
<TabItem value="add" label="Add to Config">
```bash
b install --add jq
```
</TabItem>
</Tabs>
Add Title to Code Block with Tabs
Add the codeTitle prop to the Tabs component:
Add Title to Code Block without Tabs
Remove Report Button
Use the noReport metadata to remove the report button:
Remove Copy Button
Use the noCopy metadata to remove the copy button:
Linting with Vale
b uses Vale to lint documentation pages and perform checks on incoming PRs.
Result of Vale PR Checks
You can check the result of running the "lint" action on your PR by clicking the Details link next to it. You can find there all errors that you need to fix.
Run Vale Locally
- Install direnv and run
direnv allowin the root directory. - Lint with
vale:
VS Code Extension
You can optionally use the Vale VS Code extension for inline error highlighting while writing.
Linter Exceptions
If you need to break style guide rules in a document:
You can also disable specific rules:
If you use this in your PR, you must justify its usage.
Linting with ESLint
b uses ESLint to lint code blocks in both content and the documentation site codebase.
Linting Code/Content with ESLint
Each PR runs through a check that lints code in the content files using ESLint. The action's name is code-docs-eslint.
To check and fix ESLint errors locally, run from the docs branch root:
ESLint Exceptions
To skip linting for a specific code block:
To disable specific rules: