From 2cf69bb5b1894d64ddcbd3e4b4e28e652cd3fcc4 Mon Sep 17 00:00:00 2001 From: Mykola Fant Date: Mon, 13 Jan 2025 16:55:04 +0200 Subject: [PATCH] DOC-305: orphan pages detector (#428) Implements https://hazelcast.atlassian.net/browse/DOC-305 Please note, we probably can close https://hazelcast.atlassian.net/browse/DOC-304 if this implementation is OK --- .github/workflows/validate.yml | 4 +- antora-playbook-local.yml | 4 +- antora-playbook.yml | 4 +- .../modules/getting-started/partials/nav.adoc | 2 +- lib/swagger-ui-block-macro.js | 20 ----- lib/tabs-block.js | 80 ------------------- package-lock.json | 15 ++++ package.json | 4 +- 8 files changed, 25 insertions(+), 108 deletions(-) delete mode 100644 lib/swagger-ui-block-macro.js delete mode 100644 lib/tabs-block.js diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 917cfa66..c71c706a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,4 +1,4 @@ -name: Check for dead links +name: Docs validation on: pull_request: @@ -13,5 +13,5 @@ jobs: steps: - name: Checkout Current Repo uses: actions/checkout@v4 - - name: Check dead links + - name: Validate Docs uses: hazelcast/hazelcast-docs/.github/actions/validate@main diff --git a/antora-playbook-local.yml b/antora-playbook-local.yml index 217d65fe..ddc9cf13 100644 --- a/antora-playbook-local.yml +++ b/antora-playbook-local.yml @@ -36,5 +36,5 @@ asciidoc: docs-archive: 'https://hazelcast.org/imdg/download/archives/' hazelcast-cloud: Cloud extensions: - - ./lib/tabs-block.js - - ./lib/swagger-ui-block-macro.js + - ./node_modules/hazelcast-docs-tools/antora-macro/tabs-block.js + - ./node_modules/hazelcast-docs-tools/antora-macro/swagger-ui-block-macro.js diff --git a/antora-playbook.yml b/antora-playbook.yml index 9c94a45c..d593ae6e 100644 --- a/antora-playbook.yml +++ b/antora-playbook.yml @@ -35,5 +35,5 @@ asciidoc: docs-archive: 'https://hazelcast.org/imdg/download/archives/' hazelcast-cloud: Cloud extensions: - - ./lib/tabs-block.js - - ./lib/swagger-ui-block-macro.js + - ./node_modules/hazelcast-docs-tools/antora-macro/tabs-block.js + - ./node_modules/hazelcast-docs-tools/antora-macro/swagger-ui-block-macro.js diff --git a/docs/modules/getting-started/partials/nav.adoc b/docs/modules/getting-started/partials/nav.adoc index 75d2c922..3502220e 100644 --- a/docs/modules/getting-started/partials/nav.adoc +++ b/docs/modules/getting-started/partials/nav.adoc @@ -6,4 +6,4 @@ ** User Interface Overview *** xref:getting-started:user-interface.adoc[Top Bar and Side Bar] *** xref:getting-started:graphs.adoc[] -*** xref:getting-started:tables.adoc[] \ No newline at end of file +*** xref:getting-started:tables.adoc[] diff --git a/lib/swagger-ui-block-macro.js b/lib/swagger-ui-block-macro.js deleted file mode 100644 index 1c497ce1..00000000 --- a/lib/swagger-ui-block-macro.js +++ /dev/null @@ -1,20 +0,0 @@ -const buildSwaggerUi = ({ specUrl }) => ` - - -` - -function blockSwaggerUiMacro ({ file }) { - return function () { - this.process((parent, specUrl) => { - specUrl = `${specUrl}` - const contentScripts = buildSwaggerUi({ specUrl }) - return this.createBlock(parent, 'pass', contentScripts) - }) - } -} - -function register (registry, context) { - registry.blockMacro('swagger_ui', blockSwaggerUiMacro(context)) -} - -module.exports.register = register diff --git a/lib/tabs-block.js b/lib/tabs-block.js deleted file mode 100644 index ae47e18d..00000000 --- a/lib/tabs-block.js +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 2018 OpenDevise, Inc. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * Extends the AsciiDoc syntax to support a tabset. The tabset is created from - * a dlist enclosed in an example block that is marked with the tabs style. - * - * Usage: - * - * [tabs] - * ==== - * Tab A:: - * + - * -- - * Contents of tab A. - * -- - * Tab B:: - * + - * -- - * Contents of tab B. - * -- - * ==== - * - * @author Dan Allen - */ -const IdSeparatorCh = '-' -const ExtraIdSeparatorsRx = /^-+|-+$|-(-)+/g -const InvalidIdCharsRx = /[^a-zA-Z0-9_]/g -const List = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'List') -const ListItem = Opal.const_get_local(Opal.module(null, 'Asciidoctor'), 'ListItem') - -const generateId = (str, idx) => - `tabset${idx}_${str.toLowerCase().replace(InvalidIdCharsRx, IdSeparatorCh).replace(ExtraIdSeparatorsRx, '$1')}` - -function tabsBlock () { - this.onContext('example') - this.process((parent, reader, attrs) => { - const createHtmlFragment = (html) => this.createBlock(parent, 'pass', html) - const tabsetIdx = parent.getDocument().counter('idx-tabset') - const nodes = [] - nodes.push(createHtmlFragment('
')) - const container = this.parseContent(this.createBlock(parent, 'open'), reader) - const sourceTabs = container.getBlocks()[0] - if (!(sourceTabs && sourceTabs.getContext() === 'dlist' && sourceTabs.getItems().length)) return - const tabs = List.$new(parent, 'ulist') - tabs.addRole('tabs') - const panes = {} - sourceTabs.getItems().forEach(([[title], details]) => { - const tab = ListItem.$new(tabs) - tabs.$append(tab) - const id = generateId(title.getText(), tabsetIdx) - tab.text = `[[${id}]]${title.text}` - let blocks = details.getBlocks() - const numBlocks = blocks.length - if (numBlocks) { - if (blocks[0].context === 'open' && numBlocks === 1) blocks = blocks[0].getBlocks() - panes[id] = blocks.map((block) => (block.parent = parent) && block) - } - }) - nodes.push(tabs) - nodes.push(createHtmlFragment('
')) - Object.entries(panes).forEach(([id, blocks]) => { - nodes.push(createHtmlFragment(`
`)) - nodes.push(...blocks) - nodes.push(createHtmlFragment('
')) - }) - nodes.push(createHtmlFragment('
')) - nodes.push(createHtmlFragment('
')) - parent.blocks.push(...nodes) - }) -} - -function register (registry) { - registry.block('tabs', tabsBlock) -} - -module.exports.register = register diff --git a/package-lock.json b/package-lock.json index 11c12b0f..6442483d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@antora/cli": "^3.1.1", "@antora/site-generator": "^3.1.1", "asciidoctor-kroki": "^0.10.0", + "hazelcast-docs-tools": "github:hazelcast/hazelcast-docs-tools#v1.1.0", "ngrok": "^4.2.2", "serve": "^13.0.2" } @@ -1403,6 +1404,20 @@ "node": ">=4" } }, + "node_modules/hazelcast-docs-tools": { + "version": "1.1.0", + "resolved": "git+ssh://git@github.com/hazelcast/hazelcast-docs-tools.git#b602ba887566628f5b405722ef0f23629e319eed", + "dev": true, + "license": "ISC", + "bin": { + "check-orphan-pages": "bin/check-orphan-pages.js", + "load-check-links-playbook": "bin/load-check-links-playbook.js" + }, + "engines": { + "node": ">=20.0.0", + "npm": ">=10.0.0" + } + }, "node_modules/help-me": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", diff --git a/package.json b/package.json index ce7448e3..bb8c21d5 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,12 @@ "name": "hazelcast-docs-playbook", "version": "1.0.0", "description": "Hazelcast Antora project.", - "author": "SerdarO", + "author": "Hazelcast Docs", "license": "ISC", "scripts": { "build": "antora --to-dir docs --fetch antora-playbook.yml", "build-local": "antora --to-dir test --fetch antora-playbook-local.yml", + "check-orphan-pages": "check-orphan-pages --log-failure-level=error", "serve": "serve test", "expose": "ngrok http 5000" }, @@ -14,6 +15,7 @@ "@antora/cli": "^3.1.1", "@antora/site-generator": "^3.1.1", "asciidoctor-kroki": "^0.10.0", + "hazelcast-docs-tools": "github:hazelcast/hazelcast-docs-tools#v1.1.0", "ngrok": "^4.2.2", "serve": "^13.0.2" }