diff --git a/.circleci/config.yml b/.circleci/config.yml index ffd410c2d..c02b6b06b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,7 +23,10 @@ jobs: command: ./deploy/ci-install-s3deploy.sh - run: name: Install NPM dependencies - command: sudo npm i -g postcss-cli autoprefixer + command: sudo npm i -g postcss-cli autoprefixer redoc-cli + - run: + name: Generate API documentation + command: cd api-docs && sh generate-api-docs.sh - save_cache: key: install-v1-{{ checksum ".circleci/config.yml" }} paths: diff --git a/.gitignore b/.gitignore index 07f198c85..b69d13c23 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ public node_modules *.log /resources +/content/**/api.html diff --git a/api-docs/generate-api-docs.sh b/api-docs/generate-api-docs.sh new file mode 100644 index 000000000..a9419c248 --- /dev/null +++ b/api-docs/generate-api-docs.sh @@ -0,0 +1,40 @@ +#!/bin/bash -e + +# Get list of versions from directory names +versions="$(ls -d -- */)" + +for version in $versions +do + # Trim the trailing slash off the directory name + version="${version%/}" + menu="${version//./_}_ref" + + # Generate the frontmatter + frontmatter="--- +title: InfluxDB $version API documentation +description: > + The InfluxDB API provides a programmatic interface for interactions with InfluxDB $version. +layout: api +menu: + $menu: + parent: InfluxDB v2 API + name: View full API docs +weight: 102 +--- +" + + # Use Redoc to generate the API html + redoc-cli bundle -t template.hbs \ + --title="InfluxDB $version API documentation" \ + --options.sortPropsAlphabetically \ + --options.menuToggle \ + --options.hideHostname \ + --templateOptions.version="$version" \ + $version/swagger.yml + + # Create temp file with frontmatter and Redoc html + echo "$frontmatter" >> $version.tmp + cat redoc-static.html >> $version.tmp + rm -f redoc-static.html + mv $version.tmp ../content/$version/api.html +done diff --git a/api-docs/template.hbs b/api-docs/template.hbs index 5b8c294b8..b63535da2 100644 --- a/api-docs/template.hbs +++ b/api-docs/template.hbs @@ -7,6 +7,16 @@ + + + + + {{#unless disableGoogleFont}}{{/unless}} {{{redocHead}}} +
+