@antora/asciidoc-loader
Advanced tools
Comparing version 3.0.3 to 3.1.0
'use strict' | ||
const Asciidoctor = require('@asciidoctor/core')() | ||
const Asciidoctor = require('./asciidoctor') | ||
const { Extensions, LoggerManager, NullLogger } = Asciidoctor | ||
@@ -10,4 +10,4 @@ const Opal = global.Opal | ||
const { posix: path } = require('path') | ||
const resolveAsciiDocConfig = require('./config/resolve-asciidoc-config') | ||
const resolveIncludeFile = require('./include/resolve-include-file') | ||
const userRequire = require('@antora/user-require-helper') | ||
@@ -85,18 +85,26 @@ const BLANK_LINE_BUF = Buffer.from('\n\n') | ||
} finally { | ||
if (extensions.length) freeExtensions() | ||
if (extensions.length) { | ||
// low-level operation to free objects from memory that have been weaved into an extension DSL module | ||
EXTENSION_DSL_TYPES.forEach((type) => (Opal.const_get_local(Extensions, type).$$iclasses.length = 0)) | ||
} | ||
} | ||
} | ||
function computePageAttrs ({ component: componentName, version, module: module_, relative, origin }, contentCatalog) { | ||
function computePageAttrs ({ component, version, module: module_, relative, origin, editUrl }, contentCatalog) { | ||
const attrs = {} | ||
attrs['page-component-name'] = componentName | ||
attrs['page-component-name'] = component | ||
attrs['page-component-version'] = attrs['page-version'] = version | ||
const component = contentCatalog && contentCatalog.getComponent(componentName) | ||
if (component) { | ||
if ((component = contentCatalog && contentCatalog.getComponent(component))) { | ||
attrs['page-component-title'] = component.title | ||
const componentVersion = component.versions.find((it) => it.version === version) | ||
if (componentVersion) attrs['page-component-display-version'] = componentVersion.displayVersion | ||
attrs['page-component-title'] = component.title | ||
if (componentVersion) { | ||
attrs['page-component-display-version'] = componentVersion.displayVersion | ||
const latestVersion = component.latest.version | ||
if (version === latestVersion) attrs['page-component-version-is-latest'] = '' | ||
attrs['page-component-latest-version'] = latestVersion | ||
} | ||
} | ||
attrs['page-module'] = module_ | ||
attrs['page-relative-src-path'] = relative | ||
if (editUrl) attrs['page-edit-url'] = editUrl | ||
if (origin) { | ||
@@ -106,9 +114,4 @@ attrs['page-origin-type'] = origin.type | ||
attrs['page-origin-start-path'] = origin.startPath | ||
if (origin.branch) { | ||
attrs['page-origin-refname'] = attrs['page-origin-branch'] = origin.branch | ||
attrs['page-origin-reftype'] = 'branch' | ||
} else { | ||
attrs['page-origin-refname'] = attrs['page-origin-tag'] = origin.tag | ||
attrs['page-origin-reftype'] = 'tag' | ||
} | ||
attrs['page-origin-reftype'] = origin.reftype | ||
attrs['page-origin-refname'] = attrs['page-origin-' + origin.reftype] = origin.refname | ||
if (origin.worktree) { | ||
@@ -120,2 +123,3 @@ attrs['page-origin-worktree'] = origin.worktree | ||
} | ||
if (origin.private) attrs['page-origin-private'] = '' | ||
} | ||
@@ -136,70 +140,2 @@ return attrs | ||
/** | ||
* Resolves a global AsciiDoc configuration object from data in the playbook. | ||
* | ||
* Reads data from the asciidoc category of the playbook and resolves it into a global AsciiDoc configuration object | ||
* that can be used by the loadAsciiDoc function. This configuration object consists of built-in attributes as well as a | ||
* shallow clone of the data from the asciidoc category in the playbook. | ||
* | ||
* The main purpose of this function is to resolve extension references in the playbook to extension | ||
* functions. If the extension is scoped, the function is stored in this object. If the extension is global, it is | ||
* registered with the global extension registry, then discarded. | ||
* | ||
* @memberof asciidoc-loader | ||
* | ||
* @param {Object} playbook - The configuration object for Antora (default: {}). | ||
* @param {Object} playbook.asciidoc - The AsciiDoc configuration data in the playbook. | ||
* | ||
* @returns {Object} A resolved configuration object to be used by the loadAsciiDoc function. | ||
*/ | ||
function resolveAsciiDocConfig (playbook = {}) { | ||
const attributes = { | ||
env: 'site', | ||
'env-site': '', | ||
'site-gen': 'antora', | ||
'site-gen-antora': '', | ||
'attribute-missing': 'warn', | ||
'data-uri': null, | ||
icons: 'font', | ||
sectanchors: '', | ||
'source-highlighter': 'highlight.js', | ||
} | ||
if (playbook.site) { | ||
const site = playbook.site | ||
if (site.title) attributes['site-title'] = site.title | ||
if (site.url) attributes['site-url'] = site.url | ||
} | ||
if (!playbook.asciidoc) return { attributes } | ||
// TODO process !name attributes | ||
const { extensions, ...config } = Object.assign({ attributes }, playbook.asciidoc, { | ||
attributes: Object.assign(attributes, playbook.asciidoc.attributes), | ||
}) | ||
if (extensions && extensions.length) { | ||
const userRequireContext = { dot: playbook.dir, paths: [playbook.dir || '', __dirname] } | ||
const scopedExtensions = extensions.reduce((accum, extensionPath) => { | ||
const extension = userRequire(extensionPath, userRequireContext) | ||
if ('register' in extension) { | ||
accum.push(extension) | ||
} else if (!isExtensionRegistered(extension, Extensions)) { | ||
// QUESTION should we assign an antora-specific group name? | ||
Extensions.register(extension) | ||
} | ||
return accum | ||
}, []) | ||
if (scopedExtensions.length) config.extensions = scopedExtensions | ||
} | ||
return config | ||
} | ||
function isExtensionRegistered (ext, registry) { | ||
return Object.values(registry.getGroups()).includes(ext) | ||
} | ||
/** | ||
* Low-level operation to free objects from memory that have been weaved into an extension DSL module | ||
*/ | ||
function freeExtensions () { | ||
EXTENSION_DSL_TYPES.forEach((type) => (Opal.const_get_local(Extensions, type).$$iclasses.length = 0)) | ||
} | ||
module.exports = Object.assign(loadAsciiDoc, { | ||
@@ -206,0 +142,0 @@ loadAsciiDoc, |
{ | ||
"name": "@antora/asciidoc-loader", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "Loads AsciiDoc content into an Asciidoctor Document object (AST) for use in an Antora documentation pipeline.", | ||
@@ -19,4 +19,10 @@ "license": "MPL-2.0", | ||
"main": "lib/index.js", | ||
"exports": { | ||
".": "./lib/index.js", | ||
"./config/collate-asciidoc-attributes": "./lib/config/collate-asciidoc-attributes.js", | ||
"./util/compute-relative-url-path": "./lib/util/compute-relative-url-path.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"dependencies": { | ||
"@antora/logger": "3.0.3", | ||
"@antora/logger": "3.1.0", | ||
"@antora/user-require-helper": "~2.0", | ||
@@ -26,3 +32,3 @@ "@asciidoctor/core": "~2.2" | ||
"engines": { | ||
"node": ">=12.21.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -29,0 +35,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41519
19
944
+ Added@antora/logger@3.1.0(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-copy@2.1.7(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedhelp-me@4.2.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedpino@8.4.2(transitive)
+ Addedpino-pretty@9.0.1(transitive)
+ Addedpino-std-serializers@6.2.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@2.3.2(transitive)
+ Addedreadable-stream@4.5.2(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedsonic-boom@3.2.1(transitive)
+ Addedthread-stream@2.7.0(transitive)
- Removed@antora/logger@3.0.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargs@5.0.3(transitive)
- Removedcamelcase@5.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedleven@2.1.0(transitive)
- Removedmri@1.1.4(transitive)
- Removedon-exit-leak-free@0.2.0(transitive)
- Removedpino@7.6.5(transitive)
- Removedpino-pretty@7.3.0(transitive)
- Removedpino-std-serializers@4.0.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedreal-require@0.1.0(transitive)
- Removedrfdc@1.4.1(transitive)
- Removedsonic-boom@2.4.2(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedthread-stream@0.13.2(transitive)
Updated@antora/logger@3.1.0