Skip to content

Commit f1d82f4

Browse files
committed
fix(api-docs): Update API reference directories and generation script for influxdb3 URL paths, update links and names in reference content
1 parent 5e9560d commit f1d82f4

File tree

47 files changed

+9862
-597
lines changed

Some content is hidden

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

47 files changed

+9862
-597
lines changed

api-docs/cloud-dedicated/management/content/info.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

api-docs/generate-api-docs.sh

Lines changed: 77 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,30 @@ while getopts "hc" opt; do
3636
done
3737

3838
function generateHtml {
39-
specPath="$1"
40-
product="$2"
41-
productName="$3"
42-
api="$4"
43-
configPath="$5"
44-
isDefault=$6
39+
local specPath="$1"
40+
local productVersion="$2"
41+
local productName="$3"
42+
local api="$4"
43+
local configPath="$5"
44+
local isDefault=$6
4545

4646
# Use the product name to define the menu for the Hugo template
47-
menu="influxdb_$(echo $product | sed 's/\./_/g;s/-/_/g;')"
47+
local menu="$(echo $productVersion | sed 's/\./_/g;s/-/_/g;s/\//_/g;')"
48+
# Short version name (for old aliases)
49+
# Everything after the last slash
50+
local versionDir=$(echo $productVersion | sed 's/.*\///g;')
4851
# Extract the API name--for example, "management" from "management@v2".
49-
apiName=$(echo $api | sed 's/@.*//g;')
52+
local apiName=$(echo $api | sed 's/@.*//g;')
5053
# Extract the API version--for example, "v0" from "management@v0".
51-
version=$(echo $api | sed 's/.*@//g;')
54+
local apiVersion=$(echo $api | sed 's/.*@//g;')
5255
# Use the title and summary defined in the product API's info.yml file.
53-
title=$(yq '.title' $product/$apiName/content/info.yml)
54-
menuTitle=$(yq '.x-influxdata-short-title' $product/$apiName/content/info.yml)
55-
description=$(yq '.summary' $product/$apiName/content/info.yml)
56+
local title=$(yq '.title' $productVersion/$apiName/content/info.yml)
57+
local menuTitle=$(yq '.x-influxdata-short-title' $productVersion/$apiName/content/info.yml)
58+
local description=$(yq '.summary' $productVersion/$apiName/content/info.yml)
5659
# Define the file name for the Redoc HTML output.
57-
specbundle=redoc-static_index.html
60+
local specbundle=redoc-static_index.html
5861
# Define the temporary file for the Hugo template and Redoc HTML.
59-
tmpfile="${product}-${api}_index.tmp"
62+
local tmpfile="${productVersion}-${api}_index.tmp"
6063

6164
echo "Bundling $specPath"
6265

@@ -75,7 +78,7 @@ function generateHtml {
7578
--options.noAutoAuth \
7679
--output=$specbundle \
7780
--templateOptions.description=$description \
78-
--templateOptions.product="$product" \
81+
--templateOptions.product="$productVersion" \
7982
--templateOptions.productName="$productName"
8083

8184
if [[ $apiName == "v1-compatibility" ]]; then
@@ -90,10 +93,10 @@ menu:
9093
identifier: api-reference-$apiName
9194
weight: 304
9295
aliases:
93-
- /influxdb/$product/api/v1/
96+
- /influxdb/$versionDir/api/v1/
9497
---
9598
"
96-
elif [[ $version == "0" ]]; then
99+
elif [[ $apiVersion == "0" ]]; then
97100
echo $productName $apiName
98101
frontmatter="---
99102
title: $title
@@ -119,7 +122,7 @@ menu:
119122
identifier: api-reference-$apiName
120123
weight: 102
121124
aliases:
122-
- /influxdb/$product/api/
125+
- /influxdb/$versionDir/api/
123126
---
124127
"
125128
else
@@ -152,68 +155,74 @@ weight: 102
152155
rm -f $specbundle
153156
# Create the directory and move the file.
154157
if [ ! -z "$apiName" ]; then
155-
mkdir -p ../content/influxdb/$product/api/$apiName
156-
mv $tmpfile ../content/influxdb/$product/api/$apiName/_index.html
158+
mkdir -p ../content/$productVersion/api/$apiName
159+
mv $tmpfile ../content/$productVersion/api/$apiName/_index.html
157160
else
158-
mkdir -p ../content/influxdb/$product/api
159-
mv $tmpfile ../content/influxdb/$product/api/_index.html
161+
mkdir -p ../content/$productVersion/api
162+
mv $tmpfile ../content/$productVersion/api/_index.html
160163
fi
161164
}
162165

163166
# Use a combination of directory names and configuration files to build the API documentation.
164167
# Each directory represents a product, and each product directory contains a configuration file that defines APIs and their spec file locations.
165168
function build {
166-
# Get the list of products from directory names
167-
products="$(ls -d -- */ | grep -v 'node_modules' | grep -v 'openapi')"
168-
169-
for product in $products; do
170-
#Trim the trailing slash off the directory name
171-
product="${product%/}"
172-
# Get the product API configuration file.
173-
configPath="$product/.config.yml"
174-
if [ ! -f $configPath ]; then
175-
configPath=".config.yml"
176-
fi
177-
echo "Checking product config $configPath"
178-
# Get the product name from the configuration.
179-
productName=$(yq e '.x-influxdata-product-name' $configPath)
180-
if [[ -z "$productName" ]]; then
181-
productName=InfluxDB
182-
fi
183-
# Get an array of product API names (keys) from the configuration file
184-
apis=$(yq e '.apis | keys | .[]' $configPath)
185-
# Read each element of the apis array
186-
while IFS= read -r api; do
187-
# Get the spec file path from the configuration.
188-
specRootPath=$(yq e ".apis | .$api | .root" $configPath)
189-
# Check that the YAML spec file exists.
190-
specPath="$product/$specRootPath"
191-
echo "Checking for spec $specPath"
192-
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
193-
echo "OpenAPI spec $specPath doesn't exist."
169+
local versions
170+
versions="$(ls -d -- */* | grep -v 'node_modules' | grep -v 'openapi')"
171+
for version in $versions; do
172+
# Trim the trailing slash off the directory name
173+
local version="${version%/}"
174+
# Get the version API configuration file.
175+
local configPath="$version/.config.yml"
176+
if [ ! -f "$configPath" ]; then
177+
configPath=".config.yml"
194178
fi
195-
# Get default status from the configuration.
196-
isDefault=false
197-
defaultStatus=$(yq e ".apis | .$api | .x-influxdata-default" $configPath)
198-
if [[ $defaultStatus == "true" ]]; then
199-
isDefault=true
179+
echo "Using config $configPath"
180+
# Get the product name from the configuration.
181+
local versionName
182+
versionName=$(yq e '.x-influxdata-product-name' "$configPath")
183+
if [[ -z "$versionName" ]]; then
184+
versionName=InfluxDB
200185
fi
186+
# Get an array of API names (keys) from the configuration file
187+
local apis
188+
apis=$(yq e '.apis | keys | .[]' "$configPath")
189+
# Read each element of the apis array
190+
while IFS= read -r api; do
191+
echo "======Building $version $api======"
192+
# Get the spec file path from the configuration.
193+
local specRootPath
194+
specRootPath=$(yq e ".apis | .$api | .root" "$configPath")
195+
# Check that the YAML spec file exists.
196+
local specPath
197+
specPath="$version/$specRootPath"
198+
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
199+
echo "OpenAPI spec $specPath doesn't exist."
200+
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
201208

202-
# If the spec file differs from master, regenerate the HTML.
203-
update=0
204-
if [[ $generate_changed == 0 ]]; then
205-
diff=$(git diff --name-status master -- ${specPath})
206-
if [[ -z "$diff" ]]; then
207-
update=1
209+
# If the spec file differs from master, regenerate the HTML.
210+
local update=0
211+
if [[ $generate_changed == 0 ]]; then
212+
local diff
213+
diff=$(git diff --name-status master -- "${specPath}")
214+
if [[ -z "$diff" ]]; then
215+
update=1
216+
fi
208217
fi
209-
fi
210218

211-
if [[ $update -eq 0 ]]; then
212-
echo "Regenerating $product $api"
213-
generateHtml "$specPath" "$product" "$productName" "$api" "$configPath" $isDefault
214-
fi
215-
done <<< "$apis"
216-
done
219+
if [[ $update -eq 0 ]]; then
220+
echo "Regenerating $version $api"
221+
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath" "$isDefault"
222+
fi
223+
echo "========Done with $version $api========"
224+
done <<< "$apis"
225+
done
217226
}
218227

219228
build
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)