-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore: clean up kubebuilder annotations in executor_swagger.md #15099
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
base: main
Are you sure you want to change the base?
chore: clean up kubebuilder annotations in executor_swagger.md #15099
Conversation
Add a Python script to make the generated executor swagger documentation more readable by converting annotations to a human-readable "Validation" section: - +optional → **Validation:** Optional. - +default=X → **Validation:** Default: X. - +kubebuilder:validation:Minimum=X → **Validation:** Minimum: X. - +kubebuilder:validation:Maximum=X → **Validation:** Maximum: X. - +kubebuilder:validation:MinLength=X → **Validation:** Minimum length: X. - +kubebuilder:validation:MaxLength=X → **Validation:** Maximum length: X. - +kubebuilder:validation:MinItems=X → **Validation:** Minimum items: X. - +kubebuilder:validation:MaxItems=X → **Validation:** Maximum items: X. - +kubebuilder:validation:Pattern=X → **Validation:** Pattern: X. - +kubebuilder:validation:Enum=A;B → **Validation:** Valid values: A, B. Internal annotations are removed: +patchStrategy, +patchMergeKey, +listType, +listMapKey, +featureGate, +structType, +protobuf, +union, +enum, +kubebuilder:validation:XValidation (complex CEL rules). Signed-off-by: Alan Clucas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a Python script to clean up kubebuilder annotations in the generated executor_swagger.md documentation, making it more readable by converting raw annotations into a structured "Validation" section.
Key Changes:
- Adds
hack/docgen/clean_swagger_md.pyto parse and transform kubebuilder annotations - Converts annotations like
+optional,+kubebuilder:validation:Minimum=X, etc. into human-readable validation descriptions - Removes internal annotations (
+patchStrategy,+listType,+protobuf, etc.) that are not useful in user-facing documentation
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hack/docgen/clean_swagger_md.py | New Python script that parses annotations from markdown, converts them to readable validation sections, and removes internal implementation details |
| docs/executor_swagger.md | Generated documentation with cleaned-up annotations - all kubebuilder annotations are now converted to "Validation:" sections with semicolon-separated constraints |
| Makefile | Updated codegen target to use the new Python script instead of the previous sed command that only fixed interface{} links |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
|
@CodeRabbit full review |
✅ Actions performedFull review triggered. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe Makefile's codegen target replaces a direct sed command with an invocation of a new Python script ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
hack/docgen/clean_swagger_md.py (1)
60-64: Numeric validation regex doesn't match negative values.Same issue as in
hack/docs/clean_swagger_md.py- the regex\d+won't capture negative numbers forMinimumandMaximumconstraints. This was flagged in a past review.for key, validator in validation_fields: text, annotations[key] = extract_and_remove( text, - rf'\+kubebuilder:validation:{validator}=(\d+)', - rf'\+kubebuilder:validation:{validator}=\d+') + rf'\+kubebuilder:validation:{validator}=([+-]?\d+)', + rf'\+kubebuilder:validation:{validator}=[+-]?\d+')
🧹 Nitpick comments (1)
hack/docs/clean_swagger_md.py (1)
60-64: Inconsistency withhack/docgen/clean_swagger_md.pyfor numeric validation patterns.This file uses
\d+for numeric validations, whilehack/docgen/clean_swagger_md.pyuses[+-]?\d+which also handles negative values. ForMinimumandMaximumconstraints, negative values are valid (e.g., temperatures, offsets). Consider aligning with the other script.for key, validator in validation_fields: text, annotations[key] = extract_and_remove( text, - rf'\+kubebuilder:validation:{validator}=(\d+)', - rf'\+kubebuilder:validation:{validator}=\d+') + rf'\+kubebuilder:validation:{validator}=([+-]?\d+)', + rf'\+kubebuilder:validation:{validator}=[+-]?\d+')
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Makefile(1 hunks)hack/docgen/clean_swagger_md.py(1 hunks)hack/docs/clean_swagger_md.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
hack/docs/clean_swagger_md.py (1)
hack/docgen/clean_swagger_md.py (3)
extract_and_remove(12-18)parse_annotations(21-97)build_validation_section(100-130)
🔇 Additional comments (3)
Makefile (1)
356-357: LGTM!The Makefile correctly invokes the new Python script to clean up executor_swagger.md during code generation. The comment clearly explains the purpose.
hack/docgen/clean_swagger_md.py (1)
215-221: Encoding handling is correct.The
encoding='utf-8'parameter is properly specified for both read and write operations, addressing the concern from the previous review.hack/docs/clean_swagger_md.py (1)
1-227: Verify existence ofhack/docgen/clean_swagger_md.pyand compare withhack/docs/clean_swagger_md.py.The review comment claims duplicate scripts exist with minor differences, but this requires manual verification of whether both files exist in the repository and confirmation of their actual similarities and differences before determining if consolidation is necessary.
Signed-off-by: Alan Clucas <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Motivation
We've got a lot of messy comments coming through into executor_swagger.md these days. The few we used to allow through have been supplemented by a lot of kubebuilder text.
Modifications
Add a Python script to make the generated executor swagger documentation more readable by converting annotations to a human-readable "Validation" section:
Internal annotations are removed: +patchStrategy, +patchMergeKey, +listType, +listMapKey, +featureGate, +structType, +protobuf, +union, +enum, +kubebuilder:validation:XValidation (complex CEL rules).
Verification
NA
Documentation
Yup, this is all about documentation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.