@antora/site-generator-default 3.0.0-beta.1 → 3.0.0-beta.5

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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # Antora Default Site Generator
2
2
 
3
- This is the default site generator for Antora.
3
+ This is the site generator for Antora.
4
4
  This generator is invoked by the `generate` command of Antora's CLI to produce and publish static documentation sites.
5
5
 
6
+ *This package is an alias for the `@antora/site-generator` package.*
7
+
6
8
  [Antora](https://antora.org) is a modular static site generator designed for creating documentation sites from AsciiDoc documents.
7
9
  Its site generator aggregates documents from versioned content repositories and processes them using [Asciidoctor](https://asciidoctor.org).
8
10
 
package/lib/index.js CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  /**
4
- * Default Site Generator component for Antora
5
- *
6
- * Coordinates a default set of software components to produce and publish a
7
- * documentation site. This component represents just one way the Antora
8
- * components can be organized to make a documentation generator.
4
+ * An alias for the @antora/site-generator package.
9
5
  *
10
6
  * @namespace site-generator-default
11
7
  */
12
- module.exports = require('./generate-site')
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-beta.1",
4
- "description": "The default site generator for producing and publishing static documentation sites with Antora.",
3
+ "version": "3.0.0-beta.5",
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,7 @@
15
15
  },
16
16
  "main": "lib/index.js",
17
17
  "dependencies": {
18
- "@antora/asciidoc-loader": "3.0.0-beta.1",
19
- "@antora/content-aggregator": "3.0.0-beta.1",
20
- "@antora/content-classifier": "3.0.0-beta.1",
21
- "@antora/document-converter": "3.0.0-beta.1",
22
- "@antora/logger": "3.0.0-beta.1",
23
- "@antora/navigation-builder": "3.0.0-beta.1",
24
- "@antora/page-composer": "3.0.0-beta.1",
25
- "@antora/redirect-producer": "3.0.0-beta.1",
26
- "@antora/site-mapper": "3.0.0-beta.1",
27
- "@antora/site-publisher": "3.0.0-beta.1",
28
- "@antora/ui-loader": "3.0.0-beta.1",
29
- "@antora/user-require-helper": "~2.0"
30
- },
31
- "devDependencies": {
32
- "@antora/playbook-builder": "3.0.0-beta.1"
18
+ "@antora/site-generator": "3.0.0-beta.5"
33
19
  },
34
20
  "engines": {
35
21
  "node": ">=12.21.0"
@@ -46,5 +32,5 @@
46
32
  "static site",
47
33
  "web publishing"
48
34
  ],
49
- "gitHead": "7c5ef1ea93dd489af533c80a936c736013c41769"
35
+ "gitHead": "a13d03df41654d4deb78211a5a54953ce2a35fb8"
50
36
  }
@@ -1,72 +0,0 @@
1
- 'use strict'
2
-
3
- const GeneratorContext = require('./generator-context')
4
- const SiteCatalog = require('./site-catalog')
5
-
6
- async function generateSite (playbook) {
7
- try {
8
- const context = new GeneratorContext(playbook, module)
9
- const { fxns, vars } = context
10
- await context.notify('playbookBuilt')
11
- playbook = vars.lock('playbook')
12
- vars.asciidocConfig = fxns.resolveAsciiDocConfig(playbook)
13
- vars.siteCatalog = new SiteCatalog()
14
- await context.notify('beforeProcess')
15
- const asciidocConfig = vars.lock('asciidocConfig')
16
- await Promise.all([
17
- fxns.aggregateContent(playbook).then((contentAggregate) =>
18
- context.notify('contentAggregated', Object.assign(vars, { contentAggregate })).then(() => {
19
- vars.contentCatalog = fxns.classifyContent(playbook, vars.remove('contentAggregate'), asciidocConfig)
20
- })
21
- ),
22
- fxns.loadUi(playbook).then((uiCatalog) => context.notify('uiLoaded', Object.assign(vars, { uiCatalog }))),
23
- ])
24
- await context.notify('contentClassified')
25
- const contentCatalog = vars.lock('contentCatalog')
26
- const uiCatalog = vars.lock('uiCatalog')
27
- fxns.convertDocuments(contentCatalog, asciidocConfig)
28
- await context.notify('documentsConverted')
29
- vars.navigationCatalog = fxns.buildNavigation(contentCatalog, asciidocConfig)
30
- await context.notify('navigationBuilt')
31
- ;(() => {
32
- const navigationCatalog = vars.remove('navigationCatalog')
33
- const composePage = fxns.createPageComposer(playbook, contentCatalog, uiCatalog, playbook.env)
34
- contentCatalog.getPages((page) => page.out && composePage(page, contentCatalog, navigationCatalog))
35
- if (playbook.site.url) vars.siteCatalog.addFile(composePage(create404Page()))
36
- })()
37
- await context.notify('pagesComposed')
38
- vars.siteCatalog.addFiles(fxns.produceRedirects(playbook, contentCatalog))
39
- await context.notify('redirectsProduced')
40
- if (playbook.site.url) {
41
- const publishablePages = contentCatalog.getPages((page) => page.out)
42
- vars.siteCatalog.addFiles(fxns.mapSite(playbook, publishablePages))
43
- await context.notify('siteMapped')
44
- }
45
- await context.notify('beforePublish')
46
- return fxns.publishSite(playbook, [contentCatalog, uiCatalog, vars.lock('siteCatalog')]).then((publications) => {
47
- if (!playbook.runtime.quiet && process.stdout.isTTY) {
48
- process.stdout.write('Site generation complete!\n')
49
- publications.forEach(
50
- ({ fileUri }) => fileUri && process.stdout.write(`View the site by visiting ${fileUri} in a browser.\n`)
51
- )
52
- }
53
- return context
54
- .notify('sitePublished', Object.assign(vars, { publications }))
55
- .then(() => vars.remove('publications'))
56
- })
57
- } catch (err) {
58
- if (!GeneratorContext.isHaltSignal(err)) throw err
59
- }
60
- }
61
-
62
- function create404Page () {
63
- return {
64
- title: 'Page Not Found',
65
- mediaType: 'text/html',
66
- src: { stem: '404' },
67
- out: { path: '404.html' },
68
- pub: { url: '/404.html', rootPath: '' },
69
- }
70
- }
71
-
72
- module.exports = generateSite
@@ -1,160 +0,0 @@
1
- 'use strict'
2
-
3
- const EventEmitter = require('events')
4
- const getLogger = require('@antora/logger')
5
- const userRequire = require('@antora/user-require-helper')
6
-
7
- const FUNCTION_PROVIDERS = {
8
- aggregateContent: 'content-aggregator',
9
- buildNavigation: 'navigation-builder',
10
- classifyContent: 'content-classifier',
11
- convertDocument: 'document-converter',
12
- convertDocuments: 'document-converter',
13
- createPageComposer: 'page-composer',
14
- extractAsciiDocMetadata: 'asciidoc-loader',
15
- loadAsciiDoc: 'asciidoc-loader',
16
- loadUi: 'ui-loader',
17
- mapSite: 'site-mapper',
18
- produceRedirects: 'redirect-producer',
19
- publishSite: 'site-publisher',
20
- resolveAsciiDocConfig: 'asciidoc-loader',
21
- }
22
-
23
- class HaltSignal extends Error {}
24
-
25
- class GeneratorContext extends EventEmitter {
26
- #fxns
27
- #vars
28
-
29
- constructor (playbook, module_) {
30
- super()
31
- if (!('path' in (this.module = module_))) module_.path = require('path').dirname(module_.filename)
32
- this._registerFunctions(module_)
33
- this._registerExtensions(playbook, this._initVariables(playbook), module_)
34
- Object.defineProperties(this, { _initVariables: {}, _registerExtensions: {}, _registerFunctions: {} })
35
- }
36
-
37
- getFunctions () {
38
- return arguments.length ? this.#fxns : Object.assign({}, this.#fxns)
39
- }
40
-
41
- getLogger (name = 'antora') {
42
- return getLogger(name)
43
- }
44
-
45
- getVariables () {
46
- return Object.assign({}, this.#vars)
47
- }
48
-
49
- halt () {
50
- throw new HaltSignal()
51
- }
52
-
53
- async notify (eventName) {
54
- if (!this.listenerCount(eventName)) return
55
- for (const listener of this.rawListeners(eventName)) {
56
- const outcome = listener.length === 1 ? listener.call(this, this.getVariables()) : listener.call(this)
57
- if (outcome instanceof Promise) await outcome
58
- }
59
- }
60
-
61
- replaceFunctions (updates) {
62
- const fxns = this.#fxns
63
- Object.entries(updates).map(([name, fxn]) => {
64
- if (name in fxns) fxns[name] = fxn.bind(this)
65
- })
66
- }
67
-
68
- require (request) {
69
- return this.module.require(request)
70
- }
71
-
72
- updateVariables (updates) {
73
- try {
74
- Object.assign(this.#vars, updates)
75
- } catch (err) {
76
- if (err instanceof TypeError) {
77
- err.message = err.message.replace(/ assign to read.only property '(.+)' .*/, " update read-only var '$1'")
78
- }
79
- throw err
80
- }
81
- }
82
-
83
- // TODO remove updateVars before Antora 3.0.0
84
- updateVars (updates) {
85
- return this.updateVariables(updates)
86
- }
87
-
88
- static isHaltSignal (err) {
89
- return err instanceof HaltSignal
90
- }
91
-
92
- _initVariables (playbook) {
93
- Object.defineProperty(this, 'vars', {
94
- configurable: true,
95
- get: () => {
96
- delete this.vars
97
- return Object.setPrototypeOf(this.#vars, {
98
- lock (name) {
99
- return Object.defineProperty(this, name, { configurable: false, writable: false })[name]
100
- },
101
- remove (name) {
102
- const currentValue = this[name]
103
- delete this[name]
104
- return currentValue
105
- },
106
- })
107
- },
108
- })
109
- return (this.#vars = { playbook })
110
- }
111
-
112
- _registerExtensions (playbook, vars, module_) {
113
- const extensions = (playbook.antora || {}).extensions || []
114
- if (extensions.length) {
115
- const requireContext = { dot: playbook.dir, paths: [playbook.dir || '', module_.path] }
116
- extensions.forEach((ext) => {
117
- const { enabled = true, id, require: request, ...config } = ext.constructor === String ? { require: ext } : ext
118
- if (!enabled) return
119
- const { register } = userRequire(request, requireContext)
120
- if (typeof register !== 'function') return
121
- if (register.length) {
122
- if (/^(?:function *)?(?:\w+ *)?\( *\w|^\w+(?: *, *\w+)* *=>/.test(register.toString().replace(/\r?\n/g, ' '))) {
123
- register.length === 1 ? register(this) : register(this, Object.assign({ config }, vars))
124
- } else {
125
- register.call(this, Object.assign({ config }, vars))
126
- }
127
- } else {
128
- register.call(this)
129
- }
130
- })
131
- }
132
- this.notify = this.eventNames().length ? this.notify.bind(this) : async () => undefined
133
- }
134
-
135
- _registerFunctions (module_) {
136
- this.#fxns = Object.entries(
137
- Object.entries(FUNCTION_PROVIDERS).reduce((accum, [fxnName, moduleKey]) => {
138
- accum[moduleKey] = (accum[moduleKey] || []).concat(fxnName)
139
- return accum
140
- }, {})
141
- ).reduce((accum, [moduleKey, fxnNames]) => {
142
- const defaultExport = module_.require('@antora/' + moduleKey)
143
- const defaultExportName = defaultExport.name
144
- fxnNames.forEach((fxnName) => {
145
- const fxn = fxnName === defaultExportName ? defaultExport : defaultExport[fxnName]
146
- accum[fxnName] = fxn.bind(this)
147
- })
148
- return accum
149
- }, {})
150
- Object.defineProperty(this, 'fxns', {
151
- configurable: true,
152
- get: () => {
153
- delete this.fxns
154
- return this.#fxns
155
- },
156
- })
157
- }
158
- }
159
-
160
- module.exports = GeneratorContext
@@ -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