diff --git a/.github/workflows/generate-docs.yaml b/.github/workflows/generate-docs.yaml index 2189b3e758..680bedd4ed 100644 --- a/.github/workflows/generate-docs.yaml +++ b/.github/workflows/generate-docs.yaml @@ -7,24 +7,27 @@ on: paths: - website/** + workflow_dispatch: + schedule: + - cron: '@daily' + jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: setup git config - run: | - git config --global user.name "${GH_NAME}" - git config --global user.email "${GH_EMAIL}" - echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc - # Stage the file, commit and push - cd website && yarn && GIT_USER="ivarconr" yarn deploy - env: - GH_NAME: 'ivarconr' - GH_EMAIL: 'ivarconr@gmail.com' - GH_TOKEN: ${{ secrets.GH_TOKEN }} - DEPLOYMENT_BRANCH: 'main' - UNLEASH_FEEDBACK_TARGET_URL: ${{ secrets.DOCS_FEEDBACK_TARGET_URL }} - UNLEASH_PROXY_CLIENT_KEY: ${{ secrets.UNLEASH_PROXY_CLIENT_KEY_PRODUCTION }} - UNLEASH_PROXY_URL: ${{ secrets.UNLEASH_PROXY_URL_PRODUCTION }} + - uses: actions/checkout@v3 + - name: setup git config + run: | + git config --global user.name "${GH_NAME}" + git config --global user.email "${GH_EMAIL}" + echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc + # Stage the file, commit and push + cd website && yarn && GIT_USER="ivarconr" yarn deploy + env: + GH_NAME: 'ivarconr' + GH_EMAIL: 'ivarconr@gmail.com' + GH_TOKEN: ${{ secrets.GH_TOKEN }} + DEPLOYMENT_BRANCH: 'main' + UNLEASH_FEEDBACK_TARGET_URL: ${{ secrets.DOCS_FEEDBACK_TARGET_URL }} + UNLEASH_PROXY_CLIENT_KEY: ${{ secrets.UNLEASH_PROXY_CLIENT_KEY_PRODUCTION }} + UNLEASH_PROXY_URL: ${{ secrets.UNLEASH_PROXY_URL_PRODUCTION }} diff --git a/website/.gitignore b/website/.gitignore index b2d6de3062..9acb5a54d8 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -18,3 +18,8 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# OpenAPI docusaurus generated stuff +docs/reference/apis/**/sidebar.js +*.api.mdx +*.tag.mdx diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index ff3e614847..bf5d7f2f34 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -190,28 +190,26 @@ module.exports = { }, }, ], - // NOTE: activate this when we sort out the enterprise / open - // source API situation - // - // [ - // 'docusaurus-plugin-openapi-docs', - // { - // id: 'api-operations', - // docsPluginId: 'classic', - // config: { - // server: { - // specPath: process.env.NODE_ENV === 'development' ? - // 'http://localhost:4242/docs/openapi.json' - // : './openapi-spec.generated.json', - // outputDir: 'docs/reference/apis/unleash', - // sidebarOptions: { - // groupPathsBy: 'tag', - // categoryLinkSource: 'tag', - // }, - // }, - // }, - // }, - // ], + [ + 'docusaurus-plugin-openapi-docs', + { + id: 'api-operations', + docsPluginId: 'classic', + config: { + server: { + specPath: + process.env.NODE_ENV === 'development' + ? 'http://localhost:4242/docs/openapi.json' + : 'https://us.app.unleash-hosted.com/ushosted/docs/openapi.json', + outputDir: 'docs/reference/api/unleash', + sidebarOptions: { + groupPathsBy: 'tag', + categoryLinkSource: 'tag', + }, + }, + }, + }, + ], ], themes: ['docusaurus-theme-openapi-docs'], // Allows use of @theme/ApiItem and other components }; diff --git a/website/package.json b/website/package.json index 40098dc1a0..b02d9c71e5 100644 --- a/website/package.json +++ b/website/package.json @@ -8,8 +8,9 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start", - "build": "docusaurus build", + "build": "docusaurus gen-api-docs all && docusaurus build", "swizzle": "docusaurus swizzle", + "generate": "docusaurus gen-api-docs all", "deploy": "docusaurus deploy", "clear": "docusaurus clear", "serve": "docusaurus serve", diff --git a/website/sidebars.js b/website/sidebars.js index 5e656d9da0..09ae9fd72a 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -173,21 +173,19 @@ module.exports = { 'api/internal/health', ], }, - // NOTE: activate this when we're ready to integrate generated OpenAPI docs - // - // { - // label: 'OpenAPI docs', - // collapsed: true, - // type: 'category', - // link: { - // title: 'Unleash Server APIs', - // type: 'generated-index', - // description: - // 'Generated API docs based on the Unleash OpenAPI schema. For the time being, some additional info can also be found in the older API docs.', - // slug: '/reference/apis/unleash', - // }, - // items: require('./docs/reference/apis/unleash/sidebar.js'), - // }, + { + label: 'OpenAPI docs', + collapsed: true, + type: 'category', + link: { + title: 'Unleash Server APIs', + type: 'generated-index', + description: + 'Generated API docs based on the Unleash OpenAPI schema. For the time being, some additional info can also be found in the older API docs.', + slug: '/reference/api/unleash', + }, + items: require('./docs/reference/api/unleash/sidebar.js'), + }, ], }, { diff --git a/website/src/css/custom.css b/website/src/css/custom.css index 4a96be6be2..302c7e5bbb 100644 --- a/website/src/css/custom.css +++ b/website/src/css/custom.css @@ -171,7 +171,7 @@ html[data-theme='dark'] .header-github-link:before { /* docusaurus-plugin-openapi-docs styling Taken from -https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/demo/src/css/custom.css#L45 +https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/02922a6ad6d635373e01409dac8c17a88da2b72e/demo/src/css/custom.css#L45-L9 Based on this thread: https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/177 @@ -193,39 +193,50 @@ https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/177 font-weight: 600; border-radius: 0.25rem; border: 1px solid; + border-inline-start-width: 5px; margin-right: var(--ifm-spacing-horizontal); text-align: center; flex-shrink: 0; - border-color: transparent; - color: white; } .get > .menu__link::before { content: 'get'; - background-color: var(--openapi-code-blue); + background-color: var(--ifm-color-info-contrast-background); + color: var(--ifm-color-info-contrast-foreground); + border-color: var(--ifm-color-info-dark); } .post > .menu__link::before { content: 'post'; - background-color: var(--openapi-code-green); + background-color: var(--ifm-color-success-contrast-background); + color: var(--ifm-color-success-contrast-foreground); + border-color: var(--ifm-color-success-dark); } .delete > .menu__link::before { content: 'del'; - background-color: var(--openapi-code-red); + background-color: var(--ifm-color-danger-contrast-background); + color: var(--ifm-color-danger-contrast-foreground); + border-color: var(--ifm-color-danger-dark); } .put > .menu__link::before { content: 'put'; - background-color: var(--openapi-code-orange); + background-color: var(--ifm-color-warning-contrast-background); + color: var(--ifm-color-warning-contrast-foreground); + border-color: var(--ifm-color-warning-dark); } .patch > .menu__link::before { content: 'patch'; - background-color: var(--openapi-code-green); + background-color: var(--ifm-color-success-contrast-background); + color: var(--ifm-color-success-contrast-foreground); + border-color: var(--ifm-color-success-dark); } .head > .menu__link::before { content: 'head'; - background-color: var(--ifm-color-secondary-darkest); + background-color: var(--ifm-color-secondary-contrast-background); + color: var(--ifm-color-secondary-contrast-foreground); + border-color: var(--ifm-color-secondary-dark); }