-
Notifications
You must be signed in to change notification settings - Fork 1.6k
📖 Add docs: custom markers for unsupported file extensions #5107
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: master
Are you sure you want to change the base?
📖 Add docs: custom markers for unsupported file extensions #5107
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nerdeveloper The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @nerdeveloper. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
ddb8cdb
to
161acff
Compare
- You're building an **external plugin** for a language not natively supported by Kubebuilder | ||
- You want to scaffold files with custom extensions (`.rs`, `.java`, `.tpl`, `.py`, etc.) | ||
- Your file extensions aren't (and shouldn't be) part of the core `commentsByExt` map | ||
- You need to maintain scaffolding markers in non-Go files |
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.
I think the documentation could be How to create Custom Markers.
For those who use Kubebuilder as a library, it would be possible to create their own custom markers, regardless of whether it is for an extension valid or not for Golang projects.
So, it would not only be valid for external references
builder.WriteString(":") | ||
} | ||
return builder.String() | ||
} |
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.
Could you let me know if you tested this example?
Can it work without any change in the code at this moment?
Is the code covered with tests to ensure that this example would be possible?
} | ||
``` | ||
|
||
## Complete Example: Rust Plugin with Custom Markers |
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.
Do we need all those examples?
Could we not have only 1 example?
How could we simplify the doc and its maintainability?
Just to share what is required
## Best Practices | ||
|
||
1. **Use Clear Prefixes**: Choose a unique prefix for your plugin to avoid conflicts (e.g., `+rust:scaffold:`, `+java:scaffold:`) | ||
|
||
2. **Handle Comments Correctly**: Different languages have different comment syntax. Make sure to map the correct comment style for each file extension. | ||
|
||
3. **Error Handling**: Always validate file extensions and return clear error messages when unsupported files are encountered. | ||
|
||
4. **Maintain Compatibility**: When possible, follow the same patterns as Kubebuilder's core marker system to maintain consistency. | ||
|
||
5. **Document Your Markers**: Clearly document what markers your plugin supports and where they should be placed. | ||
|
||
6. **Testing**: Test your marker implementation with various file types and edge cases. |
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.
Best Practices is something subjective, I think it's better to avoid this term.
} | ||
``` | ||
|
||
## Conclusion |
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.
Could you please review the other documentation we have?
We do not use a conclusion. We should always follow the same layout and standards.
Hi @camilamacedo86, Thank you for the review feedback! I've updated the documentation to address your comments: ✅ Changed title to "Creating Custom Markers" (broader scope, not just for unsupported extensions) Regarding testing: I performed minimal testing of the marker generation logic by creating a standalone Go program that tests the core marker creation code. The test confirms:
However, I have NOT tested the complete integration with external plugins end-to-end (the full example with templates and plugin integration). Question: What would you prefer for this documentation?
Please let me know your preference, and I'll update accordingly! |
Shows how to use Kubebuilder as a library to create custom marker support for external plugins with non-Go file extensions like .rs, .java, .py
161acff
to
51faf4e
Compare
Summary
Related
Test Plan