@@ -45,18 +45,22 @@ To install dependencies listed in package.json:
45
45
3 . Run ` yarn ` to install dependencies (including Hugo).
46
46
4 . Install the Yarn package manager and run ` yarn ` to install project dependencies.
47
47
48
- ` package.json ` contains dependencies for linting and running Git hooks.
48
+ ` package.json ` contains dependencies used in ` /assets/js ` JavaScript code and
49
+ dev dependencies used in pre-commit hooks for linting, syntax-checking, and testing.
49
50
50
- - ** [ husky] ( https://github.com/typicode/husky ) ** : manages Git hooks, including the pre-commit hook for linting and testing
51
- - ** [ lint-staged] ( https://github.com/lint-staged/lint-staged ) ** : passes staged files to commands
52
- - ** [ prettier] ( https://prettier.io/docs/en/ ) ** : formats code, including Markdown, according to style rules for consistency
51
+ Dev dependencies include:
53
52
54
- ### Install Docker
53
+ - [ Lefthook] ( https://github.com/evilmartians/lefthook ) : configures and
54
+ manages pre-commit hooks for linting and testing Markdown content.
55
+ - [ prettier] ( https://prettier.io/docs/en/ ) : formats code, including Markdown, according to style rules for consistency
56
+ - [ Cypress] : e2e testing for UI elements and URLs in content
55
57
56
- Install [ Docker] ( https://docs.docker.com/get-docker/ ) for your system.
58
+ ### Install Docker
57
59
58
60
docs-v2 includes Docker configurations (` compose.yaml ` and Dockerfiles) for running the Vale style linter and tests for code blocks (Shell, Bash, and Python) in Markdown files.
59
61
62
+ Install [ Docker] ( https://docs.docker.com/get-docker/ ) for your system.
63
+
60
64
#### Build the test dependency image
61
65
62
66
After you have installed Docker, run the following command to build the test
@@ -65,13 +69,24 @@ The tests defined in `compose.yaml` use the dependencies and execution
65
69
environment from this image.
66
70
67
71
``` bash
68
- docker build -t influxdata: docs-pytest -f Dockerfile.pytest .
72
+ docker build -t influxdata/ docs-pytest:latest -f Dockerfile.pytest .
69
73
```
70
74
71
75
### Run the documentation locally (optional)
72
76
73
77
To run the documentation locally, follow the instructions provided in the README.
74
78
79
+ ### Install Visual Studio Code extensions
80
+
81
+ If you use Microsoft Visual Studio (VS) Code, you can install extensions
82
+ to help you navigate, check, and edit files.
83
+
84
+ docs-v2 contains a ` ./.vscode/settings.json ` that configures the following extensions:
85
+
86
+ - Comment Anchors: recognizes tags (for example, ` //SOURCE ` ) and makes links and filepaths clickable in comments.
87
+ - Vale: shows linter errors and suggestions in the editor.
88
+ - YAML Schemas: validates frontmatter attributes.
89
+
75
90
### Make your changes
76
91
77
92
Make your suggested changes being sure to follow the [ style and formatting guidelines] ( #style--formatting ) outline below.
@@ -80,29 +95,31 @@ Make your suggested changes being sure to follow the [style and formatting guide
80
95
81
96
### Automatic pre-commit checks
82
97
83
- docs-v2 uses Husky to manage Git hook scripts.
84
- When you try to commit your changes (for example, ` git commit ` ), Git runs
85
- scripts configured in ` .husky/pre-commit ` , including linting and tests for your ** staged** files.
98
+ docs-v2 uses Lefthook to manage Git hooks, such as pre-commit hooks that lint Markdown and test code blocks.
99
+ When you try to commit changes (` git commit ` ), Git runs
100
+ the commands configured in ` lefthook.yml ` which pass your ** staged** files to Vale,
101
+ Prettier, Cypress (for UI tests and link-checking), and Pytest (for testing Python and shell code in code blocks).
86
102
87
103
### Skip pre-commit hooks
88
104
89
105
** We strongly recommend running linting and tests** , but you can skip them
90
106
(and avoid installing dependencies)
91
- by including the ` HUSKY =0` environment variable or the ` --no-verify ` flag with
107
+ by including the ` LEFTHOOK =0` environment variable or the ` --no-verify ` flag with
92
108
your commit--for example:
93
109
94
110
``` sh
95
111
git commit -m " <COMMIT_MESSAGE>" --no-verify
96
112
```
97
113
98
114
``` sh
99
- HUSKY =0 git commit
115
+ LEFTHOOK =0 git commit
100
116
```
101
117
102
- For more options, see the [ Husky documentation] ( https://typicode.github.io/husky/how-to.html#skipping-git-hooks ) .
103
-
104
118
### Set up test scripts and credentials
105
119
120
+ Tests for code blocks require your InfluxDB credentials and other typical
121
+ InfluxDB configuration.
122
+
106
123
To set up your docs-v2 instance to run tests locally, do the following:
107
124
108
125
1 . ** Set executable permissions on test scripts** in ` ./test/src ` :
@@ -118,91 +135,38 @@ To set up your docs-v2 instance to run tests locally, do the following:
118
135
Cloud Dedicated instance for testing in most cases. To avoid conflicts when
119
136
running tests, create separate Cloud Dedicated and Clustered databases.
120
137
121
- 3 . ** Create .env.test** : Copy the ` ./test/env.test.example ` file into each
138
+ 1 . ** Create .env.test** : Copy the ` ./test/env.test.example ` file into each
122
139
product directory to test and rename the file as ` .env.test ` --for example:
123
140
124
141
``` sh
125
142
./content/influxdb/cloud-dedicated/.env.test
126
143
```
127
144
128
- 4 . Inside each product's ` .env.test ` file, assign your InfluxDB credentials to
129
- environment variables.
145
+ 2 . Inside each product's ` .env.test ` file, assign your InfluxDB credentials to
146
+ environment variables:
130
147
131
- In addition to the usual ` INFLUX_ ` environment variables, in your
132
- ` cloud-dedicated/.env.test ` and ` clustered/.env.test ` files define the
148
+ - Include the usual ` INFLUX_ ` environment variables
149
+ - In
150
+ ` cloud-dedicated/.env.test ` and ` clustered/.env.test ` files, also define the
133
151
following variables:
134
152
135
- - ` ACCOUNT_ID ` , ` CLUSTER_ID ` : You can find these values in your ` influxctl `
136
- ` config.toml ` configuration file.
137
- - ` MANAGEMENT_TOKEN ` : Use the ` influxctl management create ` command to generate
138
- a long-lived management token to authenticate Management API requests
139
-
140
- For the full list of variables you'll need to include, see the substitution
141
- patterns in ` ./test/src/prepare-content.sh ` .
153
+ - ` ACCOUNT_ID ` , ` CLUSTER_ID ` : You can find these values in your ` influxctl `
154
+ ` config.toml ` configuration file.
155
+ - ` MANAGEMENT_TOKEN ` : Use the ` influxctl management create ` command to generate
156
+ a long-lived management token to authenticate Management API requests
142
157
143
- ** Warning** : The database you configure in ` .env.test ` and any written data may
144
- be deleted during test runs.
145
-
146
- ** Warning** : To prevent accidentally adding credentials to the docs-v2 repo,
147
- Git is configured to ignore ` .env* ` files. Don't add your ` .env.test ` files to Git.
148
- Consider backing them up on your local machine in case of accidental deletion.
158
+ See the substitution
159
+ patterns in ` ./test/src/prepare-content.sh ` for the full list of variables you may need to define in your ` .env.test ` files.
149
160
150
- 5 . For influxctl commands to run in tests, move or copy your ` config.toml ` file
161
+ 3 . For influxctl commands to run in tests, move or copy your ` config.toml ` file
151
162
to the ` ./test ` directory.
152
163
153
- ### Pre-commit linting and testing
154
-
155
- When you try to commit your changes using ` git commit ` or your editor,
156
- the project automatically runs pre-commit checks for spelling, punctuation,
157
- and style on your staged files.
158
-
159
- ` .husky/pre-commit ` script runs Git pre-commit hook commands, including
160
- [ ` lint-staged ` ] ( https://github.com/lint-staged/lint-staged ) .
161
-
162
- The ` .lintstagedrc.mjs ` lint-staged configuration maps product-specific glob
163
- patterns to lint and test commands and passes a product-specific
164
- ` .env.test ` file to a test runner Docker container.
165
- The container then loads the ` .env ` file into the container's environment variables.
166
-
167
- To test or troubleshoot testing and linting scripts and configurations before
168
- committing, choose from the following:
169
-
170
- - To run pre-commit scripts without actually committing, append ` exit 1 ` to the
171
- ` .husky/pre-commit ` script--for example:
172
-
173
- ``` sh
174
- ./test/src/monitor-tests.sh start
175
- npx lint-staged --relative
176
- ./test/src/monitor-tests.sh kill
177
- exit 1
178
- ```
179
-
180
- And then run ` git commit ` .
181
-
182
- The ` exit 1 ` status fails the commit, even if all the tasks succeed.
183
-
184
- - Use ` yarn ` to run one of the lint or test scripts configured in
185
- ` package.json ` --for example:
186
-
187
- ``` sh
188
- yarn run test
189
- ```
190
-
191
- - Run ` lint-staged ` directly and specify options:
192
-
193
- ``` sh
194
- npx lint-staged --relative --verbose
195
- ```
196
-
197
- The pre-commit linting configuration checks for _ error-level_ problems.
198
- An error-level rule violation fails the commit and you must do one of the following before you can commit your changes:
199
-
200
- - fix the reported problem in the content
201
-
202
- - edit the linter rules to permanently allow the content.
203
- See ** Configure style rules** .
204
-
205
- - temporarily override the hook (using ` git commit --no-verify ` )
164
+ > [ !Warning]
165
+ >
166
+ > - The database you configure in ` .env.test ` and any written data may
167
+ be deleted during test runs.
168
+ > - Don't add your ` .env.test ` files to Git. To prevent accidentally adding credentials to the docs-v2 repo,
169
+ Git is configured to ignore ` .env* ` files. Consider backing them up on your local machine in case of accidental deletion.
206
170
207
171
#### Test shell and python code blocks
208
172
@@ -249,7 +213,7 @@ You probably don't want to display this syntax in the docs, which unfortunately
249
213
means you'd need to include the test block separately from the displayed code
250
214
block.
251
215
To hide it from users, wrap the code block inside an HTML comment.
252
- Pytest -codeblocks will still collect and run the code block.
216
+ pytest -codeblocks will still collect and run the code block.
253
217
254
218
##### Mark tests to skip
255
219
@@ -546,6 +510,25 @@ Insert warning markdown content here.
546
510
{{% / warn % }}
547
511
```
548
512
513
+ # ## Product data
514
+
515
+ Display the full product name and version name for the current page-- for example:
516
+
517
+ - InfluxDB 3 Core
518
+ - InfluxDB 3 Cloud Dedicated
519
+
520
+ ```md
521
+ {{% product- name % }}
522
+ ```
523
+
524
+ Display the short version name (part of the key used in `products.yml` ) from the current page URL -- for example:
525
+
526
+ - `/ influxdb3/ core` returns `core`
527
+
528
+ ```md
529
+ {{% product- key % }}
530
+ ```
531
+
549
532
# ## Enterprise Content
550
533
551
534
For sections content that relate specifically to InfluxDB Enterprise, use the `{{% enterprise % }}` shortcode.
0 commit comments