@neo4j-antora/pdf-generator 0.1.13 → 0.1.14
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.adoc +4 -0
- package/extension.js +19 -0
- package/package.json +1 -1
package/README.adoc
CHANGED
|
@@ -34,6 +34,10 @@ antora publish.yml --extension @neo4j-antora/pdf-generator
|
|
|
34
34
|
npm run verify:publish -- --extension @neo4j-antora/pdf-generator
|
|
35
35
|
----
|
|
36
36
|
|
|
37
|
+
A PDF contains a single version: the one being built. When the playbook is built, every local content
|
|
38
|
+
source (the repository being built) is limited to `branches: [HEAD]`, so the other versions the
|
|
39
|
+
playbook lists are not collected or rendered. Remote content sources are left as they are.
|
|
40
|
+
|
|
37
41
|
Generating a PDF this way always regenerates the full HTML site alongside
|
|
38
42
|
it in the same Antora run (`@antora/assembler`/`@antora/pdf-extension` hook
|
|
39
43
|
into normal site generation rather than replacing it) - there's no way to
|
package/extension.js
CHANGED
|
@@ -23,7 +23,26 @@ const DEFAULT_CONFIG_FILE = path.join(__dirname, 'antora-assembler-pdf.yml')
|
|
|
23
23
|
// as the one argument - confirmed directly against the installed Antora,
|
|
24
24
|
// including that @antora/pdf-extension's own optional second `providers`
|
|
25
25
|
// parameter is never actually populated by a real Antora invocation either.
|
|
26
|
+
// A PDF contains a single version: the one being built. The playbook of a docset usually lists
|
|
27
|
+
// its other versions as branches of the same repository (HEAD, 5.x, 4.4, ...), and building them
|
|
28
|
+
// would render a PDF for each one, only to throw all but one away. A local content source is the
|
|
29
|
+
// repository being built, and HEAD is the branch that is checked out, so those sources are limited
|
|
30
|
+
// to HEAD, before any content is collected. Remote sources are left as they are.
|
|
31
|
+
const REMOTE_URL = /^(?:[a-z][a-z0-9+.-]*:\/\/|git@)/i
|
|
32
|
+
|
|
33
|
+
function limitLocalSourcesToHead ({ playbook }) {
|
|
34
|
+
const logger = this.getLogger?.('neo4j-pdf-generator')
|
|
35
|
+
for (const source of playbook?.content?.sources ?? []) {
|
|
36
|
+
if (REMOTE_URL.test(source.url ?? '')) continue
|
|
37
|
+
const branches = [].concat(source.branches ?? [])
|
|
38
|
+
if (branches.length === 1 && branches[0] === 'HEAD') continue
|
|
39
|
+
source.branches = ['HEAD']
|
|
40
|
+
logger?.info({ source: { url: source.url } }, 'Building HEAD only (was: %s)', branches.join(', ') || 'the playbook default')
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
module.exports.register = function ({ config = {} } = {}) {
|
|
45
|
+
this.once('playbookBuilt', limitLocalSourcesToHead.bind(this))
|
|
27
46
|
const resolvedConfig = Object.assign({ configFile: DEFAULT_CONFIG_FILE }, config)
|
|
28
47
|
return pdfExtension.register.call(this, { config: resolvedConfig })
|
|
29
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-antora/pdf-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Generates a PDF export from an Antora docset, styled to match the real Neo4j docs site, via @antora/assembler + @antora/pdf-extension and asciidoctor-web-pdf",
|
|
5
5
|
"main": "extension.js",
|
|
6
6
|
"files": [
|