@antora/site-generator-default 3.0.0-alpha.9 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/lib/index.js +2 -7
- package/package.json +6 -16
- package/lib/generate-site.js +0 -85
- package/lib/pipeline.js +0 -90
- package/lib/site-catalog.js +0 -28
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Antora Default Site Generator
|
|
2
2
|
|
|
3
|
-
This is the
|
|
4
|
-
This
|
|
3
|
+
This is the site generator for Antora.
|
|
4
|
+
This generator is invoked by the `generate` command of Antora's CLI to produce and publish static documentation sites.
|
|
5
|
+
|
|
6
|
+
*This package is an alias for the `@antora/site-generator` package.*
|
|
5
7
|
|
|
6
8
|
[Antora](https://antora.org) is a modular static site generator designed for creating documentation sites from AsciiDoc documents.
|
|
7
|
-
Its site generator
|
|
9
|
+
Its site generator aggregates documents from versioned content repositories and processes them using [Asciidoctor](https://asciidoctor.org).
|
|
8
10
|
|
|
9
11
|
## Copyright and License
|
|
10
12
|
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Runs an Antora pipeline using the default set of components with a focus on
|
|
7
|
-
* producing and publishing a documentation site. This component represents
|
|
8
|
-
* just one way the Antora components can be organized into a site generation
|
|
9
|
-
* pipeline.
|
|
4
|
+
* An alias for the @antora/site-generator package.
|
|
10
5
|
*
|
|
11
6
|
* @namespace site-generator-default
|
|
12
7
|
*/
|
|
13
|
-
module.exports = require('
|
|
8
|
+
module.exports = require('@antora/site-generator')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/site-generator-default",
|
|
3
|
-
"version": "3.0.0-
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
|
+
"description": "An alias for the @antora/site-generator package.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
7
7
|
"contributors": [
|
|
@@ -15,21 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@antora/
|
|
19
|
-
"@antora/content-aggregator": "3.0.0-alpha.9",
|
|
20
|
-
"@antora/content-classifier": "3.0.0-alpha.9",
|
|
21
|
-
"@antora/document-converter": "3.0.0-alpha.9",
|
|
22
|
-
"@antora/navigation-builder": "3.0.0-alpha.9",
|
|
23
|
-
"@antora/page-composer": "3.0.0-alpha.9",
|
|
24
|
-
"@antora/playbook-builder": "3.0.0-alpha.9",
|
|
25
|
-
"@antora/redirect-producer": "3.0.0-alpha.9",
|
|
26
|
-
"@antora/site-mapper": "3.0.0-alpha.9",
|
|
27
|
-
"@antora/site-publisher": "3.0.0-alpha.9",
|
|
28
|
-
"@antora/ui-loader": "3.0.0-alpha.9",
|
|
29
|
-
"@antora/user-require-helper": "~2.0"
|
|
18
|
+
"@antora/site-generator": "3.0.0-beta.4"
|
|
30
19
|
},
|
|
31
20
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
21
|
+
"node": ">=12.21.0"
|
|
33
22
|
},
|
|
34
23
|
"files": [
|
|
35
24
|
"lib/"
|
|
@@ -43,5 +32,6 @@
|
|
|
43
32
|
"static site",
|
|
44
33
|
"web publishing"
|
|
45
34
|
],
|
|
46
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8a142499e9f1a9e0631777796e06dd6c010d3a90",
|
|
36
|
+
"readmeFilename": "README.md"
|
|
47
37
|
}
|
package/lib/generate-site.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Pipeline = require('./pipeline')
|
|
4
|
-
const SiteCatalog = require('./site-catalog')
|
|
5
|
-
|
|
6
|
-
const aggregateContent = require('@antora/content-aggregator')
|
|
7
|
-
const buildNavigation = require('@antora/navigation-builder')
|
|
8
|
-
const buildPlaybook = require('@antora/playbook-builder')
|
|
9
|
-
const classifyContent = require('@antora/content-classifier')
|
|
10
|
-
const convertDocuments = require('@antora/document-converter')
|
|
11
|
-
const createPageComposer = require('@antora/page-composer')
|
|
12
|
-
const loadUi = require('@antora/ui-loader')
|
|
13
|
-
const mapSite = require('@antora/site-mapper')
|
|
14
|
-
const produceRedirects = require('@antora/redirect-producer')
|
|
15
|
-
const publishSite = require('@antora/site-publisher')
|
|
16
|
-
const { resolveAsciiDocConfig } = require('@antora/asciidoc-loader')
|
|
17
|
-
|
|
18
|
-
async function generateSite (args, env) {
|
|
19
|
-
let playbook = buildPlaybook(args, env)
|
|
20
|
-
try {
|
|
21
|
-
const pipeline = new Pipeline(playbook, module)
|
|
22
|
-
const vars = pipeline.vars
|
|
23
|
-
await pipeline.notify('playbookBuilt')
|
|
24
|
-
playbook = vars.lock('playbook')
|
|
25
|
-
vars.asciidocConfig = resolveAsciiDocConfig(playbook)
|
|
26
|
-
vars.siteCatalog = new SiteCatalog()
|
|
27
|
-
await pipeline.notify('beforeProcess')
|
|
28
|
-
const asciidocConfig = vars.lock('asciidocConfig')
|
|
29
|
-
await Promise.all([
|
|
30
|
-
aggregateContent(playbook).then((contentAggregate) =>
|
|
31
|
-
pipeline.notify('contentAggregated', Object.assign(vars, { contentAggregate })).then(() => {
|
|
32
|
-
vars.contentCatalog = classifyContent(playbook, vars.remove('contentAggregate'), asciidocConfig)
|
|
33
|
-
})
|
|
34
|
-
),
|
|
35
|
-
loadUi(playbook).then((uiCatalog) => pipeline.notify('uiLoaded', Object.assign(vars, { uiCatalog }))),
|
|
36
|
-
])
|
|
37
|
-
await pipeline.notify('contentClassified')
|
|
38
|
-
const contentCatalog = vars.lock('contentCatalog')
|
|
39
|
-
const uiCatalog = vars.lock('uiCatalog')
|
|
40
|
-
convertDocuments(contentCatalog, asciidocConfig)
|
|
41
|
-
await pipeline.notify('documentsConverted')
|
|
42
|
-
vars.navigationCatalog = buildNavigation(contentCatalog, asciidocConfig)
|
|
43
|
-
await pipeline.notify('navigationBuilt')
|
|
44
|
-
;(() => {
|
|
45
|
-
const navigationCatalog = vars.remove('navigationCatalog')
|
|
46
|
-
const composePage = createPageComposer(playbook, contentCatalog, uiCatalog, playbook.env)
|
|
47
|
-
contentCatalog.getPages((page) => page.out && composePage(page, contentCatalog, navigationCatalog))
|
|
48
|
-
if (playbook.site.url) vars.siteCatalog.addFile(composePage(create404Page()))
|
|
49
|
-
})()
|
|
50
|
-
await pipeline.notify('pagesComposed')
|
|
51
|
-
vars.siteCatalog.addFiles(produceRedirects(playbook, contentCatalog))
|
|
52
|
-
await pipeline.notify('redirectsProduced')
|
|
53
|
-
if (playbook.site.url) {
|
|
54
|
-
const publishablePages = contentCatalog.getPages((page) => page.out)
|
|
55
|
-
vars.siteCatalog.addFiles(mapSite(playbook, publishablePages))
|
|
56
|
-
await pipeline.notify('siteMapped')
|
|
57
|
-
}
|
|
58
|
-
await pipeline.notify('beforePublish')
|
|
59
|
-
return publishSite(playbook, [contentCatalog, uiCatalog, vars.lock('siteCatalog')]).then((publications) => {
|
|
60
|
-
if (!playbook.runtime.quiet && process.stdout.isTTY) {
|
|
61
|
-
process.stdout.write('Site generation complete!\n')
|
|
62
|
-
publications.forEach(
|
|
63
|
-
({ fileUri }) => fileUri && process.stdout.write(`View the site by visiting ${fileUri} in a browser.\n`)
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
return pipeline
|
|
67
|
-
.notify('sitePublished', Object.assign(vars, { publications }))
|
|
68
|
-
.then(() => vars.remove('publications'))
|
|
69
|
-
})
|
|
70
|
-
} catch (err) {
|
|
71
|
-
if (!Pipeline.isHaltSignal(err)) throw err
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function create404Page () {
|
|
76
|
-
return {
|
|
77
|
-
title: 'Page Not Found',
|
|
78
|
-
mediaType: 'text/html',
|
|
79
|
-
src: { stem: '404' },
|
|
80
|
-
out: { path: '404.html' },
|
|
81
|
-
pub: { url: '/404.html', rootPath: '' },
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
module.exports = generateSite
|
package/lib/pipeline.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const EventEmitter = require('events')
|
|
4
|
-
const userRequire = require('@antora/user-require-helper')
|
|
5
|
-
|
|
6
|
-
class HaltPipelineSignal extends Error {}
|
|
7
|
-
|
|
8
|
-
class Pipeline extends EventEmitter {
|
|
9
|
-
constructor (playbook, module_) {
|
|
10
|
-
super()
|
|
11
|
-
if (!('path' in (this.module = module_))) module_.path = require('path').dirname(module_.filename)
|
|
12
|
-
_registerExtensions.bind(this)(playbook, module_, _initVars.bind(this)(playbook))
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
halt () {
|
|
16
|
-
throw new HaltPipelineSignal()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async notify (vars, eventName) {
|
|
20
|
-
if (this.listenerCount(eventName)) {
|
|
21
|
-
for (const listener of this.rawListeners(eventName)) {
|
|
22
|
-
const outcome = listener.call(this, Object.assign({}, vars))
|
|
23
|
-
if (outcome instanceof Promise) await outcome
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
require (request) {
|
|
29
|
-
return this.module.require(request)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
updateVars (vars, updates) {
|
|
33
|
-
try {
|
|
34
|
-
Object.assign(vars, updates)
|
|
35
|
-
} catch (err) {
|
|
36
|
-
if (err instanceof TypeError) {
|
|
37
|
-
err.message = err.message.replace(/ assign to read.only property '(.+)' .*/, " update read-only var '$1'")
|
|
38
|
-
}
|
|
39
|
-
throw err
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static isHaltSignal (err) {
|
|
44
|
-
return err instanceof HaltPipelineSignal
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _initVars (playbook) {
|
|
49
|
-
const vars = Object.setPrototypeOf(
|
|
50
|
-
{ playbook },
|
|
51
|
-
{
|
|
52
|
-
lock (name) {
|
|
53
|
-
return Object.defineProperty(this, name, { configurable: false, writable: false })[name]
|
|
54
|
-
},
|
|
55
|
-
remove (name) {
|
|
56
|
-
const currentValue = this[name]
|
|
57
|
-
delete this[name]
|
|
58
|
-
return currentValue
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
Object.defineProperty(this, 'vars', {
|
|
63
|
-
configurable: true,
|
|
64
|
-
get: () => {
|
|
65
|
-
delete this.vars
|
|
66
|
-
return vars
|
|
67
|
-
},
|
|
68
|
-
})
|
|
69
|
-
this.updateVars = this.updateVars.bind(this, vars)
|
|
70
|
-
return vars
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function _registerExtensions (playbook, module_, vars) {
|
|
74
|
-
const extensions = (playbook.pipeline || {}).extensions
|
|
75
|
-
if (extensions.length) {
|
|
76
|
-
const requireContext = { dot: playbook.dir, paths: [playbook.dir || '', module_.path] }
|
|
77
|
-
extensions.forEach((ext) => {
|
|
78
|
-
const { enabled = true, id, require: request, ...config } = ext.constructor === String ? { require: ext } : ext
|
|
79
|
-
if (enabled) {
|
|
80
|
-
const { register } = userRequire(request, requireContext)
|
|
81
|
-
if (typeof register === 'function') {
|
|
82
|
-
register.length === 1 ? register(this) : register(this, Object.assign({ config }, vars))
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
this.notify = this.eventNames().length ? this.notify.bind(this, vars) : async () => undefined
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
module.exports = Pipeline
|
package/lib/site-catalog.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const $files = Symbol('files')
|
|
4
|
-
|
|
5
|
-
class SiteCatalog {
|
|
6
|
-
constructor () {
|
|
7
|
-
this[$files] = []
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
addFile (file) {
|
|
11
|
-
this[$files].push(file)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
addFiles (files) {
|
|
15
|
-
this[$files].push(...files)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
getFiles () {
|
|
19
|
-
return this[$files].slice()
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated superceded by getFiles(); scheduled to be removed in Antora 4
|
|
25
|
-
*/
|
|
26
|
-
SiteCatalog.prototype.getAll = SiteCatalog.prototype.getFiles
|
|
27
|
-
|
|
28
|
-
module.exports = SiteCatalog
|