Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Dec 20, 2020

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?:

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 20, 2020
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 20, 2020
@youngnick
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 20, 2020
@youngnick
Copy link
Contributor

Looks like you'll need to revert some changes to pass go linting though, godoc requires constant comments to be phrased CONSTANTNAME does something.

@youngnick
Copy link
Contributor

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 20, 2020
@jpeach
Copy link
Contributor Author

jpeach commented Dec 20, 2020 via email

@robscott
Copy link
Member

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.

@jpeach
Copy link
Contributor Author

jpeach commented Dec 22, 2020

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.

ahmetb/gen-crd-api-reference-docs#30

@robscott
Copy link
Member

@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.

/cc @hbagdi @danehans @bowei

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 23, 2020
@hbagdi
Copy link
Contributor

hbagdi commented Dec 28, 2020

My perspective is that most people will read and learn the API through the HTML docs.

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.

// 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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:

Screen Shot 2021-01-17 at 11 40 11 am

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.

Copy link
Member

@robscott robscott left a 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.

// 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.
Copy link
Member

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.

apis/v1alpha1/gateway_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/gatewayclass_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/gatewayclass_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/gatewayclass_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/tlsroute_types.go Outdated Show resolved Hide resolved
@jpeach jpeach changed the title WIP: make an editorial pass over the API documentation Make an editorial pass over the API documentation. Jan 17, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 17, 2021
Copy link
Member

@robscott robscott left a 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.

apis/v1alpha1/gateway_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/gateway_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/gateway_types.go Outdated Show resolved Hide resolved
// 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.
Copy link
Member

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.

Copy link
Contributor Author

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.

apis/v1alpha1/gateway_types.go Show resolved Hide resolved
apis/v1alpha1/gateway_types.go Show resolved Hide resolved
apis/v1alpha1/httproute_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/httproute_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/httproute_types.go Outdated Show resolved Hide resolved
hack/verify-golint.sh Outdated Show resolved Hide resolved
@danehans
Copy link
Contributor

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.

@hbagdi
Copy link
Contributor

hbagdi commented Jan 21, 2021

I think the minor intrusive changes are okay but the change of * to * is taking a step too further as it makes godocs incomprehensible.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2021
@robscott
Copy link
Member

robscott commented Feb 3, 2021

Hey @jpeach, we discussed this at the community meeting today - here's a quick recap:

  • We want to ensure that godocs remain readable and accurate
  • We love the API reference docs and want to find a way to update the generator to escape special characters
  • If we can't find a way to update the generator, we may need to evaluate using https://pkg.go.dev/sigs.k8s.io/service-apis/apis/v1alpha1 temporarily until we can find a better solution

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.

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2021
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>
@jpeach
Copy link
Contributor Author

jpeach commented Feb 14, 2021

/retest

Copy link
Member

@robscott robscott left a 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|&quot;*\*|\&quot;\&ast;|g' > "$1"
Copy link
Member

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.

@hbagdi
Copy link
Contributor

hbagdi commented Feb 16, 2021

#552 merged instead
/close

@k8s-ci-robot
Copy link
Contributor

@hbagdi: Closed this PR.

In response to this:

#552 merged instead
/close

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.

@k8s-ci-robot
Copy link
Contributor

@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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants