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
Keep the list style for generated swagger doc #111505
Keep the list style for generated swagger doc #111505
Conversation
Hi @haoruan. Thanks for your PR. I'm waiting for a kubernetes 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/test-infra repository. |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/ok-to-test |
if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") { | ||
if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") || | ||
// Keep the newline for list, so won't break the markdown | ||
strings.HasPrefix(line, "* ") || strings.HasPrefix(line, "- ") { |
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 noticed a couple of locations have additional new lines that may be unintentional. (The bold \n in the second bullet)
- Before: "matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be ...
- After: "matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".\n\n- Exact: match a request only if it exactly matches a specified rule.\nFor example, if deployments can be...
Perhaps bullet points should need the line = "\n" + line + "\n"
wrapper and only the newline prefix is enough?
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 works, but the single newline in the bullet point won't break the line and there're some other generated docs with newlines in the list:
- SyncFailed: The controller encountered an error and wasn't able to compute\n the number of allowed disruptions. Therefore no disruptions are\n allowed and the status of the condition will be False.
Also from the original comment, the "For example" starts a new line with no indent, so I'm not sure if it's part of the list or if it really wants to start a new line but didn't notice that it has no effect, so keep the newline here may have some meanings.
In this case I think the line = "\n" + line + "\n"
is the same as line = "\n" + line + " "
(from markdown list formatting view), so I combined them into one wrapper.
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.
Ah I see what you mean. If it's rendered in markdown, then there is no difference between the two. I think stylistically omitting the newline would look better for clients that take the raw text without rendering markdown though. Will leave this as a nit
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 noticed a couple of locations have additional new lines that may be unintentional. (The bold \n in the second bullet)
I'm wondering if any of these are fallout from the go1.19 doc reformatting (xref #111254 (comment)):
Sweeping what 1.19 gofmt "autocorrected" in our doc strings, there's a fair number of places we had weird indents that gofmt is turning into new paragraphs, etc. I think this PR should go ahead and merge so we can get go1.19 signal, but a followup to sweep the doc auto format changes in this PR and fix up ones that look wrong would be good.
@dims, did an issue ever get opened for that?
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 we first want to make sure our API doc is compatible with go's new support for lists in godoc, and then try to make this follow similar rules (or at least a subset of them):
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 don't think an issue got opened for #111254 (comment), no
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 confirm, if it’s all done with our API doc, I’d like to get this move forward since the rebase is quite annoying
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.
A couple things I noticed from the docs that we're definitely missing at the moment:
Gofmt reformats bullet lists to use a dash as the bullet marker, two spaces of indentation before the dash, and four spaces of indentation for continuation lines.
I see some examples of misindents and bullet points using *
instead of the standardized -
Gofmt preserves but does not require a blank line between a list and the preceding paragraph. It inserts a blank line between a list and the following paragraph or heading.
This is missing in certain places that we're using *
to represent bullet points
I think this PR will still be required after fixing our API docs, but maybe the diff will be easier to compare with the API docs fixed beforehand.
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.
@liggitt Since code freeze has passed, is this still something we can still get in as a bug fix or would we need to wait until 1.26?
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.
Since it's a long-standing issue, it's hard to justify it as a high-priority / release-blocking bug. I'd be inclined to merge it for 1.26. A fixup / follow-up for #111254 (comment) would be reasonable to do for 1.25, I think
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
If you still need this PR then please rebase, if not, please close the PR |
b7b7955
to
2a34e7a
Compare
New changes are detected. LGTM label has been removed. |
2a34e7a
to
c72eda9
Compare
c72eda9
to
d14a817
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: haoruan 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 |
Do we have any example how the final generated documentation HTML looks like? |
For example: Before is:
Now is:
|
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. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: 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. |
What type of PR is this?
/kind bug
/kind documentation
What this PR does / why we need it:
The swagger_doc_generator doesn't parse the markdown list in comments correctly, some newlines are lost in the generated strings, which breaks the list formatting in the final documentation.
Which issue(s) this PR fixes:
Fixes #111388
Special notes for your reviewer:
This PR adds the newline for list style comments to keep the formatting, and also updates the auto-generated files.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: