@redpanda-data/docs-extensions-and-macros 5.53.0 → 5.54.0
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/bin/doc-tools.js +127 -0
- package/extensions/REFERENCE.adoc +45 -9
- package/extensions/generate-rp-connect-info.js +79 -24
- package/extensions/modify-connect-tag-playbook.js +319 -74
- package/extensions/url-to-xref.js +3 -0
- package/extensions/util/connect-catalog.js +10 -5
- package/extensions/util/connect-docs-asset.js +187 -0
- package/extensions/util/connect-github.js +16 -0
- package/extensions/version-fetcher/list-connect-releases.js +10 -0
- package/package.json +1 -1
- package/tools/connect-docs/check-build-log.js +311 -0
- package/tools/connect-docs/check-rendered-html.js +469 -0
- package/tools/connect-docs/ci-playbook.yml +77 -0
- package/tools/connect-docs/diff-generated.js +382 -0
- package/tools/connect-docs/pr-comment.js +104 -0
package/bin/doc-tools.js
CHANGED
|
@@ -2930,6 +2930,133 @@ programCli
|
|
|
2930
2930
|
runCli(options)
|
|
2931
2931
|
})
|
|
2932
2932
|
|
|
2933
|
+
/**
|
|
2934
|
+
* check-build-log
|
|
2935
|
+
*
|
|
2936
|
+
* @description
|
|
2937
|
+
* Check an Antora JSON log (`antora --log-format json`): exit 1 when any
|
|
2938
|
+
* record is at level error or fatal, and, with --min-pages and --site-dir,
|
|
2939
|
+
* when fewer HTML pages were written than expected. Prints a Markdown
|
|
2940
|
+
* summary (counts by level, then the error and warning messages grouped and
|
|
2941
|
+
* deduplicated, with file and line) for $GITHUB_STEP_SUMMARY. Warnings never
|
|
2942
|
+
* fail the check. With --blocking-sources, only errors from those
|
|
2943
|
+
* repositories (or with no source) fail it, so a broken page in another
|
|
2944
|
+
* content source of the playbook is reported without blocking.
|
|
2945
|
+
*
|
|
2946
|
+
* @why
|
|
2947
|
+
* Antora's --log-failure-level fails the build but explains nothing in a job
|
|
2948
|
+
* summary, and cannot catch a build that exits 0 having written no files,
|
|
2949
|
+
* which is what Antora does on an unsupported Node version. The Connect docs
|
|
2950
|
+
* PR check runs Antora with --log-failure-level=fatal so this command, not
|
|
2951
|
+
* Antora, decides.
|
|
2952
|
+
*
|
|
2953
|
+
* @example
|
|
2954
|
+
* npx antora --log-format json --log-failure-level=fatal antora-playbook.yml > build.ndjson
|
|
2955
|
+
* npx doc-tools check-build-log build.ndjson --site-dir build/site/connect --min-pages 400 >> "$GITHUB_STEP_SUMMARY"
|
|
2956
|
+
*
|
|
2957
|
+
* # Block only on errors from these repositories; list the rest
|
|
2958
|
+
* npx doc-tools check-build-log build.ndjson --blocking-sources redpanda-data/rp-connect-docs,redpanda-data/connect
|
|
2959
|
+
*/
|
|
2960
|
+
programCli
|
|
2961
|
+
.command('check-build-log')
|
|
2962
|
+
.description('Check an Antora JSON build log: fail on error or fatal records or too few pages, print a Markdown summary')
|
|
2963
|
+
.argument('<log>', 'Antora log written with --log-format json (one JSON record per line)')
|
|
2964
|
+
.option('--site-dir <dir>', 'Output directory to count HTML pages in (with --min-pages)')
|
|
2965
|
+
.option('--min-pages <n>', 'Fail when fewer than <n> HTML pages were written under --site-dir')
|
|
2966
|
+
.option('--blocking-sources <repos>', 'Comma-separated owner/name repositories whose errors block (default: all). Errors with no source always block; others are listed only')
|
|
2967
|
+
.option('--format <format>', 'Output format: markdown or json', 'markdown')
|
|
2968
|
+
.option('--output <path>', 'Also write the output to this file')
|
|
2969
|
+
.action((log, options) => {
|
|
2970
|
+
const { runCli } = require('../tools/connect-docs/check-build-log')
|
|
2971
|
+
runCli(log, options)
|
|
2972
|
+
})
|
|
2973
|
+
|
|
2974
|
+
/**
|
|
2975
|
+
* check-rendered-html
|
|
2976
|
+
*
|
|
2977
|
+
* @description
|
|
2978
|
+
* Scan the rendered HTML of one or more Antora component paths for AsciiDoc
|
|
2979
|
+
* that did not convert: literal backticks outside code, literal `xref:` or
|
|
2980
|
+
* `include::` text, leftover {page-*} or {env-*} attribute references, `|===`
|
|
2981
|
+
* table markup, Asciidoctor's "Unresolved include directive" text, links with
|
|
2982
|
+
* the `unresolved` class, and empty sections (a heading followed directly by a
|
|
2983
|
+
* heading of the same or higher level). Also checks links: a fragment with no
|
|
2984
|
+
* matching id on its target page (broken-anchor), and a relative or
|
|
2985
|
+
* root-relative link under a link root that is not in the build
|
|
2986
|
+
* (broken-link). External links are ignored; links outside every link root,
|
|
2987
|
+
* or into a root the build does not contain, are counted as unchecked. Only
|
|
2988
|
+
* the page body is scanned. Reports findings per page and exits 0 unless
|
|
2989
|
+
* --strict.
|
|
2990
|
+
*
|
|
2991
|
+
* With --changed-pages, findings are split into those on the listed pages and
|
|
2992
|
+
* the rest, and --strict exits 1 only when a listed page has findings, so
|
|
2993
|
+
* defects already on the base never fail a PR.
|
|
2994
|
+
*
|
|
2995
|
+
* @why
|
|
2996
|
+
* These defects reach readers without a single line in the Antora log: two
|
|
2997
|
+
* backticks for an empty enum option, or a backtick glued to the next word,
|
|
2998
|
+
* render as literal backticks on the published page.
|
|
2999
|
+
*
|
|
3000
|
+
* @example
|
|
3001
|
+
* npx doc-tools check-rendered-html build/site --component connect >> "$GITHUB_STEP_SUMMARY"
|
|
3002
|
+
*
|
|
3003
|
+
* # Fail on any finding
|
|
3004
|
+
* npx doc-tools check-rendered-html build/site --strict
|
|
3005
|
+
*
|
|
3006
|
+
* # Self-managed and Cloud Connect pages; fail only on the pages a PR changed
|
|
3007
|
+
* npx doc-tools check-rendered-html build/site --component connect,cloud-data-platform/develop/connect \
|
|
3008
|
+
* --changed-pages changed-pages.txt --strict
|
|
3009
|
+
*/
|
|
3010
|
+
programCli
|
|
3011
|
+
.command('check-rendered-html')
|
|
3012
|
+
.description('Scan rendered Antora HTML for unconverted AsciiDoc (literal backticks, xref:, include::, attributes, tables, empty sections) and broken anchors and links')
|
|
3013
|
+
.argument('<site-dir>', 'Antora output directory (the --to-dir of the build)')
|
|
3014
|
+
.option('--component <path>', 'Component output path to scan under <site-dir>; repeat it or give a comma list, for example connect,cloud-data-platform/develop/connect (default: connect)', (value, previous = []) => previous.concat(value))
|
|
3015
|
+
.option('--link-root <path>', 'Site path whose linked pages must exist; repeat it or give a comma list. Scanned components are always included. Links outside every root, or into a root not in the build, are counted as unchecked (default: connect,cloud-data-platform/develop/connect)', (value, previous = []) => previous.concat(value))
|
|
3016
|
+
.option('--pages <file>', 'Only scan the pages listed in <file>, one path relative to <site-dir> per line')
|
|
3017
|
+
.option('--changed-pages <file>', 'Pages a PR changed: one path relative to <site-dir> per line (the sitePath from connect-docs-diff) or connect-docs-diff --format json output. All pages are still scanned; findings are split into changed and other pages, and --strict fails only on changed pages')
|
|
3018
|
+
.option('--format <format>', 'Output format: markdown or json', 'markdown')
|
|
3019
|
+
.option('--output <path>', 'Also write the output to this file')
|
|
3020
|
+
.option('--strict', 'Exit 1 when any finding exists, or with --changed-pages when a changed page has findings (default: always exit 0)')
|
|
3021
|
+
.action((siteDir, options) => {
|
|
3022
|
+
const { runCli } = require('../tools/connect-docs/check-rendered-html')
|
|
3023
|
+
runCli(siteDir, options)
|
|
3024
|
+
})
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* connect-docs-diff
|
|
3028
|
+
*
|
|
3029
|
+
* @description
|
|
3030
|
+
* Compare two trees written by connect's docs generator, for example a PR's
|
|
3031
|
+
* merge base and its head, and map each added, removed, or changed partial or
|
|
3032
|
+
* example to the docs.redpanda.com page that includes it. Prints a Markdown
|
|
3033
|
+
* table of changed pages with links, then a unified diff per file in
|
|
3034
|
+
* collapsible blocks, capped in size. A tree root can be connect's docs/
|
|
3035
|
+
* directory, its modules/ directory, or the components/ directory.
|
|
3036
|
+
*
|
|
3037
|
+
* @why
|
|
3038
|
+
* Writers review Go string literals today and never see the page. The
|
|
3039
|
+
* generated output is the published change: connect strings, benthos strings
|
|
3040
|
+
* from a go.mod bump, and generator changes all show up here.
|
|
3041
|
+
*
|
|
3042
|
+
* @example
|
|
3043
|
+
* npx doc-tools connect-docs-diff base/modules head/modules >> "$GITHUB_STEP_SUMMARY"
|
|
3044
|
+
* npx doc-tools connect-docs-diff base/modules head/modules --format json
|
|
3045
|
+
*/
|
|
3046
|
+
programCli
|
|
3047
|
+
.command('connect-docs-diff')
|
|
3048
|
+
.description('Diff two generated Connect docs trees and map each changed partial or example to its published page')
|
|
3049
|
+
.argument('<base-dir>', 'Generated tree of the base (merge base) commit')
|
|
3050
|
+
.argument('<head-dir>', 'Generated tree of the head commit')
|
|
3051
|
+
.option('--format <format>', 'Output format: markdown or json', 'markdown')
|
|
3052
|
+
.option('--site-url <url>', 'Docs site the page links point at', 'https://docs.redpanda.com')
|
|
3053
|
+
.option('--max-bytes <n>', 'Cap on the Markdown output size; diffs past it are counted, not shown', '60000')
|
|
3054
|
+
.option('--output <path>', 'Also write the output to this file')
|
|
3055
|
+
.action((baseDir, headDir, options) => {
|
|
3056
|
+
const { runCli } = require('../tools/connect-docs/diff-generated')
|
|
3057
|
+
runCli(baseDir, headDir, options)
|
|
3058
|
+
})
|
|
3059
|
+
|
|
2933
3060
|
/**
|
|
2934
3061
|
* preview-string
|
|
2935
3062
|
*
|
|
@@ -404,39 +404,75 @@ You can optionally display pages only if they match the component and version of
|
|
|
404
404
|
|
|
405
405
|
== Redpanda Connect tag modifier
|
|
406
406
|
|
|
407
|
-
This extension
|
|
407
|
+
This extension adds the Redpanda Connect generated reference docs (field reference, examples, metadata, descriptions, config snippets, the Bloblang reference, and `platforms/catalog.json`) to the `connect` component that rp-connect-docs provides, from a Connect release.
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
Every Connect release publishes the generated tree as a release asset named `redpanda-connect-docs.tar.gz`, at `\https://github.com/redpanda-data/connect/releases/download/<tag>/redpanda-connect-docs.tar.gz`. The playbook does not list the connect repository as a content source. If it still lists the upstream repository with `tags: latest`, the extension removes that source. See <<Playbooks that list the connect repository>>.
|
|
410
|
+
|
|
411
|
+
At build time, when the playbook has the `connect` component, the extension:
|
|
412
|
+
|
|
413
|
+
. Picks the release: the latest stable `vX.Y.Z` release by default, so the site never shows fields from unreleased code on connect's `main` branch. It asks the GitHub API for the latest release and falls back to the highest stable `vX.Y.Z` tag from `git ls-remote`. If neither works, the build stops with an error. The `tag` option picks a specific release instead.
|
|
414
|
+
. Downloads that release's `redpanda-connect-docs.tar.gz` asset. With a GitHub token it downloads through the releases API, which keeps working if the connect repository becomes private. Without one, or if GitHub rejects the token, it uses the public download URL.
|
|
415
|
+
. Adds `modules/components/partials/**` as partials and `modules/components/examples/**` as examples of the `components` module, in every version of the `connect` component. A file that another source, such as rp-connect-docs, already provides is skipped and counted in the log, so rp-connect-docs can keep committing its own copies until it stops.
|
|
416
|
+
|
|
417
|
+
A release from before the asset existed has none, and the download returns 404. A new release can also be missing it for a while: Connect publishes the release first and attaches the asset 15 to 20 minutes later in a separate job, which can fail.
|
|
418
|
+
|
|
419
|
+
So when the latest release has no asset, the extension falls back to the newest older stable `vX.Y.Z` release that has one, and logs a warning that names both, such as `Redpanda Connect v4.114.0 has no redpanda-connect-docs.tar.gz asset yet; using v4.113.0`. It reads the asset lists of the 10 most recent releases from the GitHub releases API, so it downloads only the release it picks. If the API is unavailable, it tries the downloads of the next 3 lower stable tags from `git ls-remote` instead. A release picked with the `tag` option never falls back: if it has no asset, the build stops with an error that names the release.
|
|
420
|
+
|
|
421
|
+
When no release it checks has the asset, the extension logs this and adds nothing. The `generate-rp-connect-info` extension then stops the build if connector pages are missing any generated set they include: the `fields/`, `descriptions/`, or `availability/` partials, or the `common/` or `advanced/` examples. This also catches an incomplete asset, which would otherwise publish pages with unresolved includes. Any other failure, such as a network error or a corrupt archive, stops the build, because building without the reference would publish connector pages with no fields.
|
|
422
|
+
|
|
423
|
+
The extension shares the release it used, including a fallback release, so `generate-rp-connect-info` reads `catalog.json` and `info.csv` for the same release as the reference docs. It adds its files before any other `contentClassified` listener runs, wherever it is listed in the playbook.
|
|
424
|
+
|
|
425
|
+
=== Preview unreleased Connect changes
|
|
426
|
+
|
|
427
|
+
To build with reference docs that are not released yet, generate them in a connect checkout and point `REDPANDA_CONNECT_DOCS_DIR` at the result:
|
|
428
|
+
|
|
429
|
+
[,bash]
|
|
430
|
+
----
|
|
431
|
+
export REDPANDA_CONNECT_DOCS_DIR=/path/to/connect/docs
|
|
432
|
+
npx antora --fetch local-antora-playbook.yml
|
|
433
|
+
----
|
|
434
|
+
|
|
435
|
+
The value is a directory that contains `modules/` (a connect checkout's `docs/` directory after running its docs generator, or the checkout root), or a local copy of a `redpanda-connect-docs.tar.gz` file. It wins over the `tag` option and the latest release, and nothing is downloaded. Its files also replace any copy another source provides, such as the copies rp-connect-docs commits, and the log counts how many were replaced. Set `tag` as well to choose the release that `generate-rp-connect-info` reads `info.csv` from.
|
|
436
|
+
|
|
437
|
+
=== Playbooks that list the connect repository
|
|
438
|
+
|
|
439
|
+
Before the release asset, playbooks listed the connect repository as a content source:
|
|
410
440
|
|
|
411
441
|
```yaml
|
|
412
442
|
content:
|
|
413
443
|
sources:
|
|
414
444
|
- url: https://github.com/redpanda-data/connect
|
|
415
|
-
tags: latest
|
|
445
|
+
tags: latest
|
|
416
446
|
start_path: docs
|
|
417
447
|
```
|
|
418
448
|
|
|
419
|
-
|
|
449
|
+
Connect releases no longer include `docs/antora.yml`, so Antora cannot aggregate that source. When the upstream `redpanda-data/connect` repository is listed with `tags: latest` as its only ref, the extension removes the source from the playbook before Antora fetches content, logs a warning that it is no longer needed, and uses the release asset. Remove the source from the playbook to silence the warning.
|
|
420
450
|
|
|
421
|
-
|
|
422
|
-
* Keeps only the `modules/components/partials/` and `modules/components/examples/` files of the `connect` component from that source. Any file that another source, such as rp-connect-docs, already provides is skipped, and so is content from older Connect tags that name their component `redpanda-connect`. Antora fails the build on a duplicate page or partial, so you can add the source to a playbook before or after rp-connect-docs stops committing its own generated copies.
|
|
451
|
+
A connect source with explicit refs is kept, which is how you preview a connect branch: a branch, a specific tag, a fork, or a local clone whose directory is named `connect`. In that case the extension downloads no asset, and:
|
|
423
452
|
|
|
424
|
-
|
|
453
|
+
* Only the `modules/components/partials/` and `modules/components/examples/` files of the `connect` component are kept from that source. Any file that another source already provides is skipped, and so is content from older Connect tags that name their component `redpanda-connect`.
|
|
454
|
+
* `REDPANDA_CONNECT_DOCS_DIR` and the `tag` option are ignored.
|
|
455
|
+
* The ref must have `docs/antora.yml` and the generated docs. If the generated sets are missing, the `generate-rp-connect-info` error names the connect source.
|
|
425
456
|
|
|
426
457
|
=== Environment variables
|
|
427
458
|
|
|
428
|
-
- `
|
|
459
|
+
- `REDPANDA_CONNECT_DOCS_DIR` (optional): A local directory, or a local `redpanda-connect-docs.tar.gz` file, to read the reference docs from instead of a release. See <<Preview unreleased Connect changes>>.
|
|
460
|
+
- `REDPANDA_GITHUB_TOKEN` (optional): A GitHub token for the latest release lookup, the fallback release listing, the asset download, and the `git ls-remote` fallback. The extension also reads `ACTIONS_BOT_TOKEN`, `GITHUB_TOKEN`, `VBOT_GITHUB_API_TOKEN`, `GH_TOKEN`, and a github.com entry in `GIT_CREDENTIALS`, in that order. Without any GitHub token, the extension sends unauthenticated requests, which GitHub can rate limit, and which only work while the connect repository is public.
|
|
429
461
|
|
|
430
462
|
=== Configuration options
|
|
431
463
|
|
|
432
|
-
|
|
464
|
+
`tag` (optional):: A Connect release tag, such as `v4.113.0`, to use instead of the latest stable release. A missing `v` prefix is added. If that release has no asset, the build stops: an explicit tag never falls back to an older release. `latest` is rejected, because the latest release is the default without `tag`. Ignored when the playbook keeps a connect content source with explicit refs.
|
|
433
465
|
|
|
434
466
|
=== Registration
|
|
435
467
|
|
|
468
|
+
Register this extension together with `generate-rp-connect-info`:
|
|
469
|
+
|
|
436
470
|
```yaml
|
|
437
471
|
antora:
|
|
438
472
|
extensions:
|
|
439
473
|
- require: '@redpanda-data/docs-extensions-and-macros/extensions/modify-connect-tag-playbook'
|
|
474
|
+
# tag: v4.113.0 # optional: a specific release instead of the latest
|
|
475
|
+
- require: '@redpanda-data/docs-extensions-and-macros/extensions/generate-rp-connect-info'
|
|
440
476
|
```
|
|
441
477
|
|
|
442
478
|
== Version fetcher
|
|
@@ -13,29 +13,81 @@ const DEFAULTS = {
|
|
|
13
13
|
githubRepo: 'connect'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
16
|
+
// Generated sets that connector pages include, by Antora family. Each one
|
|
17
|
+
// must be present, or pages publish with unresolved includes.
|
|
18
|
+
// The generated partial and example directories that connector pages include,
|
|
19
|
+
// read from the pages themselves, so the guard asks for exactly what the pages
|
|
20
|
+
// in this build use (rp-connect-docs pages gain availability includes, for
|
|
21
|
+
// example, when they move to the generated docs).
|
|
22
|
+
const PARTIAL_INCLUDE = /include::connect:components:partial\$([a-z0-9_-]+)\//g
|
|
23
|
+
const EXAMPLE_INCLUDE = /include::(?:connect:)?components:example\$([a-z0-9_-]+)\//g
|
|
24
|
+
|
|
25
|
+
function includedDirs (pages) {
|
|
26
|
+
const partial = new Set()
|
|
27
|
+
const example = new Set()
|
|
28
|
+
for (const page of pages) {
|
|
29
|
+
const text = page.contents ? page.contents.toString() : ''
|
|
30
|
+
for (const m of text.matchAll(PARTIAL_INCLUDE)) partial.add(m[1])
|
|
31
|
+
for (const m of text.matchAll(EXAMPLE_INCLUDE)) example.add(m[1])
|
|
32
|
+
}
|
|
33
|
+
// Name the core sets first, in a fixed order, so the error reads the same
|
|
34
|
+
// way every time.
|
|
35
|
+
const order = ['fields', 'descriptions', 'availability', 'metadata', 'examples', 'common', 'advanced']
|
|
36
|
+
const rank = (d) => (order.includes(d) ? order.indexOf(d) : order.length)
|
|
37
|
+
const sorted = (set) => [...set].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b))
|
|
38
|
+
return { partial: sorted(partial), example: sorted(example) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Connector pages include the generated field reference, description meta,
|
|
42
|
+
// availability, and config examples, which the modify-connect-tag-playbook
|
|
43
|
+
// extension adds from the redpanda-connect-docs.tar.gz asset of a connect
|
|
44
|
+
// release. If a playbook has the Connect pages but any set is missing (an
|
|
45
|
+
// incomplete asset, or a connect source whose ref lacks them), connector
|
|
46
|
+
// pages would publish with unresolved includes, and Antora only logs them.
|
|
47
|
+
// Fail the build instead so the playbook gets fixed before anything is
|
|
48
|
+
// published.
|
|
49
|
+
//
|
|
50
|
+
// `connectSources` are the connect content sources still in the playbook,
|
|
51
|
+
// which means no release asset was downloaded.
|
|
52
|
+
function assertConnectReferencePresent (contentCatalog, { connectSources = [] } = {}) {
|
|
22
53
|
const component = contentCatalog.getComponents().find((c) => c.name === 'connect')
|
|
23
54
|
if (!component) return
|
|
24
|
-
// Only connector pages (inputs/kafka.adoc and so on) include
|
|
25
|
-
//
|
|
55
|
+
// Only connector pages (inputs/kafka.adoc and so on) include the generated
|
|
56
|
+
// sets. Overview pages at the module root don't.
|
|
26
57
|
const pages = contentCatalog.findBy({ component: 'connect', module: 'components', family: 'page' })
|
|
27
58
|
.filter((p) => p.src.relative.includes('/'))
|
|
28
59
|
if (!pages.length) return
|
|
29
|
-
const
|
|
30
|
-
.
|
|
31
|
-
|
|
60
|
+
const missingIn = (family, dirs) => {
|
|
61
|
+
const files = contentCatalog.findBy({ component: 'connect', module: 'components', family })
|
|
62
|
+
return dirs.filter((dir) => !files.some((f) => f.src.relative.startsWith(`${dir}/`)))
|
|
63
|
+
.map((dir) => `components:${family}$${dir}/*`)
|
|
64
|
+
}
|
|
65
|
+
const wanted = includedDirs(pages)
|
|
66
|
+
const missing = [...missingIn('partial', wanted.partial), ...missingIn('example', wanted.example)]
|
|
67
|
+
if (!missing.length) return
|
|
68
|
+
const sourceHint = connectSources.length
|
|
69
|
+
? `The playbook lists a connect content source (${connectSources.join(', ')}), so no release asset was downloaded and these files must come from that source's refs. ` +
|
|
70
|
+
'Point it at a ref that has the generated docs, or remove it to use the release asset. '
|
|
71
|
+
: ''
|
|
32
72
|
throw new Error(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
73
|
+
`The connect component has connector pages but no generated ${missing.join(' or ')} files. ` +
|
|
74
|
+
sourceHint +
|
|
75
|
+
'These come from the redpanda-connect-docs.tar.gz asset of a Redpanda Connect release, which the ' +
|
|
76
|
+
'modify-connect-tag-playbook extension downloads. Register that extension and check its log: ' +
|
|
77
|
+
'the release it used (the latest stable release, or the one in its `tag` config) may have no asset or an incomplete one. ' +
|
|
78
|
+
'Set `tag` to a release that has the asset, or set REDPANDA_CONNECT_DOCS_DIR to a local directory that contains ' +
|
|
79
|
+
'modules/ (for example a connect checkout\'s docs/ after running its docs generator).'
|
|
36
80
|
)
|
|
37
81
|
}
|
|
38
82
|
|
|
83
|
+
// The connect content sources in a playbook, with credentials removed.
|
|
84
|
+
function connectSourcesOf (playbook) {
|
|
85
|
+
const sources = (playbook && playbook.content && playbook.content.sources) || []
|
|
86
|
+
return sources
|
|
87
|
+
.filter((s) => catalogUtil.isConnectSource(s.url))
|
|
88
|
+
.map((s) => String(s.url).replace(/([a-z][a-z+.-]*:\/\/)[^@/\s]*@/gi, '$1'))
|
|
89
|
+
}
|
|
90
|
+
|
|
39
91
|
module.exports.assertConnectReferencePresent = assertConnectReferencePresent
|
|
40
92
|
|
|
41
93
|
module.exports.register = function ({ config }) {
|
|
@@ -63,8 +115,8 @@ module.exports.register = function ({ config }) {
|
|
|
63
115
|
let translatedRows = null
|
|
64
116
|
|
|
65
117
|
// Use 'on' and return the promise so Antora waits for async completion
|
|
66
|
-
this.on('contentClassified', ({ contentCatalog }) => {
|
|
67
|
-
assertConnectReferencePresent(contentCatalog)
|
|
118
|
+
this.on('contentClassified', ({ contentCatalog, playbook }) => {
|
|
119
|
+
assertConnectReferencePresent(contentCatalog, { connectSources: connectSourcesOf(playbook) })
|
|
68
120
|
return processContent(contentCatalog)
|
|
69
121
|
})
|
|
70
122
|
|
|
@@ -132,8 +184,9 @@ module.exports.register = function ({ config }) {
|
|
|
132
184
|
|
|
133
185
|
// Raw catalog rows (info.csv column names) for this build.
|
|
134
186
|
//
|
|
135
|
-
// The generated partials/platforms/catalog.json from the
|
|
136
|
-
// source comes first: it is
|
|
187
|
+
// The generated partials/platforms/catalog.json from connect (the release
|
|
188
|
+
// asset, or a connect content source) comes first: it is from the same ref
|
|
189
|
+
// as the reference content
|
|
137
190
|
// and carries status, categories, and cgo data that info.csv lacks. info.csv
|
|
138
191
|
// still supplies the SQL driver rows, which are not components and so are
|
|
139
192
|
// not in the catalog. Without catalog.json, info.csv supplies every row.
|
|
@@ -152,7 +205,8 @@ module.exports.register = function ({ config }) {
|
|
|
152
205
|
let csvRows = []
|
|
153
206
|
try {
|
|
154
207
|
const csvText = await fetchCSV(localCsvPath, contentCatalog)
|
|
155
|
-
|
|
208
|
+
// connect's info.csv pads every column with spaces, headers included
|
|
209
|
+
csvRows = Papa.parse(csvText, { header: true, skipEmptyLines: true, transformHeader: (h) => h.trim() }).data
|
|
156
210
|
} catch (error) {
|
|
157
211
|
if (!catalogRows) throw error
|
|
158
212
|
logger.warn(`Could not fetch info.csv for the SQL driver rows, so the SQL driver support list is empty: ${error.message}`)
|
|
@@ -186,8 +240,9 @@ module.exports.register = function ({ config }) {
|
|
|
186
240
|
}
|
|
187
241
|
|
|
188
242
|
// The ref to read info.csv from, in order:
|
|
189
|
-
// 1. the tag modify-connect-tag-playbook resolved for the
|
|
190
|
-
//
|
|
243
|
+
// 1. the tag modify-connect-tag-playbook resolved (for the release asset or
|
|
244
|
+
// the connect content source)
|
|
245
|
+
// 2. the ref of the connect files in the content catalog
|
|
191
246
|
// 3. latest-connect-version in antora.yml in the working directory
|
|
192
247
|
// 4. main, with a warning, because the catalog can then disagree with the
|
|
193
248
|
// reference content
|
|
@@ -201,9 +256,9 @@ module.exports.register = function ({ config }) {
|
|
|
201
256
|
const normalizedVersion = connectVersion ? String(connectVersion).trim().replace(/^v/, '') : ''
|
|
202
257
|
if (normalizedVersion) return { ...base, ref: `v${normalizedVersion}`, source: 'latest-connect-version in antora.yml' }
|
|
203
258
|
logger.warn(
|
|
204
|
-
'No connect
|
|
205
|
-
'Catalog badges can then disagree with the reference content.
|
|
206
|
-
'
|
|
259
|
+
'No resolved connect release or latest-connect-version found, so info.csv is read from connect main. ' +
|
|
260
|
+
'Catalog badges can then disagree with the reference content. Register the modify-connect-tag-playbook ' +
|
|
261
|
+
'extension, or set its `tag` config when REDPANDA_CONNECT_DOCS_DIR is set.'
|
|
207
262
|
)
|
|
208
263
|
return { ...base, ref: 'main', source: 'fallback' }
|
|
209
264
|
}
|