|
1 | 1 | # ClickHouse docs style guide |
2 | 2 |
|
3 | | -In this document, you will find a number of style guidelines for writing documentation. |
4 | | -The rules in this guide are intended to assist in helping us to create a high |
5 | | -quality documentation offering on par with the quality of ClickHouse itself. |
| 3 | +In this document, you will find a number of style guidelines for writing ClickHouse |
| 4 | +documentation. As documentation is a collective effort, these guidelines are |
| 5 | +intended to help all of us ensure quality and consistency across our documentation. |
6 | 6 |
|
7 | 7 | ## YAML front matter |
8 | 8 |
|
9 | | -Begin every new markdown document with YAML front-matter: |
| 9 | +Begin every new Markdown document with YAML front-matter: |
10 | 10 |
|
11 | 11 | ```markdown |
12 | 12 | --- |
13 | | -title: Using a clickhouse-local database |
14 | | -sidebar_label: Using clickhouse-local database |
| 13 | +title: 'Using a clickhouse-local database' |
| 14 | +sidebar_label: 'Using clickhouse-local database' |
15 | 15 | slug: /chdb/guides/clickhouse-local |
16 | | -description: Learn how to use a clickhouse-local database with chDB |
17 | | -keywords: [chdb, clickhouse-local] |
| 16 | +description: 'Learn how to use a clickhouse-local database with chDB' |
| 17 | +keywords: ['chdb', 'clickhouse-local'] |
18 | 18 | --- |
| 19 | +``` |
| 20 | + |
| 21 | +### Associated markdown rule or CI check |
| 22 | + |
| 23 | +#### front-matter validation |
| 24 | + |
| 25 | +There is a custom Docusaurus plugin which runs on build that makes the following |
| 26 | +checks on front-matter: |
| 27 | + |
| 28 | +- title, description and slug are specified. |
| 29 | +- keywords use flow style arrays with single quoted items e.g. |
| 30 | + `keywords: ['integrations']` |
| 31 | +- single quotes are used for title, description, slug, sidebar_label |
| 32 | +- there is an empty line after the YAML frontmatter block |
| 33 | + |
| 34 | +For implementation details see [plugins/frontmatter-validation](https://github.com/ClickHouse/clickhouse-docs/tree/main/plugins/frontmatter-validation) |
19 | 35 |
|
20 | 36 | ## Explicit header tags |
21 | 37 |
|
@@ -91,6 +107,38 @@ Code blocks: |
91 | 107 | - Have a title (optional) such as 'Query' or 'Response' |
92 | 108 | - Use language `response` if it is for the result of a query. |
93 | 109 |
|
| 110 | +### Highlighting |
| 111 | + |
| 112 | +You can highlight lines in a code block using the following keywords: |
| 113 | + |
| 114 | +- `highlight-next-line` |
| 115 | +- `highlight-start` |
| 116 | +- `highlight-end` |
| 117 | + |
| 118 | +These keywords should be added as comments in the codeblock with the appropriate |
| 119 | +escape symbol for the codeblock language. |
| 120 | + |
| 121 | +For example, if the codeblock is SQL: |
| 122 | + |
| 123 | +```text |
| 124 | +SELECT UserID, count(UserID) AS Count |
| 125 | +-- highlight-next-line |
| 126 | +FROM mv_hits_URL_UserID |
| 127 | +WHERE URL = 'http://public_search' |
| 128 | +GROUP BY UserID |
| 129 | +ORDER BY Count DESC |
| 130 | +LIMIT 10; |
| 131 | +``` |
| 132 | + |
| 133 | +If the codeblock is a response: |
| 134 | + |
| 135 | +```text |
| 136 | +10 rows in set. Elapsed: 0.026 sec. |
| 137 | +# highlight-next-line |
| 138 | +Processed 335.87 thousand rows, |
| 139 | +13.54 MB (12.91 million rows/s., 520.38 MB/s.) |
| 140 | +``` |
| 141 | + |
94 | 142 | ### Associated markdown rule or CI check |
95 | 143 |
|
96 | 144 | - [`MD040` enforces that codeblocks have a language specified](/scripts/.markdownlint-cli2.yaml) |
@@ -158,4 +206,37 @@ export function Anchor(props) { |
158 | 206 | ``` |
159 | 207 | - Replace `<span id="some-id"></span>` with `Anchor id="some-id"/>` |
160 | 208 |
|
| 209 | +### Floating pages |
| 210 | + |
| 211 | +In order to prevent pages from becoming 'floating' or 'orphaned' it is |
| 212 | +necessary that you add a newly created page to `sidebars.js`. We have a [custom |
| 213 | +docusaurus plugin](plugins/checkFloatingPages.js) to catch dangling pages. |
| 214 | + |
| 215 | +If there is some specific reason that you need to bypass this check, you can |
| 216 | +add an exception to `floating-pages-exceptions.txt` in the plugins directory. |
| 217 | + |
| 218 | +When adding a new page from the ClickHouse/ClickHouse repo this check will fail |
| 219 | +unless the file is in a folder which [`sidebars.js`](https://github.com/ClickHouse/clickhouse-docs/blob/main/sidebars.js) |
| 220 | +uses with `type: autogenerated` to generate the navigation items from the markdown |
| 221 | +files in the folder. |
| 222 | + |
| 223 | +If you've added a new page on ClickHouse/ClickHouse and this check is failing. |
| 224 | + |
| 225 | +For example: |
| 226 | + |
| 227 | +```text |
| 228 | +✅ All markdown files passed frontmatter validation. |
| 229 | +Loaded 3 exceptions from /opt/clickhouse-docs/plugins/floating-pages-exceptions.txt |
| 230 | +Skipping excepted page: index |
| 231 | +Skipping excepted page: integrations/language-clients/java/client-v1 |
| 232 | +Skipping excepted page: integrations/language-clients/java/jdbc-v1 |
| 233 | +�[31m1 floating pages found:�[0m |
| 234 | + - /opt/clickhouse-docs/docs/operations/query-condition-cache.md |
| 235 | +``` |
| 236 | + |
| 237 | +You will need to open a PR on docs repo to add this page to [`floating-pages-exceptions.txt`](https://github.com/ClickHouse/clickhouse-docs/blob/main/plugins/floating-pages-exceptions.txt). Once it is merged |
| 238 | +you can then rerun the docs check on the ClickHouse/ClickHouse repo which |
| 239 | +should pass. Finally open another PR on the docs repo again to remove the |
| 240 | +file from the exception list and add it to `sidebars.js` in the appropriate |
| 241 | +sidebar. |
161 | 242 |
|
0 commit comments