Skip to content

Topic properties auto #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Topic properties auto #126

wants to merge 7 commits into from

Conversation

paulohtb6
Copy link
Contributor

Introduce new topic properties automation.

Extension of the existing cluster properties automation.

As opposed to other automations, the one about topic properties show significant challenges regarding min-max identification. Topic properties don't have internal descriptions. The existing ones on docs are hand-written.

This automation serves the purpose of identifying the new properties. However, a lot of manual work must be invested to make it "publish ready".

You can run it through makefile with:

make topic-properties

or through the CLI with

npx run generate topic-properties-docs TAG=<redpanda-tag>

add treesitter

working version

working version

performance
Copy link

netlify bot commented Aug 22, 2025

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

Name Link
🔨 Latest commit 23ac50b
🔍 Latest deploy log https://app.netlify.com/projects/docs-extensions-and-macros/deploys/68a895c6df044700086f5e0b
😎 Deploy Preview https://deploy-preview-126--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.

Copy link
Contributor

coderabbitai bot commented Aug 22, 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

Adds a new automation CLI command topic-property-docs in bin/doc-tools.js to build topic property docs for a tag and optionally diff them against an old tag. Extends the Makefile with a topic-properties target that runs a new Python extractor (topic_property_extractor.py) to generate JSON and AsciiDoc outputs, plus updates .PHONY and adds a top-level build target. Updates generate_docs.py to produce a topic-properties.adoc page and classify topic-related definitions via DEFINED_IN_MAPPING. Introduces topic_property_extractor.py that discovers topic properties, enums, and cluster mappings, emits JSON, and can generate AsciiDoc.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant CLI as bin/doc-tools.js (topic-property-docs)
  participant MK as Makefile (topic-properties)
  participant EX as topic_property_extractor.py
  participant GD as generate_docs.py
  participant FS as FS (autogenerated/)

  Dev->>CLI: Run topic-property-docs --tag <newTag> [--diff <oldTag>]
  alt --diff provided
    CLI->>FS: Check autogenerated/<oldTag>/properties/ exists?
    opt Missing
      CLI->>MK: make topic-properties TAG=<oldTag>
      MK->>EX: Run extractor -> topic-properties-output.json
      MK->>EX: Generate topic-properties.adoc
      MK->>GD: (existing flows for other pages)
      EX->>FS: Write JSON/ADOC under autogenerated/<oldTag>/properties/
    end
  end
  CLI->>MK: make topic-properties TAG=<newTag>
  MK->>EX: Run extractor -> topic-properties-output.json
  MK->>EX: Generate topic-properties.adoc
  MK->>GD: (existing broker/cluster/cloud generation unaffected)
  EX->>FS: Write JSON/ADOC under autogenerated/<newTag>/properties/
  alt --diff provided
    CLI->>FS: diffDirs('properties', oldTag, newTag)
    FS-->>CLI: Patch under autogenerated/diffs/
  end
  CLI-->>Dev: Exit 0
  note over EX,GD: New topic page: topic-properties.adoc<br/>Defined-in mapping includes topic sources
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • JakeSCahill
  • asimms41
  • Feediver1
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch topic-properties-auto

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

🧹 Nitpick comments (9)
tools/property-extractor/topic_property_extractor.py (7)

7-7: Remove unused imports.

The Tuple and Set types are imported but never used in the code.

Apply this diff to remove the unused imports:

-from typing import Dict, List, Optional, Tuple, Set
+from typing import Dict, List, Optional

106-108: Silently catching all exceptions masks potential issues.

The broad exception handling without any logging makes debugging difficult if file parsing fails for unexpected reasons.

Consider at least logging the error for debugging:

 except Exception as e:
     # Skip files that can't be read
-    pass
+    print(f"Debug: Skipping {file_path}: {e}", file=sys.stderr)

317-317: Remove unused variable assignment.

The variable topic_candidates is assigned but never used.

Remove the unused variable assignment:

-        topic_candidates = []
-        
         # Remove common prefixes/suffixes
         cleaned = cluster_prop

182-184: Silent exception handling masks potential errors.

Similar to the previous comment, catching all exceptions without logging makes debugging difficult.

Consider logging the error for debugging purposes:

 except Exception as e:
     # Skip files that can't be read
-    pass
+    print(f"Debug: Error scanning enums in {file_path}: {e}", file=sys.stderr)

280-280: Unused exception variable.

The exception variable e is captured but never used.

Apply this diff to clean up the unused variable:

-        except Exception as e:
+        except Exception:
             return {}

476-477: Unnecessary directory existence check.

The os.makedirs with exist_ok=True already handles the case where the directory exists, making the conditional check redundant.

Simplify the code by removing the unnecessary check:

-        output_dir = os.path.dirname(output_path)
-        if output_dir:  # Only create directory if there's a path
-            os.makedirs(output_dir, exist_ok=True)
+        os.makedirs(os.path.dirname(output_path), exist_ok=True)

412-481: Consider refactoring long method for better maintainability.

The generate_topic_properties_adoc method is quite long (~70 lines) with hardcoded AsciiDoc content. Consider extracting the template content to a separate file or using a template engine for better maintainability.

Would you like me to help refactor this method to use a template-based approach similar to how other documentation generators in this codebase work?

tools/property-extractor/Makefile (2)

1-1: Consider adding standard Makefile targets.

The static analyzer correctly identifies that standard phony targets all and test are missing. While not critical, adding these would improve the Makefile's adherence to conventions.

Add standard targets for better convention compliance:

-.PHONY: build venv clean redpanda-git treesitter topic-properties generate-docs check
+.PHONY: all test build venv clean redpanda-git treesitter topic-properties generate-docs check
+
+# Default target
+all: build
+
+# Test target (placeholder - add actual tests as needed)
+test:
+	@echo "No tests configured yet"

114-115: Inconsistent output directory usage.

The topic-properties target writes directly to $(OUTPUT_DIR) while the main build target writes to gen/ first and then copies to $(OUTPUT_DIR). This inconsistency could cause confusion.

Consider following the same pattern as the main build for consistency:

 	@cd $(TOOL_ROOT) && \
 	  $(PYTHON) topic_property_extractor.py \
 	    --source-path $(REDPANDA_SRC) \
-	    --output-json "$(OUTPUT_DIR)/topic-properties-output.json" \
-	    --output-adoc "$(OUTPUT_DIR)/topic-properties.adoc"
+	    --output-json "gen/topic-properties-output.json" \
+	    --output-adoc "gen/topic-properties.adoc"
+	@echo "📄 Copying topic properties outputs to $(OUTPUT_DIR)…"
+	@mkdir -p "$(OUTPUT_DIR)"
+	@cp "$(TOOL_ROOT)/gen/topic-properties-output.json" "$(OUTPUT_DIR)/"
+	@cp "$(TOOL_ROOT)/gen/topic-properties.adoc" "$(OUTPUT_DIR)/"
 	@echo "✅ Topic properties extracted"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear 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 34efcf8 and 69e6fb6.

📒 Files selected for processing (4)
  • bin/doc-tools.js (1 hunks)
  • tools/property-extractor/Makefile (2 hunks)
  • tools/property-extractor/json-to-asciidoc/generate_docs.py (7 hunks)
  • tools/property-extractor/topic_property_extractor.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tools/property-extractor/topic_property_extractor.py (1)
tools/property-extractor/json-to-asciidoc/generate_docs.py (1)
  • main (341-488)
🪛 Ruff (0.12.2)
tools/property-extractor/topic_property_extractor.py

7-7: typing.Tuple imported but unused

Remove unused import

(F401)


7-7: typing.Set imported but unused

Remove unused import

(F401)


106-106: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


182-182: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


280-280: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


317-317: Local variable topic_candidates is assigned to but never used

Remove assignment to unused variable topic_candidates

(F841)

🪛 checkmake (0.2.2)
tools/property-extractor/Makefile

[warning] 1-1: Missing required phony target "all"

(minphony)


[warning] 1-1: Missing required phony target "test"

(minphony)


[warning] 4-4: Target body for "build" exceeds allowed length of 5 (9).

(maxbodylength)

⏰ 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 (4)
tools/property-extractor/json-to-asciidoc/generate_docs.py (3)

110-111: LGTM! Consistent with existing architecture pattern.

The mapping addition for topic properties follows the established pattern of the existing configuration groups.


70-83: LGTM! Well-structured constants for topic properties page.

The new constants follow the existing pattern and provide appropriate documentation for topic properties. The structure aligns well with the existing page documentation patterns for broker, cluster, and cloud properties.


358-358: LGTM! Topic properties cleanly integrated into the generation pipeline.

The implementation follows the established pattern exactly, maintaining consistency with how broker, cluster, and cloud properties are processed and written.

Also applies to: 408-408, 444-449, 463-463

bin/doc-tools.js (1)

780-813: LGTM! Clean implementation following existing patterns.

The new topic-property-docs command follows the established pattern of the existing property-docs command perfectly, including proper error handling and diff functionality.

@paulohtb6 paulohtb6 mentioned this pull request Aug 22, 2025
4 tasks
paulohtb6 and others added 4 commits August 22, 2025 11:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

1 participant