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:
Jose Diaz-Gonzalez
2021-09-13 01:21:18 -04:00
parent bf311b72f0
commit 383b651b4b
2 changed files with 8 additions and 2 deletions

View File

@@ -52,7 +52,7 @@ mysql:upgrade <service> [--upgrade-flags...] # upgrade service <service> t
## Usage ## 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 ### Basic Usage

View File

@@ -119,7 +119,7 @@ def usage_section(service, variable, alias, image, scheme, ports, options, unimp
return "\n\n".join( return "\n\n".join(
[ [
"## Usage", "## 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_intro(service, variable, alias, image, scheme, ports, options, unimplemented),
usage_lifecycle(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), 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("")
content.append(data["examples"]) 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) return "\n" + "\n".join(content)