Skip to content

Commit 0054a9b

Browse files
authored
Merge branch 'master' into plugin_error_handling
2 parents e432bb8 + d6444ac commit 0054a9b

File tree

127 files changed

+5608
-10360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+5608
-10360
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extends: substitution
2+
message: Did you mean '%s' instead of '%s'
3+
level: warning
4+
ignorecase: false
5+
# swap maps tokens in form of bad: good
6+
# NOTE: The left-hand (bad) side can match the right-hand (good) side;
7+
# Vale ignores alerts that match the intended form.
8+
swap:
9+
'cloud-serverless|cloud-dedicated|clustered': core
10+
'Cloud Serverless|Cloud Dedicated|Clustered': Core
11+
'API token': database token
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extends: substitution
2+
message: Did you mean '%s' instead of '%s'
3+
level: warning
4+
ignorecase: false
5+
# swap maps tokens in form of bad: good
6+
# NOTE: The left-hand (bad) side can match the right-hand (good) side;
7+
# Vale ignores alerts that match the intended form.
8+
swap:
9+
'(?i)bucket': database
10+
'(?i)measurement': table

.frontmatter-schema.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"title": {
6+
"type": "string",
7+
"description": "Title of the page"
8+
},
9+
"description": {
10+
"type": "string",
11+
"description": "Page description that supports multi-line text"
12+
},
13+
"menu": {
14+
"type": "object",
15+
"properties": {
16+
"influxdb3_core": {
17+
"type": "object",
18+
"properties": {
19+
"name": {
20+
"type": "string",
21+
"description": "Menu item name"
22+
}
23+
},
24+
"required": ["name"]
25+
}
26+
}
27+
},
28+
"weight": {
29+
"type": "integer",
30+
"description": "Order weight for menu items",
31+
"minimum": 0
32+
},
33+
"source": {
34+
"type": "string",
35+
"description": "Path to source content file",
36+
"pattern": "^/shared/.+\\.md$"
37+
}
38+
},
39+
"required": ["title", "description", "menu", "weight"]
40+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node_modules
88
*.log
99
/resources
1010
.hugo_build.lock
11-
/content/influxdb/*/api/**/*.html
11+
/content/influxdb*/**/api/**/*.html
1212
/api-docs/redoc-static.html*
1313
.vscode/*
1414
.idea

.vscode/settings.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
{
2-
"vale.valeCLI.config": " \"${workspaceFolder}/.vale.ini\"",
2+
"commentAnchors.tags.anchors":
3+
{ "SOURCE": {
4+
"scope": "file",
5+
"behavior": "link",
6+
"iconColor": "#FF0000",
7+
"highlightColor": "#FF0000",
8+
"style": "bold"
9+
}},
10+
"commentAnchors.workspace.matchFiles": "**/*.{md,ini,json,yaml,yml}",
11+
"commentAnchors.workspace.enabled": true,
12+
"yaml.schemas": {
13+
"./.frontmatter-schema.json": "${workspaceFolder}/content/**/*.md"
14+
},
15+
"vale.valeCLI.config": "${workspaceFolder}/.vale.ini",
316
"vale.valeCLI.minAlertLevel": "warning",
417
}

CONTRIBUTING.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ To install dependencies listed in package.json:
4646
4. Install the Yarn package manager and run `yarn` to install project dependencies.
4747

4848
`package.json` contains dependencies for linting and running Git hooks.
49+
docs-v2 uses [Lefthook](https://github.com/evilmartians/lefthook) to configure and manage pre-commit hooks for linting and testing Markdown content.
50+
51+
Other dependencies used in the project:
4952

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
5253
- **[prettier](https://prettier.io/docs/en/)**: formats code, including Markdown, according to style rules for consistency
5354

5455
### Install Docker
@@ -65,13 +66,24 @@ The tests defined in `compose.yaml` use the dependencies and execution
6566
environment from this image.
6667

6768
```bash
68-
docker build -t influxdata:docs-pytest -f Dockerfile.pytest .
69+
docker build -t influxdata/docs-pytest:latest -f Dockerfile.pytest .
6970
```
7071

7172
### Run the documentation locally (optional)
7273

7374
To run the documentation locally, follow the instructions provided in the README.
7475

76+
### Install Visual Studio Code extensions
77+
78+
If you use Microsoft Visual Studio (VS) Code, you can install extensions
79+
to help you navigate, check, and edit files.
80+
81+
docs-v2 contains a `./.vscode/settings.json` that configures the following extensions:
82+
83+
- Comment Anchors: recognizes tags (for example, `//SOURCE`) and makes links and filepaths clickable in comments.
84+
- Vale: shows linter errors and suggestions in the editor.
85+
- YAML Schemas: validates frontmatter attributes.
86+
7587
### Make your changes
7688

7789
Make your suggested changes being sure to follow the [style and formatting guidelines](#style--formatting) outline below.
@@ -80,27 +92,25 @@ Make your suggested changes being sure to follow the [style and formatting guide
8092

8193
### Automatic pre-commit checks
8294

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.
95+
docs-v2 uses Lefthook to manage Git hooks, such as pre-commit hooks that lint Markdown and test code blocks.
96+
When you try to commit changes (`git commit`), Git runs
97+
the commands configured in `lefthook.yml` which pass your **staged** files to Vale, Prettier, and Pytest (in a Docker container).
8698

8799
### Skip pre-commit hooks
88100

89101
**We strongly recommend running linting and tests**, but you can skip them
90102
(and avoid installing dependencies)
91-
by including the `HUSKY=0` environment variable or the `--no-verify` flag with
103+
by including the `LEFTHOOK=0` environment variable or the `--no-verify` flag with
92104
your commit--for example:
93105

94106
```sh
95107
git commit -m "<COMMIT_MESSAGE>" --no-verify
96108
```
97109

98110
```sh
99-
HUSKY=0 git commit
111+
LEFTHOOK=0 git commit
100112
```
101113

102-
For more options, see the [Husky documentation](https://typicode.github.io/husky/how-to.html#skipping-git-hooks).
103-
104114
### Set up test scripts and credentials
105115

106116
To set up your docs-v2 instance to run tests locally, do the following:

Dockerfile.pytest

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
3232
python3-venv \
3333
rsync \
3434
telegraf \
35-
wget
35+
wget \
36+
yq
37+
38+
# Install InfluxDB 3 Core
39+
RUN curl -O https://www.influxdata.com/d/install_influxdb3.sh \
40+
&& chmod +x install_influxdb3.sh \
41+
&& bash -c yes | ./install_influxdb3.sh
3642

3743
RUN ln -s /usr/bin/python3 /usr/bin/python
3844

api-docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ InfluxDB Cloud releases are frequent and not versioned, so the Cloud API spec is
237237
We regenerate API reference docs from `influxdata/openapi`
238238
**master** branch as features are released.
239239
240-
### InfluxDB OSS version
240+
### InfluxDB OSS v2 version
241241
242242
Given that
243243
`influxdata/openapi` **master** may contain OSS spec changes not implemented

api-docs/generate-api-docs.sh

Lines changed: 33 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function generateHtml {
4141
local productName="$3"
4242
local api="$4"
4343
local configPath="$5"
44-
local isDefault=$6
4544

4645
# Use the product name to define the menu for the Hugo template
4746
local menu="$(echo $productVersion | sed 's/\./_/g;s/-/_/g;s/\//_/g;')"
@@ -55,12 +54,23 @@ function generateHtml {
5554
# Use the title and summary defined in the product API's info.yml file.
5655
local title=$(yq '.title' $productVersion/$apiName/content/info.yml)
5756
local menuTitle=$(yq '.x-influxdata-short-title' $productVersion/$apiName/content/info.yml)
58-
local description=$(yq '.summary' $productVersion/$apiName/content/info.yml)
57+
# Get the shortened description to use for metadata.
58+
local shortDescription=$(yq '.x-influxdata-short-description' $productVersion/$apiName/content/info.yml)
59+
# Get the aliases array from the configuration file.
60+
local aliases=$(yq e ".apis | .$api | .x-influxdata-docs-aliases" "$configPath")
61+
# If aliases is null, set it to an empty YAML array.
62+
if [[ "$aliases" == "null" ]]; then
63+
aliases='[]'
64+
fi
65+
local weight=102
66+
if [[ $apiName == "v1-compatibility" ]]; then
67+
weight=304
68+
fi
5969
# Define the file name for the Redoc HTML output.
6070
local specbundle=redoc-static_index.html
6171
# Define the temporary file for the Hugo template and Redoc HTML.
6272
local tmpfile="${productVersion}-${api}_index.tmp"
63-
73+
6474
echo "Bundling $specPath"
6575

6676
# Use npx to install and run the specified version of redoc-cli.
@@ -70,75 +80,31 @@ function generateHtml {
7080
npm_config_yes=true npx redoc-cli@0.12.3 bundle $specPath \
7181
--config $configPath \
7282
-t template.hbs \
73-
--title=$title \
83+
--title="$title" \
7484
--options.sortPropsAlphabetically \
7585
--options.menuToggle \
7686
--options.hideDownloadButton \
7787
--options.hideHostname \
7888
--options.noAutoAuth \
7989
--output=$specbundle \
80-
--templateOptions.description=$description \
90+
--templateOptions.description="$shortDescription" \
8191
--templateOptions.product="$productVersion" \
8292
--templateOptions.productName="$productName"
8393

84-
if [[ $apiName == "v1-compatibility" ]]; then
85-
frontmatter="---
86-
title: $title
87-
description: $description
88-
layout: api
89-
menu:
90-
$menu:
91-
parent: InfluxDB HTTP API
92-
name: $menuTitle
93-
identifier: api-reference-$apiName
94-
weight: 304
95-
aliases:
96-
- /influxdb/$versionDir/api/v1/
97-
---
98-
"
99-
elif [[ $apiVersion == "0" ]]; then
100-
echo $productName $apiName
101-
frontmatter="---
102-
title: $title
103-
description: $description
104-
layout: api
105-
weight: 102
106-
menu:
107-
$menu:
108-
parent: InfluxDB HTTP API
109-
name: $menuTitle
110-
identifier: api-reference-$apiName
94+
local frontmatter=$(yq eval -n \
95+
".title = \"$title\" |
96+
.description = \"$shortDescription\" |
97+
.layout = \"api\" |
98+
.weight = $weight |
99+
.menu.[\"$menu\"].parent = \"InfluxDB HTTP API\" |
100+
.menu.[\"$menu\"].name = \"$menuTitle\" |
101+
.menu.[\"$menu\"].identifier = \"api-reference-$apiName\" |
102+
.aliases = \"$aliases\"")
103+
104+
frontmatter="---
105+
$frontmatter
111106
---
112107
"
113-
elif [[ $isDefault == true ]]; then
114-
frontmatter="---
115-
title: $title
116-
description: $description
117-
layout: api
118-
menu:
119-
$menu:
120-
parent: InfluxDB HTTP API
121-
name: $menuTitle
122-
identifier: api-reference-$apiName
123-
weight: 102
124-
aliases:
125-
- /influxdb/$versionDir/api/
126-
---
127-
"
128-
else
129-
frontmatter="---
130-
title: $title
131-
description: $description
132-
layout: api
133-
menu:
134-
$menu:
135-
parent: InfluxDB HTTP API
136-
name: $menuTitle
137-
identifier: api-reference-$apiName
138-
weight: 102
139-
---
140-
"
141-
fi
142108

143109
# Create the Hugo template file with the frontmatter and Redoc HTML
144110
echo "$frontmatter" >> $tmpfile
@@ -174,9 +140,10 @@ function build {
174140
# Get the version API configuration file.
175141
local configPath="$version/.config.yml"
176142
if [ ! -f "$configPath" ]; then
177-
configPath=".config.yml"
143+
# Skip to the next version if the configuration file doesn't exist.
144+
continue
178145
fi
179-
echo "Using config $configPath"
146+
echo "Using config $version $configPath"
180147
# Get the product name from the configuration.
181148
local versionName
182149
versionName=$(yq e '.x-influxdata-product-name' "$configPath")
@@ -198,13 +165,7 @@ function build {
198165
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
199166
echo "OpenAPI spec $specPath doesn't exist."
200167
fi
201-
# Get default status from the configuration.
202-
local isDefault=false
203-
local defaultStatus
204-
defaultStatus=$(yq e ".apis | .$api | .x-influxdata-default" "$configPath")
205-
if [[ $defaultStatus == "true" ]]; then
206-
isDefault=true
207-
fi
168+
208169

209170
# If the spec file differs from master, regenerate the HTML.
210171
local update=0
@@ -218,9 +179,9 @@ function build {
218179

219180
if [[ $update -eq 0 ]]; then
220181
echo "Regenerating $version $api"
221-
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath" "$isDefault"
182+
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath"
222183
fi
223-
echo "========Done with $version $api========"
184+
echo -e "========Finished $version $api========\n\n"
224185
done <<< "$apis"
225186
done
226187
}

0 commit comments

Comments
 (0)