-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add testable documentation examples to featuregate package #13159
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?
Add testable documentation examples to featuregate package #13159
Conversation
featuregate/doc.go
Outdated
// fmt.Println("Stage:", gate.Stage()) | ||
// fmt.Println("ReferenceURL:", gate.ReferenceURL()) | ||
// fmt.Println("FromVersion:", gate.FromVersion()) | ||
// fmt.Println("IsEnabled:", gate.IsEnabled()) |
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.
Rather than outputting every attribute here, I would show how to check the gate is enabled. That's the main thing someone looking to use this package will want to do.
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.
Thank you for the feedback!
I've updated the documentation to focus on the main use case: checking if a feature gate is enabled. The example now shows how to register a gate and use IsEnabled()
, and the second example demonstrates registering, setting, and visiting gates in a concise way.
Let me know if you have any further suggestions or if there’s anything else I should adjust!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13159 +/- ##
=======================================
Coverage 91.29% 91.29%
=======================================
Files 509 509
Lines 28737 28737
=======================================
Hits 26235 26235
Misses 1988 1988
Partials 514 514 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR adds clear, testable documentation examples to the featuregate package. The examples demonstrate:
How to create a feature gate and print its properties.
How to register a feature gate in a custom registry, set its value, and visit all registered gates.
Updated doc.go with concise usage examples in Go doc comment format.
Added
example_test.go
with runnable Go example functions, ensuring the documentation is both visible on pkg.go.dev and verified bygo test
.These examples help new users understand how to use the featuregate API and ensure the documentation remains correct and up to date.!