-
Notifications
You must be signed in to change notification settings - Fork 303
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
cmd/cue: add hidden command to dump command structure for cuelang.org #3758
Comments
cc @jpluscplusm |
Fat fingered attempt at typing a comment, apologies. I suggest a hidden command which outputs a JSON list of structs, one per command. For example, Which information is needed for each command? I suggest:
|
Alternatively, we could group these for-internal-use-only hidden commands like we did with |
Or, just to say it out loud, we actually start from a declarative data structure (which we could also use for cuelang.org) and code generate some Go off the back of that. |
Yes - we can and should declare this structure as CUE - but I wanted to summarise it in plain English before I got into the details. Anyway, here goes:
I chose to omit a "hidden" boolean because "experimental" and "internal" give the reason why a command is hidden in a much clearer way. From my reading of https://cuelang.org/docs/reference/command/, the website would render all commands except those marked as internal. And when rendering the page, it would primarily use In the future we can add more fields if useful, of course, but for now this seems like a good start. |
The cuelang.org reference pages (e.g. We can (and currently do) string-process our way around maintaining this link, as seen here: https://github.com/cue-lang/cuelang.org/blob/d94054d9cd41f12b7e506d1eb3cabc46e3191b4f/content/docs/reference/command/commands.cue#L26-L38. If we're emitting a structure from If we choose not to do this, and require the cuelang.org build to insert a Separately, we have a special case for the The current setup of the reference pages was written with consistency in mind (hence using a |
I share the desire for the cuelang.org consumer side to not need to maintain the list of We started to do this, tracking some in-text links for the I'd like to ask that the first cut of this There's also the question of cuelang.org's tags. You'll notice that pages like https://cuelang.org/docs/reference/command/cue-help-mod-init/ display a Given the very slow rate at which non-experimental commands will ever be removed from |
Would you be able to write a CUE schema like I tried above, along with what changes to cmd/cue you would suggest to e.g. track links to other help pages inside the texts? This doesn't have to be perfect day one either. We need to start with something that will take a couple of hours to implement and integrate. We can then improve on top of that over time, e.g. categorizing the commands or turning the help text "rich" so that the website can render links. |
Modifying @mvdan's schema slightly, I propose this: commands: [C=#HelpTextCommand]: #Command & {helpCommand: C}
#Command: {
// args is the list of arguments to invoke this command,
// such as ["cue", "mod", "tidy"].
args!: [...string]
// runnable describes if a command can be executed on its own
// or if it exists only to contain subcommands, such as `cue mod`.
runnable!: bool
// experimental is true when a command is in an experimental stage,
// meaning that it may be changed, renamed, or removed at any time,
// such as `cue exp` and its subcommands.
experimental?: bool
// internal is true when a command exists solely for use by the CUE project,
// such as `cue internal` and its subcommands.
internal?: bool
// shortDescription is a single line description of the command,
// used by `cue help` when listing available commands or subcommands.
shortDescription!: string
// helpText is the multi-line output of `cue help foo` or `cue foo --help`,
// which may include available flags and subcommands.
helpText!: string
// helpCommand is the shell command which, when invoked, emits helpText.
helpCommand!: string & #HelpTextCommand
// relatedCommands is a list of keys in the commands struct that
// represent other commands' help texts which are mentioned inside
// helpText. It defaults to an empty list.
relatedCommands: [...or(#HelpTextCommands)]
}
#HelpTextCommand: =~"^cue help[ a-zA-Z0-9]*$"
#HelpTextCommands: [for command, _ in commands {command}] The intent behind
The I've left |
For cuelang.org we rather clumsily/forgetfully maintain a list of commands that need to have pages auto-generated for their
cue help
documentation:https://github.com/cue-lang/cuelang.org/blob/d94054d9cd41f12b7e506d1eb3cabc46e3191b4f/content/docs/reference/command/commands.cue#L115-L151
We should not require a manual update on the cuelang.org side here - the cuelang.org docs should always follow what
cmd/cue
does/says/supports.Instead we should have a hidden command for
cmd/cue
which dumps a structure of some sort for all the commands it supports.The cuelang.org infrastructure can then auto-generate from the output of this hidden command for the given CUE version.
The text was updated successfully, but these errors were encountered: