diff --git a/.github/actions/validate/action.yml b/.github/actions/validate/action.yml index 797dc352..174dd60c 100644 --- a/.github/actions/validate/action.yml +++ b/.github/actions/validate/action.yml @@ -1,5 +1,19 @@ name: Validate -description: Check for dead links +description: Validate Docs + +inputs: + orphan-checker-directory: + description: Directory parameter (--directory) for check-orphan-pages + required: false + default: docs + orphan-checker-log-failure-level: + description: Failure level parameter (--log-failure-level) for check-orphan-pages + required: false + default: error + check-links-loader-log-level: + description: Log level parameter (--log-level) for load-check-links-playbook + required: false + default: log runs: using: 'composite' @@ -15,8 +29,6 @@ runs: repository: hazelcast/hazelcast-docs sparse-checkout: | antora-playbook.yml - lib/load-check-links-playbook.js - lib/antora-link-checker-extension.js sparse-checkout-cone-mode: false path: hazelcast-docs ref: main @@ -24,8 +36,11 @@ runs: - name: Check for broken internal links shell: bash run: | - cp "./hazelcast-docs/lib/load-check-links-playbook.js" "./load-check-links-playbook.js" npm i - npm i -D yaml@2.6.0 matcher@3.0.0 - node load-check-links-playbook.js $GITHUB_REPOSITORY $GITHUB_BASE_REF - ./node_modules/.bin/antora --fetch --to-dir test --log-level=warn --log-failure-level=warn --extension=hazelcast-docs/lib/antora-link-checker-extension.js check-links-playbook.yml + npm i -D hazelcast/hazelcast-docs-tools#v1.1.0 yaml@2.6.0 matcher@3.0.0 + load-check-links-playbook -r $GITHUB_REPOSITORY -b $GITHUB_BASE_REF --log-level ${{ inputs.check-links-loader-log-level }} + ./node_modules/.bin/antora --fetch --to-dir test --log-level=warn --log-failure-level=warn --extension=./node_modules/hazelcast-docs-tools/antora-extensions/antora-link-checker-extension.js check-links-playbook.yml + + - name: Check orphan pages + shell: bash + run: check-orphan-pages -d ${{ inputs.orphan-checker-directory }} --log-failure-level ${{ inputs.orphan-checker-log-failure-level }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 63770112..fc1997cb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,5 +17,7 @@ jobs: uses: actions/checkout@v4 - name: Check dead links uses: hazelcast/hazelcast-docs/.github/actions/validate@main + with: + orphan-checker-directory: "Some literal string" diff --git a/README.adoc b/README.adoc index 9cd926ac..05257207 100644 --- a/README.adoc +++ b/README.adoc @@ -196,7 +196,7 @@ For this to happen we have several common files in the link:https://github.com/h |link:https://github.com/hazelcast/hazelcast-docs/blob/main/.github/actions/validate/action.yml[action.yml] |Contains common parts of the links checker workflow -|link:https://github.com/hazelcast/hazelcast-docs/blob/main/lib/load-check-links-playbook.js[load-check-links-playbook.js] +|link:https://github.com/hazelcast/hazelcast-docs-tools/blob/v1.0.0/scripts/check-links-playbook-loader.js[load-check-links-playbook.js] |Responsible for modification of `content.sources` from the global `antora-playbook.yml`. |=== diff --git a/antora-playbook-local.yml b/antora-playbook-local.yml index 2a4922be..bdd85234 100644 --- a/antora-playbook-local.yml +++ b/antora-playbook-local.yml @@ -226,7 +226,7 @@ ui: snapshot: true antora: extensions: - - require: ./lib/api_json.js + - require: ./node_modules/hazelcast-docs-tools/antora-extensions/api-json.js tags: - Favorites - Videos @@ -273,6 +273,6 @@ asciidoc: ucn: User Code Namespaces ucd: User Code Deployment 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 - asciidoctor-kroki diff --git a/antora-playbook.yml b/antora-playbook.yml index a52277ae..44aa199b 100644 --- a/antora-playbook.yml +++ b/antora-playbook.yml @@ -244,7 +244,7 @@ ui: static_files: [ netlify.toml ] antora: extensions: - - require: ./lib/api_json.js + - require: ./node_modules/hazelcast-docs-tools/antora-extensions/api-json.js tags: - Favorites - Videos @@ -294,6 +294,6 @@ asciidoc: ucn: User Code Namespaces ucd: User Code Deployment 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.0.yml b/assembler-playbook-mc-5.0.yml index 74d7f696..c57d9fc8 100644 --- a/assembler-playbook-mc-5.0.yml +++ b/assembler-playbook-mc-5.0.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.0] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.1.yml b/assembler-playbook-mc-5.1.yml index c31a8a34..a3d5b9e8 100644 --- a/assembler-playbook-mc-5.1.yml +++ b/assembler-playbook-mc-5.1.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.1] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.2.yml b/assembler-playbook-mc-5.2.yml index bdb6406e..dd75b054 100644 --- a/assembler-playbook-mc-5.2.yml +++ b/assembler-playbook-mc-5.2.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.2] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.3.yml b/assembler-playbook-mc-5.3.yml index c58fc31a..ce32c92f 100644 --- a/assembler-playbook-mc-5.3.yml +++ b/assembler-playbook-mc-5.3.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.3] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.4.yml b/assembler-playbook-mc-5.4.yml index 05856116..8b294fb2 100644 --- a/assembler-playbook-mc-5.4.yml +++ b/assembler-playbook-mc-5.4.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.4] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-mc-5.5.yml b/assembler-playbook-mc-5.5.yml index 9e7900d5..f5bcfc3e 100644 --- a/assembler-playbook-mc-5.5.yml +++ b/assembler-playbook-mc-5.5.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/management-center-docs branches: [v/5.5] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-0.yml b/assembler-playbook-platform-5-0.yml index 67ce20b5..4c9b1f77 100644 --- a/assembler-playbook-platform-5-0.yml +++ b/assembler-playbook-platform-5-0.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/hz-docs branches: [v/5.0] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-1.yml b/assembler-playbook-platform-5-1.yml index ae122b89..5aea7442 100644 --- a/assembler-playbook-platform-5-1.yml +++ b/assembler-playbook-platform-5-1.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/hz-docs branches: [v/5.1] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-2.yml b/assembler-playbook-platform-5-2.yml index 047a4d72..fe376c88 100644 --- a/assembler-playbook-platform-5-2.yml +++ b/assembler-playbook-platform-5-2.yml @@ -2,14 +2,14 @@ site: title: Documentation url: https:/docs.hazelcast.com content: - sources: + sources: - url: https://github.com/hazelcast/hz-docs branches: [v/5.2] start_path: docs antora: extensions: - '@antora/pdf-extension' -ui: +ui: bundle: url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip #../hazelcast-docs-ui/build/ui-bundle.zip snapshot: true @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-3.yml b/assembler-playbook-platform-5-3.yml index 8825e35c..e296d84e 100644 --- a/assembler-playbook-platform-5-3.yml +++ b/assembler-playbook-platform-5-3.yml @@ -28,6 +28,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-4.yml b/assembler-playbook-platform-5-4.yml index 8825e35c..e296d84e 100644 --- a/assembler-playbook-platform-5-4.yml +++ b/assembler-playbook-platform-5-4.yml @@ -28,6 +28,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/assembler-playbook-platform-5-5.yml b/assembler-playbook-platform-5-5.yml index 8c5e8f3e..20887f71 100644 --- a/assembler-playbook-platform-5-5.yml +++ b/assembler-playbook-platform-5-5.yml @@ -25,6 +25,6 @@ asciidoc: hazelcast-cloud: Cloud page-cloud-console: https://cloud.hazelcast.com/ 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 - asciidoctor-kroki diff --git a/lib/antora-link-checker-extension.js b/lib/antora-link-checker-extension.js deleted file mode 100644 index a5aecf9f..00000000 --- a/lib/antora-link-checker-extension.js +++ /dev/null @@ -1,8 +0,0 @@ -// This extension stops the Antora site generator from building the site after checking internal links (xrefs). -// As a result, the output is a list of broken links rather than a documentation site. - -module.exports.register = (context) => { - context.on('documentsConverted', () => { - context.stop() - }) -} diff --git a/lib/api_json.js b/lib/api_json.js deleted file mode 100644 index af31f58b..00000000 --- a/lib/api_json.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict' - -/** - * Create a JSON file with a summary of the pages - */ - - -module.exports.register = function ({config}) { - let content = [] - const addEntity = ({title, url, tags, type, order}) => { - const arr = tags.split(',').map(cat => cat.trim()) - if (config.tags && !arr.some(name => (config.tags ?? []).includes(name))) { - throw Error(`Wrong cloud tag '${arr.join(', ')}' in '${title}'`) - } - content.push({ - title: title && title.trim(), - url: url && url.trim(), - tags: arr, - type: type && type.trim(), - order: order ? parseInt(order) : 0 - }) - } - (config.data ?? []).forEach(item => addEntity(item)) - this.on('documentsConverted', ({contentCatalog}) => { - contentCatalog.findBy({family: 'page'}).forEach((item) => { - const urlVideo = item.asciidoc.attributes['cloud-url-video'] - const type = urlVideo ? 'video' : 'article' - const url = urlVideo ?? item.pub.url - const tags = item.asciidoc.attributes['cloud-tags'] - const title = item.asciidoc.attributes['cloud-title'] ?? item.title - const order = item.asciidoc.attributes['cloud-order'] - if (tags) { - if (title.includes('|')) { - title.split('|').forEach((title_multi, index) => { - const tags_multi = item.asciidoc.attributes['cloud-tags'].split('|')[index] - const order_multi = item.asciidoc.attributes['cloud-order'] ? item.asciidoc.attributes['cloud-order'].split('|')[index] : '' - const anchor_multi = item.asciidoc.attributes['cloud-anchor'] ? item.asciidoc.attributes['cloud-anchor'].split('|')[index] : '' - const url_multi = item.asciidoc.attributes['cloud-url-video'] ? item.asciidoc.attributes['cloud-url-video'].split('|')[index] : item.pub.url - addEntity({ - title: title_multi ?? item.title, - url: url_multi + (!!anchor_multi ? `#${anchor_multi.trim()}` : ''), - tags: tags_multi, - type, - order: order_multi ?? 0 - }) - }) - } else { - addEntity({ - title, - url, - tags, - type, - order - }) - } - } - }) - }) - .on('beforePublish', ({siteCatalog}) => { - siteCatalog.addFile({ - contents: Buffer.from(JSON.stringify({ - tags: config.tags ?? [], - links: content.sort((a, b) => a.order - b.order) - })), - out: {path: config.path ?? 'api/cloud.json'} - }) - }) -} diff --git a/lib/load-check-links-playbook.js b/lib/load-check-links-playbook.js deleted file mode 100644 index 4679d949..00000000 --- a/lib/load-check-links-playbook.js +++ /dev/null @@ -1,172 +0,0 @@ -const YAML = require('yaml'); -const fs = require('fs'); -const { isMatch } = require('matcher'); - -function main() { - const { currentRepoName, baseBranchName } = parseInputArgs(); - - // 1. Load and parse local antora-playbook.yml - let localAntoraPlaybook = loadLocalAntoraPlaybook(); - - // 2. Load and parse global antora-playbook.yml's content.sources - let { globalSources, globalAsciidocAttributes } = loadGlobalAntoraData(); - - // 3. Modify global content.sources - // - add hazelcast-docs GitHub URL - addHazelcastDocsUrl(globalSources); - - // - exclude current target branch from the global content list by adding the branch name with the "!" prefix - const currentRepoSource = excludeBaseBranch(globalSources, currentRepoName, baseBranchName); - - // - add current branch - addCurrentBranch(currentRepoSource, globalSources); - - // - hazelcast-mono antora-playbook, contains global attributes, used across other repos - // need to add them to the local antora-playbook - localAntoraPlaybook = copyGlobalAsciidocAttributes(globalAsciidocAttributes, localAntoraPlaybook); - - // 4. Replace local content.sources with the modified content.sources - writeCheckLinksPlaybookFile(localAntoraPlaybook, globalSources); -} - -function parseInputArgs() { - const [currentRepoName, baseBranchName] = process.argv.slice(-2); - - console.log('Checking links...'); - - // check whether there are arguments after the filename - if (currentRepoName.includes('load-check-links-playbook') || baseBranchName.includes('load-check-links-playbook')) { - throw new Error('GitHub repository name and base branch should be passed as arguments'); - } - - console.log('Repository name: ', currentRepoName); - console.log('Base branch: ', baseBranchName); - - return { currentRepoName, baseBranchName }; -} - -function loadLocalAntoraPlaybook() { - const localAntoraPlaybookContent = fs.readFileSync('./antora-playbook.yml', 'utf8'); - return YAML.parse(localAntoraPlaybookContent); -} - -function removeProtectedSources(sources) { - return sources.filter(source => - !(source.url === 'https://github.com/hazelcast/hazelcast-mono') - && !(source.url === 'https://github.com/hazelcast/management-center')); -} - -function loadGlobalAntoraData() { - const globalAntoraPlaybookContent = fs.readFileSync('./hazelcast-docs/antora-playbook.yml', 'utf8'); - const globalAntoraPlaybook = YAML.parse(globalAntoraPlaybookContent); - - // - remove hazelcast-mono & management-center, - // because they have only Swagger docs thus will never have links to the current - // and also they require authentication - const globalSources = removeProtectedSources(globalAntoraPlaybook.content.sources); - const globalAsciidocAttributes = globalAntoraPlaybook.asciidoc.attributes; - - return { globalSources, globalAsciidocAttributes }; -} - -function addHazelcastDocsUrl(sources) { - // in the global playbook it's declared with a dot `.` - const hazelcastDocsSource = sources.find(source => source.url === '.'); - hazelcastDocsSource.url = 'https://github.com/hazelcast/hazelcast-docs'; - hazelcastDocsSource.branches = ['main']; - return sources; -} - -function rewriteCurrentVersion() { - const antoraYmlPath = './docs/antora.yml'; - try { - const antoraYml = YAML.parse(fs.readFileSync(antoraYmlPath, 'utf8')); - const version = 'snapshot_ci'; - antoraYml.version = version; - antoraYml.display_version = version; - antoraYml.asciidoc.attributes['full-version'] = version; - fs.writeFileSync( - antoraYmlPath, - YAML.stringify(antoraYml), - { encoding: 'utf8' }, - ); - } catch (err) { - console.debug(err); - console.warn('Could not rewrite version. There might be an error with version collision!'); - } -} - -function getCurrentSource(matchedRepos, branchName) { - let currentSource = matchedRepos.find(source => { - if (Array.isArray(source.branches)) { - return source.branches.find(branch => isMatch(branchName, branch)); - } else { - return isMatch(branchName, source.branches); - } - }); - if (!currentSource) { - console.debug(`No matching base branch found. Rewriting version to omit version collision!`); - rewriteCurrentVersion(); - currentSource = matchedRepos[0]; - } - - return currentSource; -} - -function excludeBaseBranch(sources, repoName, branchName) { - const excludedBranch = `!${branchName}`; - const matchedRepos = sources.filter(source => source.url.endsWith(repoName)); - if (matchedRepos.length === 0) { - throw new Error(`There is no repository ${repoName} among the playbook sources!`); - } - - const currentSource = getCurrentSource(matchedRepos, branchName); - if (Array.isArray(currentSource.branches)) { - currentSource.branches.push(excludedBranch); - } else { - currentSource.branches = [currentSource.branches, excludedBranch]; - } - - return currentSource; -} - -function addCurrentBranch(repoSource, sources) { - const currentBranchSource = { - url: '.', - branches: 'HEAD', - }; - - // - copy start_path(s) from the currentRepoSource - if (repoSource.start_path) { - currentBranchSource.start_path = repoSource.start_path.slice(); - } - if (repoSource.start_paths) { - currentBranchSource.start_paths = repoSource.start_paths.slice(); - } - - sources.unshift(currentBranchSource); -} - -function copyGlobalAsciidocAttributes(globalAsciidocAttributes, localAntoraPlaybook) { - localAntoraPlaybook.asciidoc.attributes = { - ...globalAsciidocAttributes, - ...localAntoraPlaybook.asciidoc.attributes, - }; - - return localAntoraPlaybook; -} - -function writeCheckLinksPlaybookFile(localPlaybook, sources) { - localPlaybook.content.sources = sources; - const checkLinksPlaybook = YAML.stringify(localPlaybook); - - console.debug(checkLinksPlaybook); - - fs.writeFileSync( - './check-links-playbook.yml', - checkLinksPlaybook, - { encoding: 'utf8' }, - ); -} - -main(); 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 77d9d1bf..91ece98e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "hazelcast-docs-playbook", + "name": "hazelcast-docs", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "hazelcast-docs-playbook", + "name": "hazelcast-docs", "version": "1.0.0", "license": "ISC", "dependencies": { @@ -15,6 +15,7 @@ "@antora/cli": "^3.1.1", "@antora/site-generator": "^3.1.1", "asciidoctor-kroki": "^0.15.0", + "hazelcast-docs-tools": "github:hazelcast/hazelcast-docs-tools#v1.1.0", "ngrok": "^4.2.2", "serve": "^13.0.2" } @@ -1730,6 +1731,20 @@ "node": ">= 0.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": "4.2.0", "resolved": "https://registry.npmjs.org/help-me/-/help-me-4.2.0.tgz", diff --git a/package.json b/package.json index 5f63bf27..030c422f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "hazelcast-docs-playbook", + "name": "hazelcast-docs", "version": "1.0.0", "description": "Hazelcast Antora project", - "author": "Jake Cahill", + "author": "Hazelcast Docs", "license": "ISC", "scripts": { "build": "antora --to-dir docs --fetch antora-playbook.yml && cp _redirects docs", @@ -26,6 +26,7 @@ "@antora/cli": "^3.1.1", "@antora/site-generator": "^3.1.1", "asciidoctor-kroki": "^0.15.0", + "hazelcast-docs-tools": "github:hazelcast/hazelcast-docs-tools#v1.1.0", "ngrok": "^4.2.2", "serve": "^13.0.2" },