Skip to content

Conversation

@JakeSCahill
Copy link
Contributor

@JakeSCahill JakeSCahill commented Oct 29, 2025

This pull request introduces several improvements and fixes to the property extraction and documentation generation tooling. The main changes focus on more accurate property type detection, improved handling of related topics in documentation, enhanced error reporting and statistics, and better parsing of C++ patterns for property values.

Property extraction and documentation generation improvements:

  • Improved property type detection for topic properties, adding explicit overrides for certain properties and refining boolean/string heuristics. For example, redpanda.remote.readreplica is now treated as a string, while redpanda.iceberg.delete is treated as a boolean. Additionally, the "Accepted values" section is now omitted for boolean properties. [1] [2]
  • Enhanced error reporting and statistics in generateAllDocs, including tracking and reporting undocumented properties, percentage of properties rendered, and improved summary output. Error reports now include properties missing descriptions, deprecated properties, and those not documented. [1] [2] [3]
  • Improved parsing and formatting of C++ property value patterns: digit separators (apostrophes) are now removed from numeric literals, and std::chrono literals are parsed and rendered in a concise format (e.g., std::chrono::minutes{5}"5 min"). Enum-like patterns are now more robustly detected. [1] [2] [3]
  • More robust and context-aware rendering of related topics in documentation: new helpers (allTopicsConditional, parseRelatedTopic) enable conditional rendering of related topics for cloud/self-managed/normal contexts, and templates are updated to use these helpers for both property and topic-property documentation. [1] [2] [3] [4] [5]
  • Minor refactoring and cleanup for clarity and maintainability, such as simplifying helper registration and removing redundant comments in template registration. [1] [2]

Other:

  • Version bump in package.json from 4.10.7 to 4.10.8.

@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for docs-extensions-and-macros ready!

Name Link
🔨 Latest commit 5398767
🔍 Latest deploy log https://app.netlify.com/projects/docs-extensions-and-macros/deploys/69049eee2bad1d000803aec8
😎 Deploy Preview https://deploy-preview-147--docs-extensions-and-macros.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR updates the property-extractor tooling to support cloud-aware rendering of documentation. It bumps the version to 4.10.8 and adds cloud/self-managed environment-specific rendering capabilities. Key changes include: two new helper functions (parseRelatedTopic and allTopicsConditional) for parsing and categorizing related topics; refactored Handlebars templates (property.hbs, topic-property.hbs) to render topic lists based on deployment environment; enhanced generate-handlebars-docs.js with a new generatePropertyPartials() function and updated generateErrorReports() signature to track documented properties and report undocumented ones.

Sequence Diagram

sequenceDiagram
    participant Main as generate-handlebars-docs.js
    participant PartialGen as generatePropertyPartials
    participant Template as property.hbs / topic-property.hbs
    participant Helper1 as allTopicsConditional
    participant Helper2 as parseRelatedTopic
    
    Main->>PartialGen: generatePropertyPartials(properties, dir)
    PartialGen->>PartialGen: batch by property groups
    PartialGen->>PartialGen: accumulate documented props
    PartialGen->>Template: render each group
    
    Template->>Helper1: allTopicsConditional(related_topics)
    Helper1-->>Template: sectionType (cloud/self-managed/normal)
    
    Template->>Helper2: parseRelatedTopic(each topic)
    Helper2-->>Template: {type, value}
    
    Template-->>PartialGen: rendered partial
    PartialGen-->>Main: written files + documentedProps[]
    
    Main->>Main: compute undocumented properties
    Main->>Main: call generateErrorReports(properties, documentedProps)
    Main-->>Main: error report with undocumented list
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

  • generate-handlebars-docs.js: Significant refactoring with new partial generation logic, documented property accumulation, and updated error reporting flow; logic density and flow changes require careful review
  • property.hbs & topic-property.hbs: Both templates have been substantially reworked with new multi-branch conditional rendering paths for cloud/self-managed environments; requires tracing through all conditional branches and helper interactions
  • New helper functions (allTopicsConditional, parseRelatedTopic): While individually straightforward, the conditional categorization logic in allTopicsConditional has several branches that should be verified for correctness
  • API signature changes: The updated generateErrorReports(properties, documentedProperties = []) signature changes must be verified against all call sites and integration points

Possibly related PRs

Suggested reviewers

  • paulohtb6
  • kbatuigas

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Support related topics for cloud/self-managed only" directly addresses a significant aspect of the changeset. The PR introduces new helpers (allTopicsConditional and parseRelatedTopic) and updates Handlebars templates to enable conditional rendering of related topics based on their cloud-only or self-managed-only classification. While the changeset also includes other meaningful improvements such as enhanced error reporting for undocumented properties and refactored property grouping logic, the title accurately captures one of the core enhancements and refers to a real and substantial part of the change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed The pull request description directly aligns with the changeset provided. It specifically describes the addition of new helper functions (allTopicsConditional and parseRelatedTopic) for handling related topics across cloud/self-managed environments, the enhancement to error reporting with tracking of undocumented properties, updates to Handlebars templates for conditional rendering, and the version bump in package.json. The description provides meaningful detail about the changes and clearly relates to all major alterations reflected in the raw summary, including specific examples of property type detection improvements and parsing enhancements.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
tools/property-extractor/generate-handlebars-docs.js (5)

25-32: Avoid process.exit in library code; throw instead.

Fail fast, but don’t terminate the host process from a module. Throwing keeps behavior consistent in both CLI and programmatic use.

 Object.entries(helpers).forEach(([name, fn]) => {
   if (typeof fn !== 'function') {
-    console.error(`❌ Helper "${name}" is not a function`);
-    process.exit(1);
+    throw new TypeError(`Helper "${name}" is not a function`);
   }
   handlebars.registerHelper(name, fn);
 });

110-163: Deduplicate partial-generation logic; collect documentedProps via callback.

Inline generation (Lines 279-315) duplicates generatePropertyPartials. Refactor generatePropertyPartials to accept an onRender callback that records names, then call it from generateAllDocs. Less drift, single source of truth.

-function generatePropertyPartials(properties, partialsDir) {
+function generatePropertyPartials(properties, partialsDir, onRender /* (name: string) => void */) {
@@
-  Object.entries(propertyGroups).forEach(([type, props]) => {
+  Object.entries(propertyGroups).forEach(([type, props]) => {
     if (props.length === 0) return;
     props.sort((a, b) => String(a.name || '').localeCompare(String(b.name || '')));
     const selectedTemplate = type === 'topic' ? topicTemplate : propertyTemplate;
-    const content = props.map(p => selectedTemplate(p)).join('\n');
+    const content = props.map(p => {
+      if (typeof onRender === 'function' && p?.name) onRender(p.name);
+      return selectedTemplate(p);
+    }).join('\n');
     const filename = `${type}-properties.adoc`;
     fs.writeFileSync(path.join(propertiesPartialsDir, filename), AUTOGEN_NOTICE + content, 'utf8');
     console.log(`✅ Generated ${filename} (${props.length} properties)`);
     totalCount += props.length;
   });
@@
-  return totalCount;
+  return totalCount;
 }
-    // Wrap generatePropertyPartials to also collect property names
-    const originalWrite = fs.writeFileSync;
-    const propertyTemplate = handlebars.compile(
-      fs.readFileSync(getTemplatePath(path.join(__dirname, 'templates', 'property.hbs'), 'TEMPLATE_PROPERTY'), 'utf8')
-    );
-    const topicTemplate = handlebars.compile(
-      fs.readFileSync(getTemplatePath(path.join(__dirname, 'templates', 'topic-property.hbs'), 'TEMPLATE_TOPIC_PROPERTY'), 'utf8')
-    );
-
-    const propertiesPartialsDir = path.join(process.env.OUTPUT_PARTIALS_DIR, 'properties');
-    fs.mkdirSync(propertiesPartialsDir, { recursive: true });
-
-    const propertyGroups = { cluster: [], topic: [], broker: [], 'object-storage': [] };
-    Object.values(properties).forEach(p => {
-      if (!p.name || !p.config_scope) return;
-      if (p.config_scope === 'topic') propertyGroups.topic.push(p);
-      else if (p.config_scope === 'broker') propertyGroups.broker.push(p);
-      else if (p.config_scope === 'cluster') {
-        if (isObjectStorageProperty(p)) propertyGroups['object-storage'].push(p);
-        else propertyGroups.cluster.push(p);
-      }
-    });
-
-    Object.entries(propertyGroups).forEach(([type, props]) => {
-      if (props.length === 0) return;
-      props.sort((a, b) => String(a.name || '').localeCompare(String(b.name || '')));
-      const selectedTemplate = type === 'topic' ? topicTemplate : propertyTemplate;
-      const content = props.map(p => {
-        documentedProps.push(p.name);
-        return selectedTemplate(p);
-      }).join('\n');
-      const filename = `${type}-properties.adoc`;
-      originalWrite(path.join(propertiesPartialsDir, filename), AUTOGEN_NOTICE + content, 'utf8');
-      console.log(`✅ Generated ${filename} (${props.length} properties)`);
-      partialsCount += props.length;
-    });
+    // Use the single implementation and collect documented property names
+    partialsCount = generatePropertyPartials(
+      properties,
+      process.env.OUTPUT_PARTIALS_DIR,
+      (name) => documentedProps.push(name)
+    );

Also applies to: 279-315


128-145: Scope grouping looks good; verify deprecation handling.

Grouping via switch is clear and robust (incl. object-storage). Confirm whether deprecated properties should appear in these main partials; if not, filter them out when grouping.

-  Object.values(properties).forEach(prop => {
-    if (!prop.name || !prop.config_scope) return;
+  Object.values(properties).forEach(prop => {
+    if (!prop.name || !prop.config_scope || prop.is_deprecated) return;

Also applies to: 150-159


228-259: Error report expansion is solid; consider key-name disambiguation.

Empty/Deprecated/Undocumented metrics and logs are clear. For repos where property keys may differ from p.name, optionally include both for easier follow-up.

-  Object.entries(properties).forEach(([key, p]) => {
-    const name = p.name || key;
+  Object.entries(properties).forEach(([key, p]) => {
+    const name = p.name || key;
     if (!p.description || !p.description.trim()) emptyDescriptions.push(name);
     if (p.is_deprecated) deprecatedProperties.push(name);
     if (!documentedSet.has(name)) undocumented.push(name);
   });

Optionally return tuples for undocumented to show key→name mapping:

-    undocumented_properties: undocumented.sort(),
+    undocumented_properties: undocumented.sort(),
+    // optionally: undocumented_pairs: undocumentedPairs.sort(([a],[b]) => a.localeCompare(b)),

325-349: Compute coverage using documentedProps length for resilience.

If templates ever skip rendering certain items, basing the percentage on documentedProps is more accurate than partialsCount.

-  const pctRendered = totalProperties
-    ? ((partialsCount / totalProperties) * 100).toFixed(2)
-    : '0.00';
+  const pctRendered = totalProperties
+    ? ((documentedProps.length / totalProperties) * 100).toFixed(2)
+    : '0.00';
tools/property-extractor/helpers/allTopicsConditional.js (1)

1-19: Classification logic looks solid; minor maintainability nit

Works as intended for mixed/invalid inputs. Consider centralizing the two prefix strings in a shared constant to avoid drift with parseRelatedTopic.

tools/property-extractor/templates/topic-property.hbs (1)

82-124: Conditional rendering is correct; consider suppressing empty headers

The branching via allTopicsConditional + per-item parse is sound. With the parse fix, bullets won’t render for invalid/blank items. Optionally, suppress the “Related topics:” header if no items render (e.g., add a tiny helper like hasRenderableTopics to pre-check).

Please spot-check with samples:

  • All cloud-only
  • All self-managed-only
  • Mixed (including blanks/non-strings)
  • Empty array
tools/property-extractor/templates/property.hbs (1)

95-137: Related topics branching LGTM; optional empty-header guard

Mirrors topic-property.hbs correctly. After the parse fix, bullets won’t print for invalid/blank entries. Optionally add a pre-check to avoid rendering the “Related topics:” header when no items will display.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8b136fb and 709bb45.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • package.json (1 hunks)
  • tools/property-extractor/generate-handlebars-docs.js (7 hunks)
  • tools/property-extractor/helpers/allTopicsConditional.js (1 hunks)
  • tools/property-extractor/helpers/index.js (1 hunks)
  • tools/property-extractor/helpers/parseRelatedTopic.js (1 hunks)
  • tools/property-extractor/templates/property.hbs (3 hunks)
  • tools/property-extractor/templates/topic-property.hbs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tools/property-extractor/helpers/parseRelatedTopic.js (1)
tools/property-extractor/helpers/allTopicsConditional.js (1)
  • trimmed (12-12)
tools/property-extractor/helpers/allTopicsConditional.js (1)
tools/property-extractor/helpers/parseRelatedTopic.js (1)
  • trimmed (5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules - docs-extensions-and-macros
  • GitHub Check: Header rules - docs-extensions-and-macros
  • GitHub Check: Pages changed - docs-extensions-and-macros
🔇 Additional comments (6)
package.json (1)

3-3: Verify that the semver bump aligns with the API changes.

The version is bumped from 4.10.7 to 4.10.8 (patch), which typically signals backward-compatible changes. However, the PR summary indicates new exported helper functions (parseRelatedTopic, allTopicsConditional) and changes to the generateErrorReports signature. Please confirm:

  1. Are the new helpers added to the package exports? If so, this may warrant a minor version bump (4.11.0).
  2. Is the generateErrorReports signature change backward-compatible, or does it constitute a breaking change requiring a major bump?
  3. Is generatePropertyPartials a new export? If so, this also suggests a minor version bump.
tools/property-extractor/generate-handlebars-docs.js (3)

156-156: LGTM: Writes grouped partials with AUTOGEN notice.

File creation and encoding are correct; directory is pre-created.


194-194: LGTM: Deprecated properties output path and write.

Write location respects OUTPUT_PARTIALS_DIR; prepend AUTOGEN notice; good.


200-200: Nit: Header clarified.

Descriptive comment improves readability.

tools/property-extractor/templates/property.hbs (1)

35-40: BYOC note wording change is fine

Text-only improvement; no behavioral impact.

tools/property-extractor/helpers/index.js (1)

14-15: All set; helpers are automatically registered

Both parseRelatedTopic and allTopicsConditional are correctly exported and will be automatically registered through the existing Object.entries(helpers).forEach() pattern in tools/property-extractor/generate-handlebars-docs.js (line 27). Both helpers are already in active use across the Handlebars templates, confirming the wiring is complete.

@JakeSCahill JakeSCahill requested a review from paulohtb6 October 30, 2025 15:07
@JakeSCahill JakeSCahill requested a review from paulohtb6 October 31, 2025 07:59
@JakeSCahill JakeSCahill merged commit 7cd4ae4 into main Oct 31, 2025
17 checks passed
@JakeSCahill JakeSCahill deleted the conditional branch October 31, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants