docs: correct casing/quoting on sentences

This commit is contained in:
Jose Diaz-Gonzalez
2020-05-15 00:34:38 -04:00
parent 6497135ae8
commit f9d5735c6c
3 changed files with 84 additions and 52 deletions

View File

@@ -77,10 +77,10 @@ Create a redis service named lolipop:
dokku redis:create lolipop dokku redis:create lolipop
``` ```
You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image. You can also specify the image and image version to use for the service. It *must* be compatible with the redis image.
```shell ```shell
export REDIS_IMAGE="${PLUGIN_IMAGE}" export REDIS_IMAGE="redis"
export REDIS_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" export REDIS_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}"
dokku redis:create lolipop dokku redis:create lolipop
``` ```
@@ -212,14 +212,14 @@ The host exposed here only works internally in docker containers. If you want yo
dokku redis:link other_service playground dokku redis:link other_service playground
``` ```
It is possible to change the protocol for redis_url by setting the environment variable redis_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding. It is possible to change the protocol for `REDIS_URL` by setting the environment variable `REDIS_DATABASE_SCHEME` on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding.
```shell ```shell
dokku config:set playground REDIS_DATABASE_SCHEME=redis2 dokku config:set playground REDIS_DATABASE_SCHEME=redis2
dokku redis:link lolipop playground dokku redis:link lolipop playground
``` ```
This will cause redis_url to be set as: This will cause `REDIS_URL` to be set as:
``` ```
redis2://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop redis2://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
@@ -283,10 +283,10 @@ dokku redis:enter lolipop touch /tmp/test
dokku redis:expose <service> <ports...> dokku redis:expose <service> <ports...>
``` ```
Expose the service on the service's normal ports, allowing access to it from the public interface (0. 0. 0. 0): Expose the service on the service's normal ports, allowing access to it from the public interface (`0.0.0.0`):
```shell ```shell
dokku redis:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} dokku redis:expose lolipop 6379
``` ```
### unexpose a previously exposed redis service ### unexpose a previously exposed redis service
@@ -296,7 +296,7 @@ dokku redis:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
dokku redis:unexpose <service> dokku redis:unexpose <service>
``` ```
Unexpose the service, removing access to it from the public interface (0. 0. 0. 0): Unexpose the service, removing access to it from the public interface (`0.0.0.0`):
```shell ```shell
dokku redis:unexpose lolipop dokku redis:unexpose lolipop
@@ -323,7 +323,7 @@ You can promote the new service to be the primary one:
dokku redis:promote other_service playground dokku redis:promote other_service playground
``` ```
This will replace redis_url with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example: This will replace `REDIS_URL` with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example:
``` ```
REDIS_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service REDIS_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
@@ -566,7 +566,7 @@ flags:
- `-u|--use-iam`: use the IAM profile associated with the current server - `-u|--use-iam`: use the IAM profile associated with the current server
Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws: Backup the 'lolipop' service to the 'my-s3-bucket' bucket on ``AWS`:`
```shell ```shell
dokku redis:backup lolipop my-s3-bucket --use-iam dokku redis:backup lolipop my-s3-bucket --use-iam
@@ -579,7 +579,7 @@ dokku redis:backup lolipop my-s3-bucket --use-iam
dokku redis:backup-set-encryption <service> <passphrase> dokku redis:backup-set-encryption <service> <passphrase>
``` ```
Set the gpg-compatible passphrase for encrypting backups for backups: Set the GPG-compatible passphrase for encrypting backups for backups:
```shell ```shell
dokku redis:backup-set-encryption lolipop dokku redis:backup-set-encryption lolipop
@@ -592,7 +592,7 @@ dokku redis:backup-set-encryption lolipop
dokku redis:backup-unset-encryption <service> dokku redis:backup-unset-encryption <service>
``` ```
Unset the gpg encryption passphrase for backups: Unset the `GPG` encryption passphrase for backups:
```shell ```shell
dokku redis:backup-unset-encryption lolipop dokku redis:backup-unset-encryption lolipop

View File

@@ -5,7 +5,7 @@ import os
import re import re
def compile(service, version, alias, scheme, ports, unimplemented, dokku_version): def compile(service, version, variable, alias, image, scheme, ports, unimplemented, dokku_version):
return ( return (
"\n\n".join( "\n\n".join(
[ [
@@ -13,8 +13,8 @@ def compile(service, version, alias, scheme, ports, unimplemented, dokku_version
description(service, version), description(service, version),
requirements_section(dokku_version), requirements_section(dokku_version),
installation_section(service, dokku_version), installation_section(service, dokku_version),
commands_section(service, alias, scheme, ports, unimplemented), commands_section(service, variable, alias, image, scheme, ports, unimplemented),
usage_section(service, alias, scheme, ports, unimplemented), usage_section(service, variable, alias, image, scheme, ports, unimplemented),
] ]
) )
.replace("\n\n\n\n\n", "\n") .replace("\n\n\n\n\n", "\n")
@@ -56,7 +56,7 @@ def installation_section(service, dokku_version):
) )
def commands_section(service, alias, scheme, ports, unimplemented): def commands_section(service, variable, alias, image, scheme, ports, unimplemented):
content = [ content = [
"## Commands", "## Commands",
"", "",
@@ -71,7 +71,7 @@ def commands_section(service, alias, scheme, ports, unimplemented):
for filename in subcommands: for filename in subcommands:
if filename in unimplemented: if filename in unimplemented:
continue continue
data = command_data(filename, service, alias, scheme, ports) data = command_data(filename, service, variable, alias, image, scheme, ports)
description = data["description"] description = data["description"]
arguments = data["arguments_string"] arguments = data["arguments_string"]
@@ -89,31 +89,31 @@ def commands_section(service, alias, scheme, ports, unimplemented):
return "\n".join(content) return "\n".join(content)
def usage_section(service, alias, scheme, ports, unimplemented): def usage_section(service, variable, alias, image, scheme, ports, unimplemented):
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. Please consult the `{service}:help` command for any undocumented commands.",
usage_intro(service, alias, scheme, ports, unimplemented), usage_intro(service, variable, alias, image, scheme, ports, unimplemented),
usage_lifecycle(service, alias, scheme, ports, unimplemented), usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented),
usage_automation(service, alias, scheme, ports, unimplemented), usage_automation(service, variable, alias, image, scheme, ports, unimplemented),
usage_data_management(service, alias, scheme, ports, unimplemented), usage_data_management(service, variable, alias, image, scheme, ports, unimplemented),
usage_backup(service, alias, scheme, ports, unimplemented), usage_backup(service, variable, alias, image, scheme, ports, unimplemented),
usage_docker_pull(service, alias, scheme, ports, unimplemented), usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented),
] ]
) )
def usage_intro(service, alias, scheme, ports, unimplemented): def usage_intro(service, variable, alias, image, scheme, ports, unimplemented):
commands = ["create", "info", "list", "logs", "link", "unlink"] commands = ["create", "info", "list", "logs", "link", "unlink"]
content = ["### Basic Usage"] content = ["### Basic Usage"]
return fetch_commands_content( return fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
) )
def usage_lifecycle(service, alias, scheme, ports, unimplemented): def usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented):
commands = [ commands = [
"connect", "connect",
"enter", "enter",
@@ -133,11 +133,11 @@ def usage_lifecycle(service, alias, scheme, ports, unimplemented):
] ]
return fetch_commands_content( return fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
) )
def usage_automation(service, alias, scheme, ports, unimplemented): def usage_automation(service, variable, alias, image, scheme, ports, unimplemented):
commands = ["app-links", "clone", "exists", "linked", "links"] commands = ["app-links", "clone", "exists", "linked", "links"]
content = [ content = [
"### Service Automation", "### Service Automation",
@@ -147,11 +147,11 @@ def usage_automation(service, alias, scheme, ports, unimplemented):
] ]
return fetch_commands_content( return fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
) )
def usage_data_management(service, alias, scheme, ports, unimplemented): def usage_data_management(service, variable, alias, image, scheme, ports, unimplemented):
commands = ["import", "export"] commands = ["import", "export"]
content = [ content = [
"### Data Management", "### Data Management",
@@ -161,11 +161,11 @@ def usage_data_management(service, alias, scheme, ports, unimplemented):
] ]
return fetch_commands_content( return fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
) )
def usage_backup(service, alias, scheme, ports, unimplemented): def usage_backup(service, variable, alias, image, scheme, ports, unimplemented):
commands = [ commands = [
"backup-auth", "backup-auth",
"backup-deauth", "backup-deauth",
@@ -188,11 +188,11 @@ def usage_backup(service, alias, scheme, ports, unimplemented):
] ]
return fetch_commands_content( return fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
) )
def usage_docker_pull(service, alias, scheme, ports, unimplemented): def usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented):
service_prefix = service.upper() service_prefix = service.upper()
return "\n".join( return "\n".join(
[ [
@@ -206,11 +206,11 @@ def usage_docker_pull(service, alias, scheme, ports, unimplemented):
def fetch_commands_content( def fetch_commands_content(
service, alias, scheme, ports, unimplemented, commands, content service, variable, alias, image, scheme, ports, unimplemented, commands, content
): ):
i = 0 i = 0
for command in commands: for command in commands:
output = command_help(command, service, alias, scheme, ports, unimplemented) output = command_help(command, service, variable, alias, image, scheme, ports, unimplemented)
if output == "": if output == "":
continue continue
content.append(output) content.append(output)
@@ -248,11 +248,11 @@ def parse_args(line):
return " ".join(arguments) return " ".join(arguments)
def command_help(command, service, alias, scheme, ports, unimplemented): def command_help(command, service, variable, alias, image, scheme, ports, unimplemented):
if command in unimplemented: if command in unimplemented:
return "" return ""
data = command_data(command, service, alias, scheme, ports) data = command_data(command, service, variable, alias, image, scheme, ports)
content = [ content = [
f"### {data['description']}", f"### {data['description']}",
"", "",
@@ -283,7 +283,7 @@ def command_help(command, service, alias, scheme, ports, unimplemented):
return "\n" + "\n".join(content) return "\n" + "\n".join(content)
def command_data(command, service, alias, scheme, ports): def command_data(command, service, variable, alias, image, scheme, ports):
description = None description = None
arguments = [] arguments = []
arguments_string = "" arguments_string = ""
@@ -295,9 +295,12 @@ def command_data(command, service, alias, scheme, ports):
line = line.replace("$PLUGIN_SERVICE", service) line = line.replace("$PLUGIN_SERVICE", service)
line = line.replace("$PLUGIN_COMMAND_PREFIX", service) line = line.replace("$PLUGIN_COMMAND_PREFIX", service)
line = line.replace("${PLUGIN_COMMAND_PREFIX}", service) line = line.replace("${PLUGIN_COMMAND_PREFIX}", service)
line = line.replace("${PLUGIN_VARIABLE}", variable)
line = line.replace("${PLUGIN_DEFAULT_ALIAS}", alias) line = line.replace("${PLUGIN_DEFAULT_ALIAS}", alias)
line = line.replace("${PLUGIN_IMAGE}", image)
line = line.replace("${PLUGIN_SCHEME}", scheme) line = line.replace("${PLUGIN_SCHEME}", scheme)
line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0]) line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0])
line = line.replace("${PLUGIN_DATASTORE_PORTS[@]}", " ".join(ports))
if "declare desc" in line: if "declare desc" in line:
description = re.search('"(.+)"', line).group(1) description = re.search('"(.+)"', line).group(1)
@@ -394,11 +397,34 @@ def command_data(command, service, alias, scheme, ports):
def process_sentence(sentence_lines): def process_sentence(sentence_lines):
sentence_lines = " ".join(sentence_lines) sentence_lines = " ".join(sentence_lines)
sentences = ". ".join( sentences = ". ".join(
i.strip().capitalize() for i in sentence_lines.split(".") upperfirst(i.strip()) for i in sentence_lines.split(".")
).strip() ).strip()
if not sentences.endswith(".") and not sentences.endswith(":"): if not sentences.endswith(".") and not sentences.endswith(":"):
sentences += ":" sentences += ":"
return sentences
text = []
for sentence in sentences.split("."):
parts = []
for word in sentence.strip().split(" "):
if word.isupper() and len(word) > 1:
for ending in [':', '.']:
if word.endswith(ending):
word = '`{0}`{1}'.format(word[:-1], ending)
else:
word = '`{0}`'.format(word)
parts.append(word)
text.append(" ".join(parts))
text = ". ".join(text)
# some cleanup
text = text.replace("(0. 0. 0. 0)", "(`0.0.0.0`)")
return text
def upperfirst(x):
return x[:1].upper() + x[1:]
def process_blockquote(blockquote_lines): def process_blockquote(blockquote_lines):
@@ -418,16 +444,22 @@ def process_codeblock(codeblock_lines):
def main(): def main():
service = None service = None
version = None version = None
variable = None
image = None
alias = None alias = None
unimplemented = [] unimplemented = []
with open("config") as f: with open("config") as f:
for line in f.readlines(): for line in f.readlines():
if "IMAGE_VERSION=${" in line: if "IMAGE_VERSION=${" in line:
version = re.search('"(.+)"', line).group(1) version = re.search('"(.+)"', line).group(1)
if "_IMAGE=${" in line:
image = re.search('"(.+)"', line).group(1)
if "PLUGIN_COMMAND_PREFIX=" in line: if "PLUGIN_COMMAND_PREFIX=" in line:
service = re.search('"(.+)"', line).group(1) service = re.search('"(.+)"', line).group(1)
if "PLUGIN_DEFAULT_ALIAS=" in line: if "PLUGIN_DEFAULT_ALIAS=" in line:
alias = re.search('"(.+)"', line).group(1) alias = re.search('"(.+)"', line).group(1)
if "PLUGIN_VARIABLE=" in line:
variable = re.search('"(.+)"', line).group(1)
if "PLUGIN_SCHEME=" in line: if "PLUGIN_SCHEME=" in line:
scheme = re.search('"(.+)"', line).group(1) scheme = re.search('"(.+)"', line).group(1)
if "PLUGIN_DATASTORE_PORTS=" in line: if "PLUGIN_DATASTORE_PORTS=" in line:
@@ -437,7 +469,7 @@ def main():
if match is not None: if match is not None:
unimplemented = [s.strip('"') for s in match.group(1).split(" ")] unimplemented = [s.strip('"') for s in match.group(1).split(" ")]
text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+") text = compile(service, version, variable, alias, image, scheme, ports, unimplemented, "0.12.x+")
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
readme_file = os.path.join(base_path, "README.md") readme_file = os.path.join(base_path, "README.md")

View File

@@ -30,10 +30,10 @@ service-link-cmd() {
#E use the 'expose' subcommand. another service can be linked to your app: #E use the 'expose' subcommand. another service can be linked to your app:
#E dokku $PLUGIN_COMMAND_PREFIX:link other_service playground #E dokku $PLUGIN_COMMAND_PREFIX:link other_service playground
#E it is possible to change the protocol for ${PLUGIN_DEFAULT_ALIAS}_URL by setting the #E it is possible to change the protocol for ${PLUGIN_DEFAULT_ALIAS}_URL by setting the
#E environment variable ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME on the app. doing so will #E environment variable ${PLUGIN_VARIABLE}_DATABASE_SCHEME on the app. doing so will
#E after linking will cause the plugin to think the service is not #E after linking will cause the plugin to think the service is not
#E linked, and we advise you to unlink before proceeding. #E linked, and we advise you to unlink before proceeding.
#E dokku config:set playground ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME=${PLUGIN_SCHEME}2 #E dokku config:set playground ${PLUGIN_VARIABLE}_DATABASE_SCHEME=${PLUGIN_SCHEME}2
#E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground #E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground
#E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as: #E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as:
#E #E