@antora/content-classifier 3.1.7 → 3.1.9

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.
@@ -2,6 +2,8 @@
2
2
 
3
3
  const ContentCatalog = require('./content-catalog')
4
4
  const collateAsciiDocAttributes = require('@antora/asciidoc-loader/config/collate-asciidoc-attributes')
5
+ const logger = require('./logger')
6
+ const summarizeFileLocation = require('./util/summarize-file-location')
5
7
 
6
8
  /**
7
9
  * Organizes the raw aggregate of virtual files into a {ContentCatalog}.
@@ -34,8 +36,16 @@ function classifyContent (playbook, aggregate, siteAsciiDocConfig = {}) {
34
36
  .forEach((componentVersionData, componentVersion) => {
35
37
  const { name, version } = componentVersion
36
38
  const { files, nav, startPage } = componentVersionData
39
+ const navResolved = nav && (nav.resolved = new Set())
37
40
  componentVersionData.files = undefined // clean up memory
38
41
  files.forEach((file) => allocateSrc(file, name, version, nav) && contentCatalog.addFile(file))
42
+ if (navResolved && nav.length > navResolved.size && new Set(nav).size > navResolved.size) {
43
+ const loc = summarizeFileLocation({ path: 'antora.yml', src: { origin: nav.origin } })
44
+ for (const filepath of nav) {
45
+ if (navResolved.has(filepath)) continue
46
+ logger.warn('Could not resolve nav entry for %s@%s defined in %s: %s', version, name, loc, filepath)
47
+ }
48
+ }
39
49
  contentCatalog.registerComponentVersionStartPage(name, componentVersion, startPage)
40
50
  })
41
51
  contentCatalog.registerSiteStartPage(playbook.site.startPage)
@@ -45,9 +55,9 @@ function classifyContent (playbook, aggregate, siteAsciiDocConfig = {}) {
45
55
  function allocateSrc (file, component, version, nav) {
46
56
  const extname = file.src.extname
47
57
  const filepath = file.path
48
- const navInfo = nav && getNavInfo(filepath, nav)
49
58
  const pathSegments = filepath.split('/')
50
- if (navInfo) {
59
+ let navInfo
60
+ if (nav && (navInfo = getNavInfo(filepath, nav))) {
51
61
  if (extname !== '.adoc') return // ignore file
52
62
  file.nav = navInfo
53
63
  file.src.family = 'nav'
@@ -57,14 +67,14 @@ function allocateSrc (file, component, version, nav) {
57
67
  file.src.relative = pathSegments.slice(2).join('/')
58
68
  file.src.moduleRootPath = calculateRootPath(pathSegments.length - 3)
59
69
  } else {
60
- // relative to root
70
+ // relative to content source root
61
71
  file.src.relative = filepath
62
72
  }
63
73
  } else if (pathSegments[0] === 'modules') {
64
74
  let familyFolder = pathSegments[2]
65
75
  switch (familyFolder) {
66
76
  case 'pages':
67
- // pages/_partials location for partials is @deprecated; special designation scheduled to be removed in Antora 4
77
+ // pages/_partials location for partials is @deprecated; special designation scheduled for removal in Antora 4
68
78
  if (pathSegments[3] === '_partials') {
69
79
  file.src.family = 'partial'
70
80
  // relative to modules/<module>/pages/_partials
@@ -127,7 +137,7 @@ function allocateSrc (file, component, version, nav) {
127
137
  */
128
138
  function getNavInfo (filepath, nav) {
129
139
  const index = nav.findIndex((candidate) => candidate === filepath)
130
- if (~index) return { index }
140
+ if (~index) return nav.resolved.add(filepath) && { index }
131
141
  }
132
142
 
133
143
  function resolveAsciiDocConfig (siteAsciiDocConfig, { asciidoc, origins = [] }) {
@@ -7,6 +7,7 @@ const { lookup: resolveMimeType } = require('./mime-types-with-asciidoc')
7
7
  const parseResourceId = require('./util/parse-resource-id')
8
8
  const { posix: path } = require('path')
9
9
  const resolveResource = require('./util/resolve-resource')
10
+ const summarizeFileLocation = require('./util/summarize-file-location')
10
11
  const versionCompare = require('./util/version-compare-desc')
11
12
 
12
13
  const { ROOT_INDEX_ALIAS_ID, ROOT_INDEX_PAGE_ID } = require('./constants')
@@ -72,6 +73,7 @@ class ContentCatalog {
72
73
  }
73
74
  }
74
75
  }
76
+ // NOTE if no AsciiDoc attributes are defined in the component descriptor, asciidoc is the siteAsciiDocConfig object
75
77
  if (asciidoc) componentVersion.asciidoc = asciidoc
76
78
  const component = this[$components].get(name)
77
79
  if (component) {
@@ -143,7 +145,7 @@ class ContentCatalog {
143
145
  throw new Error(`Duplicate alias: ${generateResourceSpec(src)}`)
144
146
  } else {
145
147
  const details = [filesForFamily.get(key), file]
146
- .map((it, idx) => `${idx + 1}: ${getFileLocation(it)}`)
148
+ .map((it, idx) => `${idx + 1}: ${summarizeFileLocation(it)}`)
147
149
  .join(LOG_WRAP)
148
150
  if (family === 'nav') {
149
151
  throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}${LOG_WRAP}${details}`)
@@ -365,10 +367,10 @@ class ContentCatalog {
365
367
  throw new Error(
366
368
  existingPage === target
367
369
  ? `Page cannot define alias that references itself: ${generateResourceSpec(src)}` +
368
- ` (specified as: ${spec})${LOG_WRAP}source: ${getFileLocation(existingPage)}`
370
+ ` (specified as: ${spec})${LOG_WRAP}source: ${summarizeFileLocation(existingPage)}`
369
371
  : `Page alias cannot reference an existing page: ${generateResourceSpec(src)} (specified as: ${spec})` +
370
- `${LOG_WRAP}source: ${getFileLocation(target)}` +
371
- `${LOG_WRAP}existing page: ${getFileLocation(existingPage)}`
372
+ `${LOG_WRAP}source: ${summarizeFileLocation(target)}` +
373
+ `${LOG_WRAP}existing page: ${summarizeFileLocation(existingPage)}`
372
374
  )
373
375
  }
374
376
  } else if (src.version == null) {
@@ -380,7 +382,7 @@ class ContentCatalog {
380
382
  if (existingAlias) {
381
383
  throw new Error(
382
384
  `Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})` +
383
- `${LOG_WRAP}source: ${getFileLocation(target)}`
385
+ `${LOG_WRAP}source: ${summarizeFileLocation(target)}`
384
386
  )
385
387
  }
386
388
  // NOTE the redirect producer will populate contents when the redirect facility is 'static'
@@ -598,13 +600,4 @@ function createSymbolicVersionAlias (component, version, symbolicVersionSegment,
598
600
  : Object.assign(symbolicVersionAlias, { out: undefined, rel: originalVersionAlias })
599
601
  }
600
602
 
601
- function getFileLocation ({ path: path_, src: { abspath, origin } }) {
602
- if (!origin) return abspath || path_
603
- const { url, gitdir, worktree, refname, tag, reftype = tag ? 'tag' : 'branch', remote, startPath } = origin
604
- let details = `${reftype}: ${refname}`
605
- if ('worktree' in origin) details += worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : ''
606
- if (startPath) details += ` | start path: ${startPath}`
607
- return `${abspath || path.join(startPath, path_)} in ${'worktree' in origin ? worktree || gitdir : url} (${details})`
608
- }
609
-
610
603
  module.exports = ContentCatalog
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ const { posix: path } = require('path')
4
+
5
+ function summarizeFileLocation ({ path: path_, src: { abspath, origin } }) {
6
+ if (!origin) return abspath || path_
7
+ const { url, gitdir, worktree, refname, tag, reftype = tag ? 'tag' : 'branch', remote, startPath } = origin
8
+ let details = `${reftype}: ${refname}`
9
+ if ('worktree' in origin) details += worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : ''
10
+ if (startPath) details += ` | start path: ${startPath}`
11
+ return `${abspath || path.join(startPath, path_)} in ${'worktree' in origin ? worktree || gitdir : url} (${details})`
12
+ }
13
+
14
+ module.exports = summarizeFileLocation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/content-classifier",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "Organizes aggregated content into a virtual file catalog for use in an Antora documentation pipeline.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -27,10 +27,10 @@
27
27
  "#constants": "./lib/constants.js"
28
28
  },
29
29
  "dependencies": {
30
- "@antora/asciidoc-loader": "3.1.7",
31
- "@antora/logger": "3.1.7",
30
+ "@antora/asciidoc-loader": "3.1.9",
31
+ "@antora/logger": "3.1.9",
32
32
  "mime-types": "~2.1",
33
- "vinyl": "~2.2"
33
+ "vinyl": "~3.0"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">=16.0.0"