-
Notifications
You must be signed in to change notification settings - Fork 475
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
Add notes to explain how API fields should be documented in conventions #1069
Add notes to explain how API fields should be documented in conventions #1069
Conversation
Skipping CI for Draft Pull Request. |
Couple of drive-by thoughts:
|
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.
We do have some other similar advice in the conventions file, and this addition fits thematically. We also have the dev-guide directory, and so you might consider adding a separate file with API advice there if there is going to be a lot of information to document over time.
CONVENTIONS.md
Outdated
// + This can be used to add notes for developers that aren't intended for end users. | ||
type Example struct { | ||
// Type allows the user to determine how to interpret the example given. | ||
// It must be set to one of the following values; Documentation, Convention, or Mixed. |
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.
Is it necessary to type out the values for an enum if they're also included in the kubebuilder validation directive?
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.
If you don't add them to the godoc, then they won't appear in oc explain
as it doesn't print out the enum values. So i think the convention has been to include them in the documentation explicitly as well as having the enum for validation purposes
Explaining this makes sense. Since so much of the openshift API is now configuration API describing how our product can be configured, detailed documentation that will automatically appear in everything consuming openAPI is extremely valuable and serves as a good starting point for writing online documentation. |
Good question, not that I'm aware of. I'm happy to expand on some of the style guidelines if we want to. I'll check in with docs as well if they have anything. One thing I was thinking is that, for example, a
Not sure I know this one, I think a
Yeah I noticed the other notes about API conventions in here and how we differ from upstream Kube conventions, I think if we are going to put this in the dev-guide section we should move the rest of the API conventions from this doc as well. |
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.
This looks excellent. I'm glad we're getting more of these conventions formally documented.
// + --- | ||
// + Note that this comment line will not end up in the generated API schema as it is | ||
// + preceded by a `+`. The `---` also prevents anything after it from being added to | ||
// + the swagger docs. | ||
// + This can be used to add notes for developers that aren't intended for end users. |
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.
TIL!
dev-guide/api-conventions.md
Outdated
// + This can be used to add notes for developers that aren't intended for end users. | ||
type Example struct { | ||
// Type allows the user to determine how to interpret the example given. | ||
// It must be set to one of the following values; Documentation, Convention, or Mixed. |
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.
// It must be set to one of the following values; Documentation, Convention, or Mixed. | |
// It must be set to one of the following values: Documentation, Convention, or Mixed. |
dev-guide/api-conventions.md
Outdated
type Example struct { | ||
// Type allows the user to determine how to interpret the example given. | ||
// It must be set to one of the following values; Documentation, Convention, or Mixed. | ||
// +kubebuilder:validation:Enum:Documentation;Convention;Mixed |
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.
// +kubebuilder:validation:Enum:Documentation;Convention;Mixed | |
// +kubebuilder:validation:Enum=Documentation;Convention;Mixed |
// Documentation allows the user to define documentation for the example. | ||
// When this value is provided, the `type` must be set to either `Documentation` or `Mixed`. | ||
// The content of the documentation is free form text but must be no longer than 512 characters. | ||
// +kubebuilder:validation:MaxLength:=512 |
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've noticed that we sometimes use :=
and sometimes use =
, and I haven't been able to find any documentation on the distinction. As far as I can tell, they are interchangeable in practice, and if that is true, I would prefer we settle on a preferred style. We can leave that for a later PR if it requires debate.
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 have erred towards :=
because that's how it's represented in the kubebuilder documentation. I don't think there's any different from a usage perspective though
dev-guide/api-conventions.md
Outdated
// + Note: In this example, the `platform` refers to OpenShift Container Platform and not | ||
// + a cloud provider (commonly referred to among engineers as platforms). |
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'm not sure this is a good example use of +
. The clarification could be useful to end users reading the oc explain
output or Swagger documentation, and really, the text could be written to avoid the ambiguous use of "platform" in the first place.
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.
Perhaps I should pull this out of the Godoc in the example. The wording here is something that has been recommended to me across several API reviews so I thought it was standard wording.
Perhaps we can come up with a different wording that has less ambiguity?
CC @deads2k in case you have an opinion on this wording?
Given the feedback so far, it seems like we have a good basis here to build upon. To avoid this becoming a complete documentation through a single PR, I'm going to defer the question about marking fields deprecated for now as that seems like it deserves its own section. I will follow up to add a deprecated fields section once I've done a bit more research on that |
LGTM. |
@JoelSpeed there are a couple of suggestions on the review. Did you want to resolve those here, or iterate? /assign @dhellmann |
2539b85
to
4164fa0
Compare
@dhellmann Thanks for the prompt, missed those. I think for now let's merge this and iterate on the outstanding points. I'll try to get some opinions on the wording around "platform" and follow up to clarify that and the deprecation point |
@JoelSpeed that works for me /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dhellmann The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
dev-guide/api-conventions.md
Outdated
|
||
type <string> | ||
Type allows the user to determine how to interpret the example given. It must be set to one of the following | ||
values; Documentation, Convention, or Mixed. |
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.
values; Documentation, Convention, or Mixed. | |
values: Documentation, Convention, or Mixed. |
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.
Thanks, missed that while updating the other location, have updated now
4164fa0
to
09e76ff
Compare
@JoelSpeed: all tests passed! Full PR test history. Your PR dashboard. 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/test-infra repository. I understand the commands that are listed here. |
Thanks! |
As an API reviewer, I would like to see thorough documentation added to new API fields so that I can understand the mechanics of the changes we are adding to our API and so that customers can understand how they can and can't use the new fields.
To encourage better documentation on ur APIs, I think we should add some notes to the conventions prompting users with a number of questions to think about when writing their godoc and some examples of how this might look in practice.
This is a first draft of this to gather initial feedback:
ToDo: