-
Notifications
You must be signed in to change notification settings - Fork 472
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
Make an editorial pass over the API documentation. #509
Conversation
/lgtm |
Looks like you'll need to revert some changes to pass go linting though, godoc requires constant comments to be phrased |
/lgtm cancel |
On 21 Dec 2020, at 10:02 am, Nick Young ***@***.***> wrote:
Looks like you'll need to revert some changes to pass go linting though, godoc requires constant comments to be phrased CONSTANTNAME does something.
Yup, I pinged slack on this. The go convention conflicts with making the docs useful for their intended purpose (people generating YAML). Specifically, the constant names are completely useless to anyone reading the docs to figure out how to interpret the API, since those names aren't visible in the API.
We could nobble the golint error if we switch to golangci-lint.
|
Thanks for the work on this @jpeach! There are a lot of great improvements here, I'm not quite sure what to do as far as doc links though. The links added in this PR would look somewhat out of place everywhere but the API spec docs. This is likely much more complicated, but it seems like this is the kind of issue that would ideally be solved by improving the docs/spec generation here. If that could recognize the names of types it was processing and add links automatically we'd have a readable spec + go types that pass linting. |
Yeah IIUC godoc automatically links type names that it finds in the doc text. But the godoc currently has a ton of ugliness, so I don't really see the markdown links as a blocker here. My perspective is that most people will read and learn the API through the HTML docs. |
@jpeach that is a good point, the annotations we already have make things like https://pkg.go.dev/sigs.k8s.io/service-apis/apis/v1alpha1 rather ugly. This would represent a further shift away from readable godocs towards more readable HTML docs. I'm not sure that's necessarily a bad thing, but interested in what others think here. |
012b8e2
to
a1f759f
Compare
I think we have control over this part of user-experience. Most doc generators have some quirks that make them harder to use. Whenever I'm browsing upstream k8s APIs, I use the HTML browser to figure out the types I need to lookup and then go and read the godoc version. Regarding the markdown in Godoc, I'd rather prefer to not have it in there but I can live with a little bit of it sprinkled around. |
apis/v1alpha1/gateway_types.go
Outdated
// An opaque identifier that represents a specific IP address. The interpretation | ||
// of the name is dependent on the controller. For example, | ||
// a "NamedAddress" might be a cloud-dependent ID for a "static" | ||
// or "elastic" IP. |
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 it is best to leave the idiomatic Godoc style " is ..." in here for the sake of consistency across the entire project.
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.
The problem with the Go idiom here is that the API isn't the constant t name but the constant value (ie. the value is what you need in the YAML). So using the constant name here is actually misleading readers of the documentation. It's also confusing because the constant names done appear anywhere in the HTML rendering.
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 is an interesting one. I took a look at the Kubernetes reference docs and they lack consistency here but the godoc style Harry is suggesting above does seem to be more common (ConfigMap is an example of that). Your proposed change does certainly read better in the reference docs, we just need to determine how heavily we want to prioritize that over other formats.
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.
Here's an example of the current docs:
Looking at "NamedAddress", which is a designated enum value that API clients have to provide, it is described in terms of a "NamedAddressType", a term which is never defined in the documentation and is utterly irrelevant to anyone who doesn't have the Go code in front of them.
In terms of the API, the fact that this constant is available in Go doesn't really matter. What API consumers need to know is the value of the constant.
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 for your work on this @jpeach! Lots of great cleanup + godoc improvements here. I'd personally prefer to separate out the markdown link additions/discussion so we can get the rest of this cleanup in sooner.
apis/v1alpha1/gateway_types.go
Outdated
// An opaque identifier that represents a specific IP address. The interpretation | ||
// of the name is dependent on the controller. For example, | ||
// a "NamedAddress" might be a cloud-dependent ID for a "static" | ||
// or "elastic" IP. |
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 is an interesting one. I took a look at the Kubernetes reference docs and they lack consistency here but the godoc style Harry is suggesting above does seem to be more common (ConfigMap is an example of that). Your proposed change does certainly read better in the reference docs, we just need to determine how heavily we want to prioritize that over other formats.
a1f759f
to
2a0cfe3
Compare
2a0cfe3
to
7245c26
Compare
7245c26
to
d8c0929
Compare
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 for the work on this! A few more questions and nits, but lots of good improvements here. Still not sure about the transition away from the more traditional Type is ...
structure. Added something to agenda tomorrow to try to get some consensus on which structure we want to standardize on throughout and how much we want to prioritize the readability of reference docs.
// Value. Examples: "1.2.3.4", "128::1", "my-ip-address". Validity of the | ||
// values will depend on `Type` and support by the controller. | ||
// Value of the address. The validity of the values will depend | ||
// on the type and support by the controller. |
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.
Nit: I think the backticks and capitalization above made it more clear that "type" was referring to an API field and not a characteristic of the controller.
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.
That would be find if it was used consistently. We can make a separate pass to add that.
d8c0929
to
d38c202
Compare
IMO we should prioritize documentation for godocs. Is it possible for this PR to focus on changes that are applicable to godoc and html? The more controversial changes can be discussed further in a separate PR. |
I think the minor intrusive changes are okay but the change of |
Hey @jpeach, we discussed this at the community meeting today - here's a quick recap:
I think there's general agreement that the best case scenario involves finding a way to update the generator so we can have both readable godocs and great reference docs. Happy to help figure that out, just not sure where to even start. |
d38c202
to
74649fc
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpeach 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 |
Especially now that enum constants are rendered in the HTML API documentation, the godoc conventions make it harder for a reader to understand the intentions of the documentation. To handle passing a literal "*" character through the two layers of Markdown, we postprocess the`"*"` pattern into a HTML entity. Make an editorial pass that improves readability without any semantic changes. Signed-off-by: James Peach <jpeach@vmware.com>
74649fc
to
52bf5e2
Compare
/retest |
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 for all your work on this! This LGTM, just needs one more rebase.
@@ -50,4 +50,4 @@ fi | |||
gendoc::build | |||
gendoc::exec \ | |||
-api-dir sigs.k8s.io/gateway-api/apis/v1alpha1 \ | |||
-out-file "$1" | |||
-out-file /dev/stdout | sed '-es|"*\*|\"\*|g' > "$1" |
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.
With #549 merged I don't think this and the associated changes to escaping asterisks are necessary anymore. I think it's still worth looking into ways to improve our docs generation, but what we have now is probably good enough for the v0.2.0 release.
#552 merged instead |
@hbagdi: Closed this PR. In response to this:
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. |
@jpeach: PR needs rebase. 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. |
What type of PR is this?
/kind cleanup
/kind documentation
What this PR does / why we need it:
Especially now that enum constants are rendered in the HTML API
documentation, the godoc conventions make it harder for a reader
to understand the intentions of the documentation.
Make an editorial pass that improves readability without any semantic
changes.
Which issue(s) this PR fixes:
n/a
Does this PR introduce a user-facing change?: