Skip to content

Commit 2594f34

Browse files
authored
Merge pull request #3376 from Blargian/document_standards
add style guide and turn on custom anchor headings check
2 parents 5445710 + 1e5640a commit 2594f34

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ Please assign any pull request (PR) against an issue; this helps the docs team t
132132
133133
Check out the GitHub docs for a refresher on [how to create a pull request](https://docs.github.com/en/desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request-from-github-desktop).
134134
135+
### Style guidelines
136+
137+
For style guidelines, see ["Style guide"](/contribute/style-guide.md).
138+
135139
### Tests and CI/CD {#tests-and-cicd}
136140
137141
There are five workflows that run against PRs in this repo:

contribute/style-guide.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ClickHouse docs style guide
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.
6+
7+
## YAML front matter
8+
9+
Begin every new markdown document with YAML front-matter:
10+
11+
```markdown
12+
---
13+
title: Using a clickhouse-local database
14+
sidebar_label: Using clickhouse-local database
15+
slug: /chdb/guides/clickhouse-local
16+
description: Learn how to use a clickhouse-local database with chDB
17+
keywords: [chdb, clickhouse-local]
18+
---
19+
```
20+
21+
## Explicit header tags
22+
23+
Due to the way our translation system works, it is necessary to add an explicit
24+
anchor tag next to every header, such as `{#explicit-anchor-tag}`.
25+
26+
For example:
27+
28+
```markdown
29+
## My header {#my-header}
30+
```
31+
32+
### Associated markdown rule or CI check
33+
- [`custom-anchor-headings`](/scripts/.markdownlint-cli2.yaml)
34+
35+
## Images
36+
37+
In all cases images get added to the `static/images` directory of the repository.
38+
Under the images directory you should place the images according to the folder
39+
structure of the docs.
40+
41+
For example, if you wanted to add images to `clickhouse-local.md` which is
42+
located at `/docs/chdb/guides/clickhouse-local.md`. You should add the
43+
images at `/static/images/chdb/guides/`.
44+
45+
Try to use descriptive names in lower case. For example:
46+
- `clickhouse-local-1.png`
47+
- `clickhouse-local-2.png`
48+
- `clickhouse-local-3.png` etc.
49+
50+
In the markdown document import the images under the YAML frontmatter:
51+
52+
```markdown
53+
---
54+
title: Using a clickhouse-local database
55+
sidebar_label: Using clickhouse-local database
56+
slug: /chdb/guides/clickhouse-local
57+
description: Learn how to use a clickhouse-local database with chDB
58+
keywords: [chdb, clickhouse-local]
59+
---
60+
61+
import clickhouse-local-1 from '@site/static/images/chdb/guides/clickhouse-local-1.png'
62+
import clickhouse-local-2 from '@site/static/images/chdb/guides/clickhouse-local-2.png'
63+
import clickhouse-local-3 from '@site/static/images/chdb/guides/clickhouse-local-3.png'
64+
```
65+
66+
Use the `<img/>` tag to place your image in the appropriate place:
67+
68+
```markdown
69+
Here is some example text which refers to the image below:
70+
71+
<img src={clickhouse-local-1}
72+
alt='DESCRIPTION OF THE IMAGE'
73+
style={{width: '800px'}} // optional
74+
/>
75+
76+
Here is another paragraph...
77+
```
78+
79+
## Codeblocks
80+
81+
Codeblocks are defined using backticks. For example:
82+
83+
```text
84+
\```sql title='Query'
85+
SELECT * FROM system.contributors;
86+
\```
87+
```
88+
89+
Code blocks:
90+
- Should always have a language defined immediately next to the opening 3
91+
backticks, without any space.
92+
- Have a title (optional) such as 'Query' or 'Response'
93+
- Use language `response` if it is for the result of a query.
94+
95+
### Associated markdown rule or CI check
96+
97+
- [`MD040` enforces that codeblocks have a language specified](/scripts/.markdownlint-cli2.yaml)
98+
99+
## Broken links
100+
101+
Making a change to a page slug or moving a file can result in broken links in
102+
numerous places across the docs. To mitigate this we use the built in link checker
103+
provided by Docusaurus. If broken links are found then docs check will fail with
104+
an error message something like this:
105+
106+
```text
107+
Exhaustive list of all broken links found:
108+
109+
- Broken link on source page path = /docs/observability/integrating-opentelemetry:
110+
-> linking to /docs/observability/schema-design#using-maps
111+
- Broken link on source page path = /docs/operations/server-configuration-parameters/settings:
112+
-> linking to ../../../engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl (resolved as: /engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl)
113+
- Broken link on source page path = /docs/partitions:
114+
-> linking to /docs/optimize/sparse-primary-indexes#data-is-organized-into-granules-for-parallel-data-processing
115+
```
116+
117+
To fix the links, find the source page, given after `source page path =` and search within it for the
118+
link given after `linking to`. As slugs are resolved relative to `/docs` you can exclude this from your
119+
search. E.g don't search `/docs/observability/schema-design#using-maps` but `/observability/schema-design#using-maps`
120+
121+
**note** if you can't find the link on the page but you're sure that you are looking in the file
122+
reported by the failing broken link checker, the link is most likely found in a snippet which is
123+
imported by that page. Find the snippet location from the import statement at the top of the page.
124+
125+

scripts/.markdownlint-cli2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config:
77
default: false
88
MD040: false # Fenced code blocks should have a language specified
99
links-url-type: false # Disallow relative links to a .md or .mdx file
10-
custom-anchor-headings: false # Headings must have a custom anchor which is unique per page eg. # A Heading {#a-heading}
10+
custom-anchor-headings: true # Headings must have a custom anchor which is unique per page eg. # A Heading {#a-heading}
1111

1212
# Keep this item last due to length
1313
proper-names: # MD044

0 commit comments

Comments
 (0)