This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-website.git
The following commit(s) were added to refs/heads/main by this push: new 479c07c chore: prepare jsonpath pipeline 479c07c is described below commit 479c07c8ffbc7f9c266ed5abf9ac6b9a3ea751fe Author: David Jencks <djen...@apache.org> AuthorDate: Thu Sep 9 10:18:16 2021 +0200 chore: prepare jsonpath pipeline This is the last bit needed for the changes in https://github.com/apache/camel/pull/6040 To get merged, utilizing the jsonpath macro in the Antora pipeline to generate component/endpoint options table. This has been picked from https://github.com/apache/camel-website/pull/617 to ease merging. The bit that was not included in this or in the PR #620 is the refactoring around absolute/relative URLs, i.e. the `patch-sitemap.js` is still present after this. --- antora-playbook.yml | 5 +++- util/jsonpath-util.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/antora-playbook.yml b/antora-playbook.yml index 48fe690..089db46 100644 --- a/antora-playbook.yml +++ b/antora-playbook.yml @@ -98,7 +98,6 @@ asciidoc: - ./extensions/table.js - ./extensions/inline-styles.js - "@djencks/asciidoctor-antora-indexer" - - "@djencks/asciidoctor-jsonpath" attributes: eip-vc: latest@components @@ -106,3 +105,7 @@ runtime: log: level: info failure_level: warn + +pipeline: + extensions: + - require: '@djencks/asciidoctor-jsonpath' diff --git a/util/jsonpath-util.js b/util/jsonpath-util.js new file mode 100644 index 0000000..d28ef02 --- /dev/null +++ b/util/jsonpath-util.js @@ -0,0 +1,65 @@ +module.exports = { + alias: (name, aliases) => { + for (expr of (aliases || '').split(',')) { + const {pattern, alias} = splitOnce(expr) + const re = new RegExp(pattern, 'i') + if (re.test(name)) { + return alias + } + } + return '' + }, + + description: (value) => { + try { + return module.exports.strong(value, "Autowired") + + module.exports.strong(value, "Required") + + module.exports.strong(value, "Deprecated") + + module.exports.escapeAttributes(value.description) + (value.description.endsWith(".") ? "" : ".") + + (value.deprecatedNote ? `\n\nNOTE: ${value.deprecatedNote}` : "") + + (value.enum ? `${["\n\nEnum values:\n"].concat(value.enum).join("\n* ")}` : "") + } catch (e) { + console.log('error', e) + return e.msg() + } + }, + + escapeAttributes: (text) => { + return text.split('{').join('\\{') + }, + + formatSignature: (signature) => { + return signature.split('$').join('.') + ';' + }, + + javaSimpleName: (name) => { + return name.split(/<.*>/).join('').split('.').pop() + }, + + pascalCase: (input) => { + return input ? + input.split('-').map((segment) => { + return segment.length ? + segment.charAt(0).toUpperCase() + segment.slice(1) : + segment + }).join('') : + input + }, + + producerConsumerLong: (consumerOnly, producerOnly) => { + if (consumerOnly) return 'Only consumer is supported' + if (producerOnly) return 'Only producer is supported' + return 'Both producer and consumer are supported' + }, + + strong: (data, text) => { + return data[text.toLowerCase()] ? `*${text}* ` : '' + }, +} + +function splitOnce (querySpec, token = '=') { + const index = querySpec.indexOf(token) + const pattern = querySpec.substring(0, index).trim() + const alias = querySpec.substring(index + 1).trim() + return { pattern, alias } +}