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

[WIP] [CI:DOCS] man-page checker: include --format (Go templates) #14046

Closed
wants to merge 2 commits into from

Conversation

edsantiago
Copy link
Member

Autocomplete is awesome. It offers us a programmatic way to
determine the set of values for a given --format option.
Use that to make sure the man pages document reality.

Signed-off-by: Ed Santiago [email protected]

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 28, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 28, 2022
@edsantiago
Copy link
Member Author

I don't need to say DO NOT MERGE, because this isn't even going to pass CI. Current set of failures is:

xref-helpmsgs-manpages: 'podman history --format': .CreatedAt in docs/source/markdown/podman-history.1.md, but not --help
xref-helpmsgs-manpages: 'podman history --format': .CreatedSince in docs/source/markdown/podman-history.1.md, but not --help
xref-helpmsgs-manpages: 'podman image history --format': .CreatedAt in docs/source/markdown/podman-history.1.md, but not --help
xref-helpmsgs-manpages: 'podman image history --format': .CreatedSince in docs/source/markdown/podman-history.1.md, but not --help
xref-helpmsgs-manpages: 'podman image list --format': .CreatedAt in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman image list --format': .CreatedSince in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman image list --format': .Repository in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman image list --format': .Tag in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman image search': --format options documented in man page, but not available via autocomplete
xref-helpmsgs-manpages: 'podman images --format': .CreatedAt in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman images --format': .CreatedSince in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman images --format': .Repository in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman images --format': .Tag in docs/source/markdown/podman-images.1.md, but not --help
xref-helpmsgs-manpages: 'podman network inspect': --format options documented in man page, but not available via autocomplete
xref-helpmsgs-manpages: 'podman search': --format options documented in man page, but not available via autocomplete

Those are beyond my ability to fix. And, as will be obvious to anyone who looks at the diffs, I didn't even bother describing any of the options I added in the man pages.

This is just a proof of concept. Worth pursuing? If so, would someone like to tag-team with me on it, pushing fixes to this PR?

@Luap99
Copy link
Member

Luap99 commented Apr 28, 2022

The idea is very nice but there is a significant problem with it. The current autocompletion is best effort and far from perfect.

For example podman inspect --format can display containers, pods, images, networks... There no reason to duplicated all fields in the man page when they are already in podman-container-inspect(1) and so on. I think at the moment podman inspect --format doesn't provide any autocompletion for a struct fields which is wrong and should be fixed.

Also this all depends on the correct use of AutocompleteFormat(). I think this is a good idea but I have to improve AutocompleteFormat() first to actually make this work correctly. I guess it would help to have a test which checks that the suggested field name actually work for the given command.

@edsantiago
Copy link
Member Author

Thank you!

@edsantiago edsantiago closed this Apr 28, 2022
@Luap99
Copy link
Member

Luap99 commented Apr 28, 2022

I think we should still merge some of your detected problem (--rollback ordering for example)

I will take a look at the autocompletion code to see if there is anything I can improve easily

@edsantiago
Copy link
Member Author

@containers/podman-maintainers this is a followup (precursor, actually) to @Luap99's demo this morning. Could each of you PTAL at the diffs and, if you are responsible for any of the modified man pages, take a moment to submit a (separate) PR to update the --format documentation for your given subcommand?

There is, at this time, no automated checking. This PR probable has to linger for weeks or months while we get the man pages in shape. If you're willing to do the man-page updates piecemeal, I'm willing to keep rebasing and tweaking the script logic. (By "tweak" I mean find, with your help, some way to deal with podman stats where the man page and autocomplete are completely and wildly out of sync;

@edsantiago edsantiago changed the title [WIP] man-page checker: include --format (Go templates) [WIP] [CI:DOCS] man-page checker: include --format (Go templates) May 11, 2022
@@ -70,6 +61,14 @@ For a container to send the READY message via SDNOTIFY it must be created with t
| .Policy | Auto-update policy of the container |
| .Updated | Update status: true,false,failed |

#### **--rollback**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get this change merged independently from this PR, this is obviously correct and should not have to wait for the other stuff to land which will take more time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can submit a mini-PR for this and other obvious fixes. Before I do so, can you (or anyone) comment on the weird "Print the numeric IDs only" line (search for FIXME FIXME) below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this must be under the --quiet option.

edsantiago added a commit to edsantiago/libpod that referenced this pull request May 11, 2022
As part of work done in containers#14046, fix bugs found in man pages,
basically just moving a few descriptions to the right place
and removing some undesired asterisks.

Signed-off-by: Ed Santiago <[email protected]>
@edsantiago edsantiago force-pushed the xref_format branch 3 times, most recently from 91f5bb4 to 7a652ea Compare May 12, 2022 19:44
Comment on lines +41 to +60
| .AvgCPU | Average CPU (full precision float) |
| .AVGCPU | Average CPU (formatted) |
| .CPU | Percent CPU (full precision float) |
| .CPUNano | CPU Usage, total, in nanoseconds |
| .CPUSystemNano | CPU Usage, kernel, in nanoseconds |
| .Duration | Same as CPUNano (FIXME: why?) |
| .MemLimit | Memory limit, in bytes |
| .MemPerc | Memory percentage |
| .NetIO | Network IO |
| .BlockIO | Block IO |
| .PIDS | Number of PIDs |
| .NetInput | Network Input |
| .NetOutput | Network Output |
| .BlockInput | Block Input |
| .BlockOutput | Block Output |
| .PerCPU | FIXME: empty array? |
| .PIDs | Number of PIDs |
| .SystemNano | Current system datetime, nanoseconds since epoch |
| .UpTime | WTF? This is Duration (CPUNano) in human-readable form?? |
| .Up | Same as UpTime (FIXME: why?) |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the man pages can be slowly filled in if/when people like, but this set here bothers me a little: some of the fields are duplicated for no clear reason; some (Duration?) seem misleading to my untrained eye. I wonder if someone familiar with podman stats would mind taking a look and confirming that these fields all do what's desired?

Autocomplete is awesome. It offers us a programmatic way to
determine the set of values for a given --format option.
Use that to make sure the man pages document reality.

Signed-off-by: Ed Santiago <[email protected]>
Since these can be way too many to mention, allow '.Field ...'
(ellipsis) in man page to indicate "don't bother warning me
about fields that show up in completion but not the man page"

For those that _are_ enumerable, allow '.Foo.Bar' in the
man page table itself.

Everything in this commit is iffy (even iffier than the first
commit). It might be a very bad idea to recurse deeply into
options. OTOH it might offer nice possibilities for man pages.

Signed-off-by: Ed Santiago <[email protected]>
edsantiago added a commit to edsantiago/libpod that referenced this pull request May 26, 2022
Baby steps toward merging containers#14046: document a few of the Go format
command-line options.

Signed-off-by: Ed Santiago <[email protected]>
mheon pushed a commit to mheon/libpod that referenced this pull request Jun 14, 2022
As part of work done in containers#14046, fix bugs found in man pages,
basically just moving a few descriptions to the right place
and removing some undesired asterisks.

Signed-off-by: Ed Santiago <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jun 21, 2022

@edsantiago Are you intending on merging this at some point?

@edsantiago
Copy link
Member Author

I'm feeling very lost. The PR you just closed was a subset of this one. How can this one be acceptable, but a tiny-subset not be?

Looking back at the discussion on that PR, you objected to some duplicate fields (which are also present in this PR, because the underlying completion code is the same). IIUC the completion code cannot easily be fixed to remove the duplication or to hide a subset of fields. So there doesn't seem to be anything I can do: either I document everything, including useless confusing stuff, or I document nothing (which is what we have now). I can't do a middle ground.

@github-actions github-actions bot removed the stale-pr label Jul 26, 2022
@Luap99
Copy link
Member

Luap99 commented Jul 26, 2022

I think we should do this and document all options. Right now we have zero idea about the stability of these options. Removing or renaming fields in structs that are exposed via a template are breaking changes to users. We are very bad a catching stuff like this at review time.
Having it documented in the man page and check via script will ensure that it is up do date and will make it very clear when there is a breaking change.

If there is a reason to hide some fields from the shell completion then this is a technical problem which can be solved. But I still think we should never expose the internal structs to the fronted, instead use stable (template only) structs and copy the data (and convert where needed) from the internal struct to the template struct.

@mheon
Copy link
Member

mheon commented Jul 26, 2022

Using template-exclusive structs would be a big change, but I agree that it's necessary. Tying our internal data representations to Docker's formats is not sensible or sane in the long run.

@rhatdan
Copy link
Member

rhatdan commented Jul 26, 2022

I will not stand in the way of implementing this. My fear is the noice to signal ratio could get out of control. But catching bugs and documenting things like format would be useful.

@github-actions
Copy link

A friendly reminder that this PR had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Aug 26, 2022

@edsantiago Going to move forward on this after the consolidation is done?

@rhatdan rhatdan removed the stale-pr label Aug 26, 2022
@edsantiago
Copy link
Member Author

@rhatdan I would like to proceed with this one day, but it seems like we still need to have deep conversations about what that would look like, and perhaps do some internal work to mark some formats as hidden.

edsantiago added a commit to edsantiago/libpod that referenced this pull request Sep 15, 2022
Baby steps toward merging containers#14046: document a few of the Go format
command-line options.

Signed-off-by: Ed Santiago <[email protected]>
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2022
@openshift-merge-robot
Copy link
Collaborator

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

edsantiago added a commit to edsantiago/libpod that referenced this pull request Sep 19, 2022
Baby steps toward merging containers#14046: document Go format options
for podman events.

This is deliberately imperfect. I am not the right person
to document these. I am simply the person who is getting
a skeleton framework in place.

Signed-off-by: Ed Santiago <[email protected]>
edsantiago added a commit to edsantiago/libpod that referenced this pull request Oct 5, 2022
Baby steps toward merging containers#14046: document Go format options
for podman images.

Signed-off-by: Ed Santiago <[email protected]>
edsantiago added a commit to edsantiago/libpod that referenced this pull request Feb 8, 2023
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]>
@edsantiago
Copy link
Member Author

Addressed, at least partly, in #17443. Future discussion will take place in #17472.

@edsantiago edsantiago closed this Feb 13, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants