-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CI:DOCS] man-page checker: include --format (Go templates) #17443
[CI:DOCS] man-page checker: include --format (Go templates) #17443
Conversation
Very belated successor to containers#14046. I don't know why this is so important to me. Probably because we're doing a halfhearted sloppy job of documenting, and new options get added, and not documented, and that's just wrong. I've given up on documenting internal structs. This iteration has a $Format_Exceptions table defined at the top of the xref script, enumerating a hardcoded defined set of podman commands and fields that should remain undocumented. This iteration also forgives completely-undocumented formats. If podman-foo has a --format, but podman-foo.1.md does not list *any* valid fields, the script warns but does not fail. This at least is better than documenting a random mix of fields. This version of the xref script is much slower: 10s vs 4. I think we can live with that in a CI-only script. Signed-off-by: Ed Santiago <[email protected]>
New warnings, as expected:
|
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, vrothberg 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 |
# Table of exceptions for documenting fields in '--format {{.Foo}}' | ||
# | ||
# Autocomplete is wonderful, and it's even better when we document the | ||
# existing options. Unfortunately, sometimes internal structures get | ||
# exposed that are of no use to anyone and cannot be guaranteed. Avoid | ||
# documenting those. This table lists those exceptions. Format is: | ||
# | ||
# foo .Bar | ||
# | ||
# ...such that "podman foo --format '{{.Bar}}'" will not be documented. | ||
# | ||
my $Format_Exceptions = <<'END_EXCEPTIONS'; | ||
# Deep internal structs; pretty sure these are permanent exceptions | ||
events .Details | ||
history .ImageHistoryLayer | ||
images .ImageSummary | ||
network-ls .Network | ||
|
||
# FIXME: this one, maybe? But someone needs to write the text | ||
machine-list .Starting | ||
|
||
# No clue what these are. Some are just different-case dups of others. | ||
pod-ps .Containers .Id .InfraId .ListPodsReport .Namespace | ||
ps .Cgroup .CGROUPNS .IPC .ListContainer .MNT .Namespaces .NET .PIDNS .User .USERNS .UTS | ||
|
||
# I think .Destination is an internal struct, but .IsMachine maybe needs doc? | ||
system-connection-list .Destination .IsMachine | ||
END_EXCEPTIONS |
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.
@Luap99 PTAL, this is the most questionable part of my PR
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 this is a reasonable way of starting this. However I see two problem in this:
- Every new unwanted field must be special cases here in the script. Not something most authors will be aware of.
- The docs will not match the completion. If we do not want some stuff documented should we maybe not auto complete them as well? I think having a solution in pure go would be better, something that allows us to set a option on a struct field to make it not show up. We could also write some form of generator that will read the go comments from the struct fields and use this as Description so that a) a human must not write them by hand and b) code changes will be reflected in the docs. Of course the quality of the go comments varies but I think most are decent enough to be used as user doc.
That said I know that is not something you can write and I don't know how difficult it would be for me or somebody else.
I am definitely in favour of merging this though. This is much better than nothing.
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.
Every new unwanted field must be special cases here in the script. Not something most authors will be aware of.
True. Good point.
If we do not want some stuff documented should we maybe not auto complete them as well?
Exactly, and this is what has blocked me the two other times I've tried to submit something like this: the document-or-not argument has been unsolvable. See #14386 (comment)
I would love for those tables to be autogenerated!
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.
First of all I 100% agree with this. These fields should be documented.
I think it would be useful create an issue/card for the missing commands and assign it to somebody.
# Table of exceptions for documenting fields in '--format {{.Foo}}' | ||
# | ||
# Autocomplete is wonderful, and it's even better when we document the | ||
# existing options. Unfortunately, sometimes internal structures get | ||
# exposed that are of no use to anyone and cannot be guaranteed. Avoid | ||
# documenting those. This table lists those exceptions. Format is: | ||
# | ||
# foo .Bar | ||
# | ||
# ...such that "podman foo --format '{{.Bar}}'" will not be documented. | ||
# | ||
my $Format_Exceptions = <<'END_EXCEPTIONS'; | ||
# Deep internal structs; pretty sure these are permanent exceptions | ||
events .Details | ||
history .ImageHistoryLayer | ||
images .ImageSummary | ||
network-ls .Network | ||
|
||
# FIXME: this one, maybe? But someone needs to write the text | ||
machine-list .Starting | ||
|
||
# No clue what these are. Some are just different-case dups of others. | ||
pod-ps .Containers .Id .InfraId .ListPodsReport .Namespace | ||
ps .Cgroup .CGROUPNS .IPC .ListContainer .MNT .Namespaces .NET .PIDNS .User .USERNS .UTS | ||
|
||
# I think .Destination is an internal struct, but .IsMachine maybe needs doc? | ||
system-connection-list .Destination .IsMachine | ||
END_EXCEPTIONS |
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 this is a reasonable way of starting this. However I see two problem in this:
- Every new unwanted field must be special cases here in the script. Not something most authors will be aware of.
- The docs will not match the completion. If we do not want some stuff documented should we maybe not auto complete them as well? I think having a solution in pure go would be better, something that allows us to set a option on a struct field to make it not show up. We could also write some form of generator that will read the go comments from the struct fields and use this as Description so that a) a human must not write them by hand and b) code changes will be reflected in the docs. Of course the quality of the go comments varies but I think most are decent enough to be used as user doc.
That said I know that is not something you can write and I don't know how difficult it would be for me or somebody else.
I am definitely in favour of merging this though. This is much better than nothing.
I would love it if the autocompletion did not suggest formats, that we do not want to document. But this is best we have for now. /lgtm |
Very belated successor to #14046.
I don't know why this is so important to me. Probably because we're doing a halfhearted sloppy job of documenting, and new options get added, and not documented, and that's just wrong.
I've given up on documenting internal structs. This iteration has a $Format_Exceptions table defined at the top of the xref script, enumerating a hardcoded defined set of podman commands and fields that should remain undocumented.
This iteration also forgives completely-undocumented formats. If podman-foo has a --format, but podman-foo.1.md does not list any valid fields, the script warns but does not fail. This at least is better than documenting a random mix of fields.
This version of the xref script is much slower: 10s vs 4. I think we can live with that in a CI-only script.
Signed-off-by: Ed Santiago [email protected]