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

feat(docs): generate cli docs directly from the struct #12717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akaladarshi
Copy link
Contributor

Related Issues

Fixes: #12706

@akaladarshi akaladarshi marked this pull request as ready for review November 26, 2024 15:13
@akaladarshi akaladarshi requested review from masih and rvagg November 26, 2024 15:14
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
cli/miner/actor_test.go Outdated Show resolved Hide resolved
@rvagg
Copy link
Member

rvagg commented Nov 28, 2024

Looks like a lot of the logic for this lives in https://github.com/urfave/cli/blob/main/help.go and the templates in here (unfortunately not exported!) are here: https://github.com/urfave/cli/blob/main/template.go

Use this as an exercise in minimising the diff, that's your challenge - how can you get to near zero red/green lines in the diff here for the documentation output, aiming to only make changes where the existing script is getting it wrong (mostly missing some things I believe).

@akaladarshi akaladarshi force-pushed the akaladarshi/refactor-docsgen-cli branch from 1f2c2c4 to f616568 Compare December 1, 2024 14:24
@BigLep
Copy link
Member

BigLep commented Dec 3, 2024

@akaladarshi : I assume you'll re-request review when you're ready for it to be looked at again.

@akaladarshi akaladarshi requested a review from rvagg December 3, 2024 12:00
documentation/en/cli-lotus.md Outdated Show resolved Hide resolved
cli/pprof.go Outdated Show resolved Hide resolved
documentation/en/cli-lotus.md Outdated Show resolved Hide resolved
@rvagg
Copy link
Member

rvagg commented Dec 4, 2024

Very close @akaladarshi, good work so far. I haven't done an in-depth review of the actual code, I'm mainly looking at the output and assuming that the code is good, I'll look over that next.

cli/clicommands/cmd.go Outdated Show resolved Hide resolved
@akaladarshi
Copy link
Contributor Author

@rvagg I think I found a minimum solution for this we can directly use the urface cli package for generating, Initially I though we need to print everything (hidden), but this will directly print the correct format value.

     customAppData := func() map[string]interface{} {
		return map[string]interface{}{
			"ExtraInfo": g.app.ExtraInfo,
		}
	}

	cli.HelpPrinterCustom(header, cli.AppHelpTemplate, g.app, customAppData())

@akaladarshi akaladarshi requested a review from rvagg December 4, 2024 14:11
@akaladarshi
Copy link
Contributor Author

@rvagg I think I found a minimum solution for this we can directly use the urface cli package for generating, Initially I though we need to print everything (hidden), but this will directly print the correct format value.

     customAppData := func() map[string]interface{} {
		return map[string]interface{}{
			"ExtraInfo": g.app.ExtraInfo,
		}
	}

	cli.HelpPrinterCustom(header, cli.AppHelpTemplate, g.app, customAppData())

Removed the above change in favour of app.Run(args[]string), because it was not printing the default values of flags. Anyway app.Run internally uses cli.HelpPrinter to print the commands.

Makefile Outdated Show resolved Hide resolved
scripts/docsgen-cli/main.go Outdated Show resolved Hide resolved
@akaladarshi akaladarshi requested a review from rvagg December 19, 2024 11:05
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@rvagg rvagg force-pushed the akaladarshi/refactor-docsgen-cli branch from b9a161b to 7fe23b0 Compare January 6, 2025 03:00
@rvagg
Copy link
Member

rvagg commented Jan 6, 2025

Squashed down to a single commit and rebased onto current master in this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ⌨️ In Progress
Development

Successfully merging this pull request may close these issues.

Use urfav Command struct directly to generate docsgen-cli
3 participants