Skip to content

Commit a0124f5

Browse files
authored
full pass on Style Guide (#20307)
* full pass on Style Guide
1 parent 7fbb35c commit a0124f5

File tree

2 files changed

+441
-289
lines changed

2 files changed

+441
-289
lines changed

MarkdownGuide.md

Lines changed: 135 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This guide covers Markdown-specific syntax and formatting conventions used in Co
44

55
## Table of Contents
66

7+
- [Site structure](#site-structure)
8+
- [Docs repository](#docs-repository)
9+
- [Page headings](#page-headings)
10+
- [Sidebar](#sidebar)
711
- [Title](#title)
812
- [Headings](#headings)
913
- [Text formatting](#text-formatting)
@@ -30,7 +34,7 @@ This guide covers Markdown-specific syntax and formatting conventions used in Co
3034
- [Tables](#tables)
3135
- [Markdown tables](#markdown-tables)
3236
- [HTML tables](#html-tables)
33-
- [Markdown vs HTML](#markdown-vs-html)
37+
- [Markdown vs. HTML](#markdown-vs-html)
3438
- [Images](#images)
3539
- [Videos](#videos)
3640
- [Versioning](#versioning)
@@ -46,6 +50,87 @@ This guide covers Markdown-specific syntax and formatting conventions used in Co
4650
- [Comments](#comments)
4751
- [TODOs](#todos)
4852

53+
## Site structure
54+
55+
### Docs repository
56+
57+
Documentation for each CockroachDB version is organized in dedicated directories. For example, CockroachDB v23.1 docs are in `src/current/v23.1` and `src/current/_includes/v23.1`, while CockroachDB API docs are in `src/api`.
58+
59+
Each page must be a `.md` file written in [Redcarpet](https://github.com/vmg/redcarpet) Markdown. Use lowercase file names with dashes between words.
60+
61+
**Example:** `name-of-your-file.md`
62+
63+
### Page headings
64+
65+
All Markdown pages require YAML front matter:
66+
67+
```yaml
68+
---
69+
title: Title of Page
70+
summary: Short description of page for SEO
71+
---
72+
```
73+
74+
**Required fields:**
75+
76+
Field | Description
77+
------|------------
78+
`title` | Page heading in title case
79+
`summary` | SEO meta description (50-160 characters)
80+
81+
**Optional fields:**
82+
83+
Field | Description | Default
84+
------|-------------|--------
85+
`toc` | Auto-generates page table of contents | `true`
86+
`toc_not_nested` | Limits TOC to h2 headers only | `false`
87+
`allowed_hashes` | URL hashes that don't correspond to headings | None
88+
`feedback` | Adds Yes/No feedback buttons | `true`
89+
`contribute` | Adds Contribute options | `true`
90+
`twitter` | Enables Twitter campaign tracking | `false`
91+
`no_sidebar` | Removes page sidebar | `false`
92+
`block_search` | Excludes page from search indexing | `false`
93+
`back_to_top` | Adds back-to-top button | `false`
94+
`docs_area` | Analytics area (for example, `get_started`, `reference.sql`) | None
95+
`product_area` | Product area for analytics | None
96+
97+
### Sidebar
98+
99+
Each CockroachDB version uses a JSON file to define sidebar navigation. The file is located at `_includes/vXX.Y/sidebar-data/{section}.json`.
100+
101+
**JSON structure:**
102+
103+
Field | Type | Description
104+
------|------|------------
105+
`title` | String | Section or page title in sidebar
106+
`items` | Array | Pages or subsections within a section
107+
`urls` | Array | Page URLs formatted as `/${VERSION}/<page-name>.html`
108+
109+
**Example structure:**
110+
111+
```json
112+
[
113+
{
114+
"title": "Get Started",
115+
"items": [
116+
{
117+
"title": "Install CockroachDB",
118+
"urls": ["/${VERSION}/install-cockroachdb.html"]
119+
},
120+
{
121+
"title": "Start a Local Cluster",
122+
"items": [
123+
{
124+
"title": "From Binary",
125+
"urls": ["/${VERSION}/start-a-local-cluster.html"]
126+
}
127+
]
128+
}
129+
]
130+
}
131+
]
132+
```
133+
49134
## Title
50135

51136
Set the page title in the `title:` metadata. The title should be in title case. Heading 1 (`#`) is reserved for page titles and **should not** be used in pages.
@@ -118,7 +203,7 @@ When linking to a versioned page from a Technical Advisory (in `advisories`), ha
118203

119204
### Custom anchor links
120205

121-
To link to a specific location on a page that is not a heading (e.g., a specific command-line flag in a table), add a manual anchor and use the `id` parameter:
206+
To link to a specific location on a page that is not a heading (for example, a specific command-line flag in a table), add a manual anchor and use the `id` parameter:
122207

123208
**Example:**
124209

@@ -149,7 +234,7 @@ For websites that automatically localize pages, avoid using localization element
149234

150235
### Inline code
151236

152-
Use inline code when referring to code, commands, or other technical syntax within a sentence. Inline `code` is surrounded by backticks (``).
237+
Use inline code when referring to code, commands, values, or other technical syntax within a sentence. Inline `code` is surrounded by backticks (``).
153238

154239
**Example:** The `CREATE TABLE` statement creates a new table in a database.
155240

@@ -213,28 +298,11 @@ Notes for usage:
213298
- **Copy to Clipboard** should be used for every code block that can be **executed**.
214299
- To render properly, there must be a line break above the `{% include_cached copy-clipboard.html %}` line.
215300

216-
### Placeholders
217-
218-
Code samples often include placeholder values, to be replaced by values specific to a user's environment. To denote that a value in a code sample is a placeholder value that should be replaced, use curly brackets (`{}`).
219-
220-
For example: `SELECT * FROM TABLE {mytable};`. In this code sample, `{mytable}` would be replaced by some table name before the code could actually run.
221-
222-
When you use placeholders, you usually need to define the value within the brackets, if the placeholder value isn't clear. Define placeholder values immediately following the code sample:
223-
224-
- For a single placeholder value, use a follow-up sentence.
225-
- For multiple placeholder values, use a bulleted list.
226-
- For many placeholder values (10+), use a table.
227-
- For large code blocks, define the placeholder values inside the code block with an inline code comment.
228-
229-
Ensure that placeholders are placed within backticks: `SET {session variable}`. This signifies that placeholder values are code.
230-
231-
If the code sample is sensitive to curly bracket characters (e.g., JavaScript), you can use `<>` instead.
232-
233301
### Escaping special characters
234302

235303
Sometimes you may need to escape special characters to achieve proper rendering:
236304

237-
- **Jekyll-reserved characters** (e.g., double `{{ ... }}`) in code blocks: Wrap the specific line(s) with Liquid tags `{% raw %} ... {% endraw %}`.
305+
- **Jekyll-reserved characters** (for example, double `{{ ... }}`) in code blocks: Wrap the specific line(s) with Liquid tags `{% raw %} ... {% endraw %}`.
238306

239307
~~~markdown
240308
{% raw %}summary: Instance {{ $labels.instance }} has {{ $value }} tripped per-Replica circuit breakers{% endraw %}
@@ -257,7 +325,7 @@ Introduce a list with a sentence and a colon. Use periods at the end of list ite
257325

258326
### Ordered lists
259327

260-
For each item of a **numbered list**, use `1.` followed by a period and a space, e.g., `1. This is a numbered list item`. The HTML renderer will render the steps in the correct order.
328+
For each item of a **numbered list**, use `1.` followed by a period and a space, for example, `1. This is a numbered list item`. The HTML renderer will render the steps in the correct order.
261329

262330
~~~markdown
263331
1. This is the first step.
@@ -267,7 +335,7 @@ For each item of a **numbered list**, use `1.` followed by a period and a space,
267335

268336
### Unordered lists
269337

270-
For each item of a **bulleted list**, use one dash followed by one space, e.g., `- This is a bulleted list item`.
338+
For each item of a **bulleted list**, use one dash followed by one space, for example, `- This is a bulleted list item`.
271339

272340
~~~markdown
273341
- This is a bullet point.
@@ -343,7 +411,7 @@ Use tables to display structured information in an easy-to-read format. We use t
343411

344412
### Markdown tables
345413

346-
If you can keep the table formatting simple (e.g., basic text formatting and using `<br>` tags for paragraph breaks), create a table using Markdown. This is the preferred table format.
414+
If you can keep the table formatting simple (for example, basic text formatting and using `<br>` tags for paragraph breaks), create a table using Markdown. This is the preferred table format.
347415

348416
To create a table, use pipes (`|`) between columns and at least 3 dashes (`-`) separating the header cells from the body cells. A return denotes the start of the next row. The text within each column does not need to align in order to be rendered correctly, and you can inline Markdown or HTML.
349417

@@ -390,12 +458,40 @@ You can use the following HTML formatting within an HTML table:
390458
- Paragraph breaks (`<p>`)
391459
- Lists (`<ol>` / `<ul>` / `<li>`)
392460

393-
### Markdown vs HTML
461+
### Markdown vs. HTML
394462

395463
- Prefer Markdown syntax over HTML when possible for better readability and maintainability.
396464
- Use HTML only when Markdown doesn't provide the necessary functionality.
397465
- When mixing Markdown and HTML, ensure proper spacing and formatting. Preview the rendered page locally.
398466

467+
## Callouts
468+
469+
CockroachDB docs use three classes of "callouts," which are highlighted blocks of text: tips, notes, and warnings.
470+
471+
- To insert a **tip**, use the following code:
472+
473+
~~~
474+
{{site.data.alerts.callout_success}}
475+
tip text goes here
476+
{{site.data.alerts.end}}
477+
~~~
478+
479+
- To insert a **note**, use the following code:
480+
481+
~~~
482+
{{site.data.alerts.callout_info}}
483+
note text goes here
484+
{{site.data.alerts.end}}
485+
~~~
486+
487+
- To insert a **warning**, use the following code:
488+
489+
~~~
490+
{{site.data.alerts.callout_danger}}
491+
warning text goes here
492+
{{site.data.alerts.end}}
493+
~~~
494+
399495
## Images
400496

401497
Use the following HTML and Liquid to include an image in a Markdown page:
@@ -476,14 +572,6 @@ A patch release version of CockroachDB receives updates as patches. To refer to
476572

477573
## Include files
478574

479-
Sometimes content needs to be duplicated across two or more pages in the documentation. For example, there may be several pages that need the same cluster setup, but describe how to use different features. Or a very specific [note](#notes) or [warning](#warnings) needs to be added to several different pages.
480-
481-
In these situations, you will need to use an _include file_. An include file is a separate Markdown file (stored in `_includes/some/shared-file.md`) where you will write content that is shared across multiple pages.
482-
483-
For more information about include files, see [the Jekyll `include` documentation](https://jekyllrb.com/docs/includes/).
484-
485-
_Note_: Using include files adds complexity to the docs site architecture and build process. It also makes writing the documentation more tricky, because instead of working on text in one document, the writer has to jump between two or more files. If you can link to existing content rather than using an include file, strongly consider doing that instead.
486-
487575
There are [basic](#basic-include-file-usage) and [advanced](#advanced-include-file-usage) methods for using include files. Use the basic method unless you are sure you need the advanced.
488576

489577
<a name="basic-include-file-usage"></a>
@@ -551,36 +639,31 @@ For more information about the `remote_include` tag, see the README in the [jeky
551639

552640
### Filter tabs
553641

554-
On some pages in our docs, there are tabs at the top of the page that will link to different pages at different hyperlinks. For example, in the [Install CockroachDB docs](https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html), there are links to the Mac, Linux, and Windows pages at the top of the page.
642+
Use filter tabs to create navigation between related pages. The [`filter-tabs.md`](https://github.com/cockroachdb/docs/blob/main/src/current/_includes/filter-tabs.md) include generates tabs that link to different pages.
555643

556-
Use [`filter-tabs.md`](https://github.com/cockroachdb/docs/blob/main/src/current/_includes/filter-tabs.md) to specify these tabs for any `cockroachcloud` docs or docs for CockroachDB v21.2 and later.
644+
**Note:** Filter tabs link to different URLs/pages, not tabs within a single page.
557645

558-
**Note:** this include file only produces tabs that link to different URLs/pages. It cannot be used for creating tabs within a single page.
646+
**Setup process:**
559647

560-
The general process to follow and use this is as follows:
648+
1. Identify pages for filter tabs and note their HTML filenames (for example, `install-cockroachdb-mac.html`).
561649

562-
1. Identify each page to be linked from a filter tab.
563-
- Make a note of each HTML page filename (e.g., `install-cockroachdb-mac.html`).
564-
- Draft a tab name (e.g., `Install on <strong>Mac</strong>`)—the text to display on the tab itself. This supports HTML, not Markdown.
565-
2. Create an include Markdown file within `_includes/<CRDB version>/filter-tabs` with the following structure:
566-
```
567-
{% assign tab_names_html = "Tab Name 1;Tab Name 2;Tab Name 3" %}
568-
{% assign html_page_filenames = "page-name-1.html;page-name-2.html;page-name-3.html" %}
650+
1. Create an include file in `_includes/<version>/filter-tabs/` with this structure:
569651

570-
{% include filter-tabs.md tab_names=tab_names_html page_filenames=html_page_filenames page_folder=<CRDB version> %}
652+
```liquid
653+
{% assign tab_names_html = "Tab 1;Tab 2;Tab 3" %}
654+
{% assign html_page_filenames = "page1.html;page2.html;page3.html" %}
655+
{% include filter-tabs.md tab_names=tab_names_html page_filenames=html_page_filenames page_folder=<version> %}
571656
```
572-
- `tab_names_html` is a semicolon-separated list of the HTML-supported tab names.
573-
- `html_page_filenames` is a semicolon-separated list of the page filenames with the `.html` extension.
574-
- `<crdb_version>` is `"cockroachcloud"` (with quotes) for any CockroachDB Cloud docs and `page.version.version` (without quotes) for any versioned docs (v21.2 and later).
575-
3. For each page listed in `html_page_filenames`, paste `{% include <CRDB version>/filter-tabs/<filter-tab-include>.html %}` in the position where you want the tabs to be included.
657+
658+
1. Include the filter tabs on each target page: `{% include <version>/filter-tabs/<name>.html %}`
576659
577660
### Technical limitations of include files
578661
579662
Include files have the following technical limitations:
580663
581-
- They cannot be used in [Markdown tables](#tables). For example, this is why [the guidance about how to use version tags in tables](#version-tags-tables) is provided.
582-
- A [remote include](#remote-includes) file in another repo that contains an [include file](#include-files) that references something in `cockroachdb/docs` will fail to pull in and render that include file.
583-
- Include files containing a paragraph followed by a code block do not render correctly in the context of both paragraphs and lists in the files they are included from due to a limitation in our [Markdown](#markdown) renderer.
664+
- Cannot be used in [Markdown tables](#markdown-tables)
665+
- Remote includes cannot reference local includes
666+
- Include files with paragraphs followed by code blocks may not render correctly in all contexts
584667
585668
## Tabs
586669

0 commit comments

Comments
 (0)