@redpanda-data/docs-extensions-and-macros 4.17.0 → 4.17.1

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.
@@ -3,6 +3,8 @@
3
3
  const fs = require('fs')
4
4
  const path = require('path')
5
5
  const os = require('os')
6
+
7
+
6
8
  const handlebars = require('handlebars')
7
9
 
8
10
  // Import and register Redpanda Connect helpers
@@ -114,9 +116,8 @@ handlebars.registerHelper('renderConnectFieldsTable', function (children) {
114
116
 
115
117
  // Default configuration
116
118
  const DEFAULTS = {
117
- format: 'nested', // 'nested' or 'table'
118
- dataPath: null, // Path to connector JSON data file (e.g., 'docs-data/connect-4.88.0.json')
119
- enabled: true // Allow disabling the extension
119
+ format: 'nested', // 'nested' or 'table'
120
+ enabled: true // Allow disabling the extension
120
121
  }
121
122
 
122
123
  module.exports.register = function ({ config }) {
@@ -125,12 +126,9 @@ module.exports.register = function ({ config }) {
125
126
  // Merge config with defaults
126
127
  const {
127
128
  format = DEFAULTS.format,
128
- datapath = DEFAULTS.dataPath, // Antora lowercases this
129
129
  enabled = DEFAULTS.enabled
130
130
  } = config || {}
131
131
 
132
- const dataPath = datapath
133
-
134
132
  if (!enabled) {
135
133
  logger.info('Extension disabled via config')
136
134
  return
@@ -142,23 +140,6 @@ module.exports.register = function ({ config }) {
142
140
  return
143
141
  }
144
142
 
145
- // Load the connector data file
146
- if (!dataPath) {
147
- logger.warn('No dataPath configured. Skipping field-only page generation.')
148
- return
149
- }
150
-
151
- let connectorData
152
- try {
153
- const resolvedPath = path.resolve(dataPath)
154
- const rawData = fs.readFileSync(resolvedPath, 'utf8')
155
- connectorData = JSON.parse(rawData)
156
- logger.info(`Loaded connector data from ${resolvedPath}`)
157
- } catch (err) {
158
- logger.error(`Failed to load connector data from ${dataPath}: ${err.message}`)
159
- return
160
- }
161
-
162
143
  // Compile template based on format (without title - these pages are meant to be included)
163
144
  const helperName = format === 'table' ? 'renderConnectFieldsTable' : 'renderConnectFields'
164
145
  const fieldOnlyTemplate = handlebars.compile(`{{{${helperName} children}}}`)
@@ -176,8 +157,70 @@ module.exports.register = function ({ config }) {
176
157
  return
177
158
  }
178
159
 
160
+ let connectorData
161
+ // Look for any versioned JSON attachment in the components module
162
+ // (i.e. modules/components/attachments/connect-X.Y.Z.json)
163
+ const attachments = contentCatalog.findBy({
164
+ component: 'redpanda-connect',
165
+ version: componentVersion.version,
166
+ module: 'components',
167
+ family: 'attachment'
168
+ })
169
+
170
+ // Find all versioned connector JSON attachments and sort by semver
171
+ const versionedAttachmentPattern = /^connect-(\d+)\.(\d+)\.(\d+)\.json$/
172
+ const matchingAttachments = attachments
173
+ .map((file) => {
174
+ const relative = file.src?.relative || ''
175
+ const basename = relative.split('/').pop()
176
+ const match = versionedAttachmentPattern.exec(basename)
177
+ if (match) {
178
+ return {
179
+ file,
180
+ version: {
181
+ major: parseInt(match[1], 10),
182
+ minor: parseInt(match[2], 10),
183
+ patch: parseInt(match[3], 10),
184
+ string: `${match[1]}.${match[2]}.${match[3]}`
185
+ }
186
+ }
187
+ }
188
+ return null
189
+ })
190
+ .filter(Boolean)
191
+ .sort((a, b) => {
192
+ // Sort by major, then minor, then patch (descending)
193
+ if (a.version.major !== b.version.major) return b.version.major - a.version.major
194
+ if (a.version.minor !== b.version.minor) return b.version.minor - a.version.minor
195
+ return b.version.patch - a.version.patch
196
+ })
197
+
198
+ if (matchingAttachments.length > 1) {
199
+ const versions = matchingAttachments.map(m => m.version.string).join(', ')
200
+ logger.warn(`Multiple versioned connector JSON attachments found (${versions}). Using highest version: ${matchingAttachments[0].version.string}`)
201
+ }
202
+
203
+ const attachment = matchingAttachments[0]?.file
204
+
205
+ if (!attachment) {
206
+ logger.warn('No JSON attachment found in the components module of the redpanda-connect content catalog. Skipping field-only page generation.')
207
+ return
208
+ }
209
+
210
+ try {
211
+ connectorData = JSON.parse(attachment.contents.toString('utf8'))
212
+ logger.info(`Loaded connector data from content catalog attachment: ${attachment.src?.relative || 'unknown'}`)
213
+ } catch (err) {
214
+ logger.error(`Failed to parse connector data from content catalog attachment: ${err.message}`)
215
+ return
216
+ }
217
+
179
218
  let pagesGenerated = 0
180
219
 
220
+ // Get origin from first existing page in component (for git metadata)
221
+ const existingPages = contentCatalog.getPages((page) => page.src.component === 'redpanda-connect')
222
+ const origin = existingPages.length > 0 ? existingPages[0].src.origin : { type: 'generated' }
223
+
181
224
  // Iterate over each type (inputs, outputs, processors, etc.)
182
225
  for (const [type, items] of Object.entries(connectorData)) {
183
226
  if (!Array.isArray(items)) continue
@@ -206,10 +249,6 @@ module.exports.register = function ({ config }) {
206
249
  const typeDir = type.endsWith('s') ? type : `${type}s`
207
250
  const relative = `fields/${typeDir}/${item.name}.adoc`
208
251
 
209
- // Get origin from first existing page in component (for git metadata)
210
- const existingPages = contentCatalog.getPages((page) => page.src.component === 'redpanda-connect')
211
- const origin = existingPages.length > 0 ? existingPages[0].src.origin : { type: 'generated' }
212
-
213
252
  // Create a fake absolute path for generated files (used by logger)
214
253
  const fakeAbspath = path.join(os.tmpdir(), 'generated-fields-only', relative)
215
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "4.17.0",
3
+ "version": "4.17.1",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",