Continue refactoring JavaScript into a component pattern and ESM. Replaces some jQuery with native DOM API. chore(ai): reference documentation and instructions for training AI chore(ai): implement Kapa AI chat widget - Move script tag to HTML template to make it obvious. - Cleanup javascript to make it more component-like - Set Kapa attributes, support setting userid chore(js): add JS dependencies, previously referenced in script tags, to package.json for JS builds. fix(api): indents chore(js): package Mermaid diagram library chore(js): refactor JS for AIChat and Theme as examples of using the component pattern for HTML/CSS/JS chore(js): Use the new local-storage API in refactored module code and in code not yet ported. Cleanup syntax in local-storage and make functions available from window.LocalStorageAPI. fix(js): theme.js name-change chore(js): fix ai-chat.js file name fix(js): refactor: - componentNames are snakecase in HTML - replace DOM selection method and jQuery eventhandler assignment - remove old theme.js references chore(ai): configure chat window overlay, size, and position: - removes overlay and scroll lock - positions chat to the right and bottom - expands sample question width to 12 cols chore(ai): edit disclaimer fix(ai): size and position chore(js): make ai-chat specific to configuration and and setting userid (for testing and future use). fix(js): copy referrerHost variable to v3-wayfinding instead of relying on influxdb-url to assign it. chore(ai): add a footer div at page bottom to contain modal triggers for custom-time and ask-ai. Still needs some CSS help. Moves tooltip text from CSS to HTML data attribute. chore(ai): dynamically load AI script tag after DOMContentLoaded to avoid race conditions. Call initialization from the modal trigger module and pass the show trigger function to the onload handler. fix(ai): fix modal triggers to viewport fix(modal-triggers): stack the triggers into a single column. restyle footer widgets updated time selector modal to use correct storage term minor style update WIP(ai-chat): get product data chore(js): Factor out pageContext module from influxdb-url.js chore(js): Refactor helpers.js out of inflluxdb-url.js WIP: refactor influxdburl - minimal changes for module conversions feat(ai): Custom AI chat example questions product and version. Ask AI example questions: - Adds support for customizing example Ask AI questions per product or version. - Configure questions in site `data/products.yml`; otherwise, it uses default questions from `ask-ai.js` Context, page, and product data: - Adds sample URLs for remaining versions in influxdb_urls - `page-context.js` consolidates and exports constants for page context (protocol, host, path, referrer) and path-to-data mappings for product and influxdb_url site data Module refactor: - Refactors some JavaScript into ES6 modules, and refactors some of those further into a Component pattern--just vanilla JS and no shadow DOM stuff. The Component pattern that uses data attributes to "bind" JavaScript modules with CSS and HTML is a popular approach in modern web development. This pattern enhances modularity, reusability, and maintainability by associating behavior (JavaScript), structure (HTML), and style (CSS) through the use of data attributes. - `assets/main.js` is the entrypoint - Passes pageParams from the Hugo page to modules that import `@params`. - Moves most external dependencies out of `script` tags and into package.json to be managed with `yarn`. - Adds `eslint`. - For modules that aren't yet components, wraps execution statements inside an `initialize()` function and calls the function from `main.js` on `DOMContentLoaded`. - For components, if the page contains the `data-component="<component-name>"`, the matching element is passed to the component function on `DOMContentLoaded`. - I tried to avoid changing logic where it wasn't necessary. Update DOC_GPT_PROFILE.md customize ai chat modal styles fix(influxdb-url): Rename to cloud_dedicated in influxdb_urls.yml, remove newly added placeholder URL and use the extant default, refactor - Rename to in influxdb_urls.yml - Fix influxdb-url.js and data provision in local-storage.js to use the new name, mapping it to to retain the existing local storage key chore(api-lib): Use local-storage import instead of window global chore(js): cleanup fix(js): Ensure feature-callout initializes on page load fix(theme): Load preferred theme before making the page visible. Execute a predefined function by specifying the function name in data-theme-callback fix(search-toggle): Restores toggling the search field when sidebar is collapsed. Moves the event handler to a new search-button component fix(ai): Fix custom attribute assignment. Rename property to ai_example_questions Include the word `Bearer` or `Token`, a space, and your **token** value (all case-sensitive). Fix TOC links. Fixes #5781 fix(api-docs): Update API reference directories and generation script for influxdb3 URL paths, update links and names in reference content fix(api-ref): Update getswagger.sh destination paths to use the new directory structure when fetching spec files. Update the redocly plugin module path. hotfix: fix hlevel bug in children shortcode Remove underline from custom time widget add color to custom time widget styling |
||
---|---|---|
.. | ||
influxdb | ||
influxdb3 | ||
openapi/plugins | ||
.config.yml | ||
README.md | ||
generate-api-docs.sh | ||
getswagger.sh | ||
package.json | ||
template.hbs | ||
yarn.lock |
README.md
API reference documentation
TL;DR: validate and test your local influxdata/openapi
changes
-
After you've edited
influxdata/openapi
definitions, you need to generate and validate contracts and test the API reference docs. To create a shell alias that does this, open your~/.profile
in an editor and add the following commands to the file:export DOCS="$HOME/github/docs-v2" alias gsd="cd $HOME/github/openapi && make generate-all && \ npx oats ./contracts/ref/cloud.yml && npx oats ./contracts/ref/oss.yml && \ cd $DOCS/api-docs && ./getswagger.sh all -b file:///$HOME/github/openapi && \ sh ./generate-api-docs.sh"
-
To refresh your environment with the
~/.profile
changes, enter the following command into your terminal:source ~/.profile
-
To run the alias, enter the following command into your terminal:
gsd
gsd
generates the local contracts in ~/github/openapi
, validates them with OATS, bundles and lints them with @redocly/cli
, and then generates the HTML with @redocly/cli
.
Update API docs for InfluxDB Cloud
-
In your
docs-v2
directory, create a branch for your changes--for example:cd ~/github/docs-v2 git fetch -ap git checkout -b release/api-cloud origin/master
-
Enter the following commands into your terminal to fetch and process the contracts:
# In your terminal, go to the `docs-v2/api-docs` directory: cd ./api-docs # Fetch the contracts, apply customizations, and bundle. sh getswagger.sh cloud
-
To generate the HTML files for local testing, follow the instructions to generate API docs locally.
-
To commit your updated spec files, push your branch to
influxdata/docs-v2
, and create a PR against themaster
branch.
Update API docs for an InfluxDB OSS release
-
Go into your local
influxdata/openapi
repo directory--for example:cd ~/github/openapi
-
Get the SHA for the release commit (or consult Team-Edge if you're not sure)--for example, enter the following command into your terminal to get the latest SHA for
contracts/ref/oss.yml
:git log -n 1 --pretty=format:%h -- contracts/ref/oss.yml
-
Copy the SHA from the output and create a git tag by running the following command, replacing
[SEMANTIC_VERSION]
with the OSS release (for example,2.3.0
) andCOMMIT_SHA
with the SHA from step 2:git tag influxdb-oss-v[SEMANTIC_VERSION] COMMIT_SHA
-
Enter the following commands into your terminal to push the new tag to the repo:
git push --tags
-
Enter the following commands into your terminal to update
docs-release/influxdb-oss
branch to the OSS release commit and rebase the branch to the latest release of InfluxDB OSS, replacingOSS_RELEASE_TAG
with the SHA from step 3.git checkout docs-release/influxdb-oss git rebase -i OSS_RELEASE_TAG git push -f origin docs-release/influxdb-oss
-
Go into your
docs-v2
directory and create a branch for your changes--for example:cd ~/github/docs-v2 git fetch -ap git checkout -b release/api-oss origin/master
-
In
./api-docs
, copy the previous version or create a directory for the new OSS version number--for example:# In your terminal, go to the `docs-v2/api-docs` directory: cd ./api-docs
If the old version directory contains custom content files (for example, v2.2/content), you'll likely want to copy those for the new version.
# Copy the old version directory to a directory for the new version: cp -r v2.2 v2.3
-
In your editor, update custom content files in NEW_VERSION/content.
-
Enter the following commands into your terminal to fetch and process the contracts:
# Fetch the contracts, apply customizations, and bundle. sh getswagger.sh oss
-
To generate the HTML files for local testing, follow the instructions to generate API docs locally.
-
To commit your updated spec files, push your branch to
influxdata/docs-v2
, and create a PR against themaster
branch.
Update API docs for OSS spec changes between releases
Follow these steps to update OSS API docs between version releases--for example, after revising description fields in influxdata/openapi
.
-
Go into your local
influxdata/openapi
repo directory--for example:cd ~/github/openapi
-
Enter the following commands into your terminal to checkout
docs-release/influxdb-oss
branch:git fetch -ap git checkout -t docs-release/influxdb-oss
-
Cherry-pick the commits with the updated description fields, and push the commits to the remote branch, replacing
[COMMIT_SHAs]
(one or more commit SHAs (space-separated))--for example:git cherry-pick [COMMIT_SHAs] git push -f origin docs-release/influxdb-oss
-
Go into your
docs-v2
directory and create a branch for your changes--for example:cd ~/github/docs-v2 git fetch -ap git checkout -b docs/api-oss origin/master
-
Go into
./api-docs
directory--for example:# In your terminal, go to the `docs-v2/api-docs` directory: cd ./api-docs
-
Enter the following commands into your terminal to fetch and process the contracts:
# Fetch the contracts, apply customizations, and bundle. sh getswagger.sh oss
-
To generate the HTML files for local testing, follow the instructions to generate API docs locally.
-
To commit your updated spec files, push your branch to
influxdata/docs-v2
, and create a PR against themaster
branch.
Generate InfluxDB API docs
InfluxData uses Redoc, redoc-cli, and Redocly's OpenApi CLI to generate API documentation from the InfluxDB OpenAPI (aka Swagger) contracts.
To minimize the size of the docs-v2
repository, the generated API documentation HTML is gitignored, therefore
not committed to the docs repo.
The InfluxDB docs deployment process uses OpenAPI specification files in the api-docs
directory
to generate version-specific (Cloud, OSS v2.1, OSS v2.0, etc.) API documentation.
Generate API docs locally
Because the API documentation HTML is gitignored, you must manually generate it to view the API docs locally.
The ./generate.sh
script uses the Redoc CLI to generate Redocly HTML, Javascript,
and CSS for each version of the InfluxDB spec.
The script uses npx
to download and execute the Redocly CLI.
-
Verify that you have a working
npx
(it's included with Node.js). In your terminal, run:npx --version
If
npx
returns errors, download and run a recent version of the Node.js installer for your OS. -
To generate API docs for all InfluxDB versions in
./openapi
, enter the following command into your terminal:sh generate-api-docs.sh
To save time testing your spec changes, you can pass the
-c
flag to regenerate HTML for only the OpenAPI files that differ from yourmaster
branch.sh generate-api-docs.sh -c
How we version OpenAPI contracts
The api-docs
directory structure versions OpenAPI files using the following pattern:
api-docs/
|-- cloud/
│ └── ref.yml
│ └── swaggerV1Compat.yml
├── v2.0/
│ └── ref.yml
│ └── swaggerV1Compat.yml
├── v2.1/
│ └── ref.yml
│ └── swaggerV1Compat.yml
├── v2.2/
│ └── ref.yml
│ └── swaggerV1Compat.yml
└── etc...
InfluxDB Cloud version
InfluxDB Cloud releases are frequent and not versioned, so the Cloud API spec isn't versioned.
We regenerate API reference docs from influxdata/openapi
master branch as features are released.
InfluxDB OSS version
Given that
influxdata/openapi
master may contain OSS spec changes not implemented
in the current OSS release, we (Docs team) maintain a release branch, influxdata/openapi
docs-release/influxdb-oss, used to generate OSS reference docs.
How to find the API spec used by an InfluxDB OSS version
influxdata/openapi
does not version the InfluxData API.
To find the influxdata/openapi
commit SHA used in a specific version of InfluxDB OSS,
see /scripts/fetch-swagger.sh
in influxdata/influxdb
--for example,
for the influxdata/openapi
commit used in OSS v2.2.0, see https://github.com/influxdata/influxdb/blob/v2.2.0/scripts/fetch-swagger.sh#L13=.
For convenience, we tag influxdata/influxdb
(OSS) release points in influxdata/openapi
as
influxdb-oss-v[OSS_VERSION]
. See https://github.com/influxdata/openapi/tags.
How to use custom OpenAPI spec processing
Generally, you should manage API content in influxdata/openapi
.
In some cases, however, you may want custom processing (e.g. collecting all Tags)
or additional content (e.g. describing the reference documentation)
specifically for the docs.
When you run getswagger.sh
, it executes @redocly/openapi-cli
and the plugins listed in .redocly.yaml
.
./openapi/plugins
use
./openapi/plugins/decorators
to apply custom
processing to OpenAPI specs.
.yml
files in ./PLATFORM/content
define custom content for OpenAPI nodes published in the reference docs.
To update the content for those nodes, you only need to update the YAML files.
For example, to customize the Info section for the Cloud API reference, edit ./cloud/content/info.yml
.
To add new YAML files for other nodes in the contracts, follow these steps:
- Create your new content file with valid OAS content structure and Markdown.
- Configure the new content YAML file in
./openapi/content/content.js
. - Write or update a decorator module for the node and configure the decorator in
./openapi/plugins/docs-plugin.js
. See the complete list of OAS v3.0 nodes.
@redocly/cli
requires that modules use CommonJS require
syntax for imports.
@redocly/cli
also provides some built-in decorators
that you can configure in .redocly
without having to write JavaScript.
How to add tag content or describe a group of paths
In API reference docs, we use OpenAPI tags
elements for navigation,
the x-traitTag
vendor extension for providing custom content, and the x-tagGroups
vendor extension
for grouping tags in navigation.
Example | OpenAPI field | |
---|---|---|
Add supplementary documentation | tags: [ { name: 'Quick start', x-traitTag: true } ] |
Source |
Group tags in navigation | x-tagGroups: [ { name: 'All endpoints', tags: [...], ...} ] |
Source) |
Add and update x-tagGroups
Custom x-tagGroups
configured in
PLATFORM/content/tag-groups.yml
override x-tagGroups
defined in influxdata/openapi
.
If you assign a list of tags to the All endpoints
tag group,
the decorator applies your list and removes Operations that don't contain
those tags.
If you assign an empty array([]
) to the All endpoints
x-tagGroup in PLATFORM/content/tag-groups.yml
,
the decorator replaces the empty array with the list of tags from all Operations in the spec.
How to test your spec or API reference changes
You can use getswagger.sh
to fetch contracts from any URL.
For example, if you've made changes to spec files and generated new contracts in your local openapi
repo, run getswagger.sh
to fetch and process them.
To fetch contracts from your own openapi
repo, pass the
-b
base_url
option and the full path to your openapi
directory.
# Use the file:/// protocol to pass your openapi directory.
sh getswagger.sh oss -b file:///Users/me/github/openapi
After you fetch them, run the linter or generate HTML to test your changes before you commit them to influxdata/openapi
.
By default, getswagger.sh
doesn't run the linter when bundling
the specs.
Manually run the linter rules to get a report of errors and warnings.
npx @redocly/openapi-cli lint v2.1/ref.yml
Configure OpenAPI CLI linting and bundling
The .redoc.yaml
configuration file sets options for the @redocly/openapi-cli
lint
and bundle
commands.
./openapi/plugins
contains custom InfluxData Docs plugins composed of rules (for validating and linting) and decorators (for customizing). For more configuration options, see @redocly/openapi-cli
configuration file documentation.