docs: add ability to inject supplementary documentation into the readme
Some commands - such as link or upgrade - have extra documenation on a per-plugin basis. Rather than make some sort of weird templating logic in the help output generation, that documentation is added directly to the repository and then injected at generation time.
This commit is contained in:
@@ -52,7 +52,7 @@ mysql:upgrade <service> [--upgrade-flags...] # upgrade service <service> t
|
||||
|
||||
## Usage
|
||||
|
||||
Help for any commands can be displayed by specifying the command as an argument to mysql:help. Please consult the `mysql:help` command for any undocumented commands.
|
||||
Help for any commands can be displayed by specifying the command as an argument to mysql:help. Plugin help output in conjunction with any files in the `docs/` folder is used to generate the plugin documentation. Please consult the `mysql:help` command for any undocumented commands.
|
||||
|
||||
### Basic Usage
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ def usage_section(service, variable, alias, image, scheme, ports, options, unimp
|
||||
return "\n\n".join(
|
||||
[
|
||||
"## Usage",
|
||||
f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.",
|
||||
f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Plugin help output in conjunction with any files in the `docs/` folder is used to generate the plugin documentation. Please consult the `{service}:help` command for any undocumented commands.",
|
||||
usage_intro(service, variable, alias, image, scheme, ports, options, unimplemented),
|
||||
usage_lifecycle(service, variable, alias, image, scheme, ports, options, unimplemented),
|
||||
usage_automation(service, variable, alias, image, scheme, ports, options, unimplemented),
|
||||
@@ -308,6 +308,12 @@ def command_help(command, service, variable, alias, image, scheme, ports, option
|
||||
content.append("")
|
||||
content.append(data["examples"])
|
||||
|
||||
doc_file = os.path.join("docs", f"{command}.md")
|
||||
if os.path.isfile(doc_file):
|
||||
content.append("")
|
||||
with open(doc_file) as f:
|
||||
content.append(f.read())
|
||||
|
||||
return "\n" + "\n".join(content)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user