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

Man pages: tighter documenting of --format fields #21060

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

edsantiago
Copy link
Member

@edsantiago edsantiago commented Dec 19, 2023

Initial impetus was #20958 (ps --format .Label abc). This is
a complicated solution to a simple-seeming problem.

The problem: .Label is a cobra function, something I did not
know about nor handle.

Solution: recognize cobra functions. Switch to __complete,
not __completeNoDesc, so we can see the number of arguments
required. Invent new man-page format for documenting functions.
And, finally, start enforcing how functions (and cobra structs)
are documented.

This discovered a never-used completion function, .Recycle(),
in podman-events. Remove it.

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

None

@edsantiago edsantiago requested a review from rhatdan December 19, 2023 14:14
@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 19, 2023
@edsantiago edsantiago force-pushed the labels-space branch 2 times, most recently from b12f8fa to 85f54f4 Compare December 19, 2023 14:19
Copy link
Member Author

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

No hurry. I think this PR should sit and simmer until Paul has a chance to look at it. I just wanted to get it submitted because it's been a lot of my work over the past two weeks.

@@ -115,8 +115,10 @@ Format the output to JSON Lines or using the given Go template.
| .Name | Container name (string) |
| .Network | Name of network being used (string) |
| .PodID | ID of pod associated with container, if any |
| .Recycle PATH BOOL | [unimplemented] |
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new convention for documenting cobra functions. It merits careful scrutiny.

@@ -86,7 +86,8 @@ Valid placeholders for the Go template are listed below:
| .Created | Creation time of pod |
| .ID | Container ID |
| .InfraID | Pod infra container ID |
| .Labels | All the labels assigned to the pod |
| .Label STRING | Specified label of the pod |
Copy link
Member Author

Choose a reason for hiding this comment

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

This huge PR, just for this....

Copy link
Member

Choose a reason for hiding this comment

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

should we use <STRING> or *string* as syntax to better display that this is a mandatory argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I was going for with CAPS, but yours seems more consistent with our conventions.

Angle brackets, probably not, because they'd need to be escaped and that's too hard to enforce. Asterisks (italics) show up only in generated HTML, not in man pages (at least not on my laptop, AFAICT). See attached image; the italics don't show up well in CAPS, but they are prominent in lowercase.

recycle

If we can find a way to highlight *italics* in the terminal man page view, I'd like to go with that approach. Otherwise, slight preference for CAPS.

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with CAPS

Copy link
Member Author

Choose a reason for hiding this comment

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

Followup: go-md2man seems to handle italics-in-tables just fine, and produces what looks like sane *roff:

\&.Recycle \fIpath\fP \fIbool\fP    [unimplemented]

...but man -l is not respecting that.

Italics and bold are possible in tables -- see systemd.unit(5) -- I just can't figure out what special magic is needed, or what the difference is between the table in systemd.unit.5 and the podman one. Giving up for now, waiting for inspiration.

Copy link
Member Author

Choose a reason for hiding this comment

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

I give up. Man page highlights are inconsistent. The following groff:

.SH DESCRIPTION
.PP
Monitor and print events that occur in Podman. Each event includes a timestamp,
a type, a status, name (if applicable), and image (if applicable).  The default logging
mechanism is \fIjournald\fP\&. This can be changed in containers.conf by changing the \fB\fCevents_logger\fR
value to \fB\fCfile\fR\&.  Only \fB\fCfile\fR and \fB\fCjournald\fR are accepted. A \fB\fCnone\fR logger is also
available, but this logging mechanism completely disables events; nothing is reported by
\fB\fCpodman events\fR\&.

.PP
By default, streaming mode is used, printing new events as they occur.  Previous events can be listed via \fB\fC--since\fR and \fB\fC--until\fR\&.

...produces the following display:
man

Note the proliferation of \f<whatever> in the source. The only ones that actually show up in the terminal view are the ones with -- (the options). This is too obscure for me.

@edsantiago edsantiago marked this pull request as draft December 19, 2023 14:20
@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 Dec 19, 2023
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Overall looks good, although I have not looked at the perl code just the docs and test cases.

@@ -86,7 +86,8 @@ Valid placeholders for the Go template are listed below:
| .Created | Creation time of pod |
| .ID | Container ID |
| .InfraID | Pod infra container ID |
| .Labels | All the labels assigned to the pod |
| .Label STRING | Specified label of the pod |
Copy link
Member

Choose a reason for hiding this comment

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

should we use <STRING> or *string* as syntax to better display that this is a mandatory argument?

@edsantiago
Copy link
Member Author

The man page confusion was 100% PEBKAC: I have had am working on tweaking a somewhat complicated set of $MANPAGER and $LESS_TERMCAP_xx settings. For normal people, the highlights should work, so I'm going with 'arg` and added tests to check and enforce.

This is too much to ask for full review. My recommendation is to focus on the man-page changes, see if those look reasonable, and then skip to the new error-message checks and see if those are acceptable. As in, if you submitted a PR and this script blew up at you with one of those messages, would you know what to do or at least have a starting point?

@edsantiago edsantiago marked this pull request as ready for review January 4, 2024 22:14
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 4, 2024
| .Name | Container name (string) |
| .Network | Name of network being used (string) |
| .PodID | ID of pod associated with container, if any |
| .Recycle *path* *bool* | [unimplemented] |
Copy link
Member

Choose a reason for hiding this comment

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

this look like a bogus function that is never called or used.

Mind removing it with

diff --git a/libpod/events/events.go b/libpod/events/events.go
index bcda07e06..18f531469 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -54,13 +54,6 @@ func NewEvent(status Status) Event {
        }
 }
 
-// Recycle checks if the event log has reach a limit and if so
-// renames the current log and starts a new one.  The remove bool
-// indicates the old log file should be deleted.
-func (e *Event) Recycle(path string, remove bool) error {
-       return errors.New("not implemented")
-}
-
 // ToJSONString returns the event as a json'ified string
 func (e *Event) ToJSONString() (string, error) {
        b, err := json.Marshal(e)

Otherwise I can submit a PR to remove it because there should really be no point in documenting broken stuff that will never help any user.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Required small tweak to regression test. I updated the commit message.

.Recycle() dates back to #2527 in 2019. Tagging @baude - that was your code, it looks like a placeholder that got orphaned. If you see a strong reason to leave that, please let me know.

Copy link
Member Author

Choose a reason for hiding this comment

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

Brent has enough on his hands this week. I'm gonna say if there's ever a need for .Recycle() it can be added (and actually implemented) then. @containers/podman-maintainers PTAL, I consider this ready to merge.

@edsantiago edsantiago force-pushed the labels-space branch 4 times, most recently from b89e4b4 to d8d5a8c Compare January 11, 2024 17:14
Initial impetus was containers#20958 (ps --format .Label abc). This is
a complicated solution to a simple-seeming problem.

The problem: .Label is a cobra *function*, something I did not
know about nor handle.

Solution: recognize cobra functions. Switch to __complete,
not __completeNoDesc, so we can see the number of arguments
required. Invent new man-page format for documenting functions.
And, finally, start enforcing how functions (and cobra structs)
are documented.

This discovered a never-used completion function, .Recycle(),
in podman-events. Remove it.

[NO NEW TESTS NEEDED] - the .go change is an excision of dead code.

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

mheon commented Jan 16, 2024

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 17, 2024
Copy link
Contributor

openshift-ci bot commented Jan 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, giuseppe

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:
  • OWNERS [edsantiago,giuseppe]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit eb77462 into containers:main Jan 17, 2024
90 of 92 checks passed
@edsantiago edsantiago deleted the labels-space branch January 17, 2024 11:41
edsantiago added a commit to edsantiago/libpod that referenced this pull request Feb 15, 2024
Followup to:
  - containers#21060, where I added new struct checks (but did not make them fatal)

  - containers#21534, which added per-interface stats and a .Network field,
    but its documentation was slightly off

Signed-off-by: Ed Santiago <[email protected]>
@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 Apr 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
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. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants