cli-docs-tool icon indicating copy to clipboard operation
cli-docs-tool copied to clipboard

fix: generate long desc and examples for root command

Open dvdksn opened this issue 1 year ago • 2 comments

We're already calling loadLongDescription recursively, no need to range over the subcommands, otherwise we're skipping the root command.

dvdksn avatar Apr 12 '24 12:04 dvdksn

@crazy-max can you help me look at these test failures? I have tried generating docs with this version in both cli and buildx and I don't see any issues. I can't quite figure out what's going wrong in these tests either.

dvdksn avatar Apr 12 '24 12:04 dvdksn

Codecov Report

Attention: Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.

Project coverage is 69.71%. Comparing base (c6cc9a5) to head (7d56538).

Files Patch % Lines
clidocstool.go 72.22% 2 Missing and 3 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
- Coverage   70.58%   69.71%   -0.88%     
==========================================
  Files           5        5              
  Lines         459      459              
==========================================
- Hits          324      320       -4     
  Misses         77       77              
- Partials       58       62       +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 18 '24 07:04 codecov-commenter

Sorry, I realise my question about --help somewhat distracted from the main issue; does this currently produce documentation for options/flags that are defined on the command? https://github.com/docker/cli-docs-tool/pull/53#discussion_r1576284060

I recall now I went looking for flags, and noticing the --help as example, but currently there's no flags in the produced output (but probably because none are defined). If we want to use this for the root command, we probably need to make sure that it includes flags 🙈

thaJeztah avatar May 27 '24 14:05 thaJeztah

@thaJeztah Aaah, I see now yes. Good callout. I just pushed a commit that adds two flags:

  • --help (hidden, persistent flag)
  • -H (dummy flag)

I looked at the options implementation in docker/cli and turns out adding --help as a hidden flag also removes it from the man fixtures (for subcommands as well, since it's a persistent flag), and interestingly, adds it for yaml fixtures (but as a hidden object 😆).

I think this change is appropriate since it mimics what we do in the core CLI.

https://github.com/docker/cli-docs-tool/pull/53/commits/0f4cffc674c9bfcef40067bf37d5c895459ae406#diff-9059958acfc03b30a2ff8fda8c5bb8403e63b17d7f32cdefe4611817db5cd191R57-R60

dvdksn avatar May 29 '24 09:05 dvdksn

Let's merge this

dvdksn avatar Jul 02 '24 12:07 dvdksn

I've used this version to generate markdown here:

  • docker/cli: https://github.com/docker/cli/pull/5010/commits/719f88ea6c09c4ab8d8c9974940e631dd55012a0
  • docker/buildx: https://github.com/docker/buildx/pull/2565

I've also generated yaml (for docker/cli) here: https://github.com/docker/docs/pull/19794/commits/b9ca7336debd9e56e61a59d59ea51b74c8ac5760

dvdksn avatar Jul 02 '24 13:07 dvdksn

Let's get this one in

crazy-max avatar Jul 02 '24 16:07 crazy-max