|
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 | 19 | ``` |
20 | 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) |
| 35 | + |
21 | 36 | ## Explicit header tags |
22 | 37 |
|
23 | 38 | Due to the way our translation system works, it is necessary to add an explicit |
@@ -61,21 +76,31 @@ keywords: [chdb, clickhouse-local] |
61 | 76 | import clickhouse-local-1 from '@site/static/images/chdb/guides/clickhouse-local-1.png' |
62 | 77 | import clickhouse-local-2 from '@site/static/images/chdb/guides/clickhouse-local-2.png' |
63 | 78 | import clickhouse-local-3 from '@site/static/images/chdb/guides/clickhouse-local-3.png' |
| 79 | +import Image from '@theme/IdealImage'; |
64 | 80 | ``` |
65 | 81 |
|
66 | | -Use the `<img/>` tag to place your image in the appropriate place: |
| 82 | +To render images we use a fork of the IdealImage plugin. This generates multiple variants of an image, [asynchronously loading them as well as selecting the most appropriate based on the network connection](https://github.com/stereobooster/react-ideal-image/blob/master/introduction.md). |
| 83 | + |
| 84 | +Ensure you import the `Image` component as shown above. |
| 85 | + |
| 86 | +Use the `<Image/>` tag to place your image in the appropriate place: |
67 | 87 |
|
68 | 88 | ```markdown |
69 | 89 | Here is some example text which refers to the image below: |
70 | 90 |
|
71 | | -<img src={clickhouse-local-1} |
72 | | - alt='DESCRIPTION OF THE IMAGE' |
73 | | - style={{width: '800px'}} // optional |
74 | | -/> |
| 91 | +<Image img={clickhouse-local-1} alt='DESCRIPTION OF THE IMAGE' size="md" border background="black"/> |
75 | 92 |
|
76 | 93 | Here is another paragraph... |
77 | 94 | ``` |
78 | 95 |
|
| 96 | +This component takes a number of props: |
| 97 | + |
| 98 | +1. `img` - the imported image |
| 99 | +2. `alt` - mandatory alternate text specified |
| 100 | +3. `size` - either `lg` (width 1024px), `md` (width 600px), `sm` (width 300px) or `logo` (48x). This sets the maximum image size. Lower resolutions maybe used on smaller screens or slower connections. |
| 101 | +4. `border` - Applies a border. **Use for screenshots only.** |
| 102 | +5. `background` - either `white` or `black`. Applicable if your image is transparent. All new images must use `black`. |
| 103 | + |
79 | 104 | ## Codeblocks |
80 | 105 |
|
81 | 106 | Codeblocks are defined using backticks. For example: |
@@ -191,4 +216,37 @@ export function Anchor(props) { |
191 | 216 | ``` |
192 | 217 | - Replace `<span id="some-id"></span>` with `Anchor id="some-id"/>` |
193 | 218 |
|
| 219 | +### Floating pages |
| 220 | + |
| 221 | +In order to prevent pages from becoming 'floating' or 'orphaned' it is |
| 222 | +necessary that you add a newly created page to `sidebars.js`. We have a [custom |
| 223 | +docusaurus plugin](plugins/checkFloatingPages.js) to catch dangling pages. |
| 224 | + |
| 225 | +If there is some specific reason that you need to bypass this check, you can |
| 226 | +add an exception to `floating-pages-exceptions.txt` in the plugins directory. |
| 227 | + |
| 228 | +When adding a new page from the ClickHouse/ClickHouse repo this check will fail |
| 229 | +unless the file is in a folder which [`sidebars.js`](https://github.com/ClickHouse/clickhouse-docs/blob/main/sidebars.js) |
| 230 | +uses with `type: autogenerated` to generate the navigation items from the markdown |
| 231 | +files in the folder. |
| 232 | + |
| 233 | +If you've added a new page on ClickHouse/ClickHouse and this check is failing. |
| 234 | + |
| 235 | +For example: |
| 236 | + |
| 237 | +```text |
| 238 | +✅ All markdown files passed frontmatter validation. |
| 239 | +Loaded 3 exceptions from /opt/clickhouse-docs/plugins/floating-pages-exceptions.txt |
| 240 | +Skipping excepted page: index |
| 241 | +Skipping excepted page: integrations/language-clients/java/client-v1 |
| 242 | +Skipping excepted page: integrations/language-clients/java/jdbc-v1 |
| 243 | +�[31m1 floating pages found:�[0m |
| 244 | + - /opt/clickhouse-docs/docs/operations/query-condition-cache.md |
| 245 | +``` |
| 246 | + |
| 247 | +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 |
| 248 | +you can then rerun the docs check on the ClickHouse/ClickHouse repo which |
| 249 | +should pass. Finally open another PR on the docs repo again to remove the |
| 250 | +file from the exception list and add it to `sidebars.js` in the appropriate |
| 251 | +sidebar. |
194 | 252 |
|
0 commit comments