Skip to content

Commit 84adb2d

Browse files
committed
docs: update docs and generation script
1 parent 345f5bf commit 84adb2d

File tree

2 files changed

+181
-45
lines changed

2 files changed

+181
-45
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Create a graphite service named lollipop:
7575
dokku graphite:create lollipop
7676
```
7777

78-
You can also specify the image and image version to use for the service. It _must_ be compatible with the dokku/docker-grafana-graphite image.
78+
You can also specify the image and image version to use for the service. It *must* be compatible with the dokku/docker-grafana-graphite image.
7979

8080
```shell
8181
export STATSD_IMAGE="dokku/docker-grafana-graphite"

bin/generate

+180-44
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
from __future__ import print_function
4+
45
import os
56
import re
67

78

8-
def compile(service, version, variable, alias, image, scheme, ports, sponsors, options, unimplemented, dokku_version):
9-
prefix = "\n\n".join([
10-
header(service),
11-
description(service, image, version),
12-
])
9+
def compile(
10+
service,
11+
version,
12+
variable,
13+
alias,
14+
image,
15+
scheme,
16+
ports,
17+
sponsors,
18+
options,
19+
unimplemented,
20+
dokku_version,
21+
):
22+
prefix = "\n\n".join(
23+
[
24+
header(service),
25+
description(service, image, version),
26+
]
27+
)
1328

1429
if len(sponsors) > 0:
1530
prefix += "\n\n"
@@ -21,8 +36,19 @@ def compile(service, version, variable, alias, image, scheme, ports, sponsors, o
2136
prefix,
2237
requirements_section(dokku_version),
2338
installation_section(service, dokku_version),
24-
commands_section(service, variable, alias, image, scheme, ports, unimplemented),
25-
usage_section(service, variable, alias, image, scheme, ports, options, unimplemented),
39+
commands_section(
40+
service, variable, alias, image, scheme, ports, unimplemented
41+
),
42+
usage_section(
43+
service,
44+
variable,
45+
alias,
46+
image,
47+
scheme,
48+
ports,
49+
options,
50+
unimplemented,
51+
),
2652
]
2753
)
2854
.replace("\n\n\n\n\n", "\n")
@@ -55,17 +81,25 @@ def sponsors_section(service, sponsors):
5581
if len(sponsors) == 0:
5682
return ""
5783

58-
sponsor_data = ["## Sponsors", "", f"The {service} plugin was generously sponsored by the following:", ""]
84+
sponsor_data = [
85+
"## Sponsors",
86+
"",
87+
f"The {service} plugin was generously sponsored by the following:",
88+
"",
89+
]
5990
sponsor_data.extend([f"- [{s}](https://github.com/{s})" for s in sponsors])
6091

61-
return "\n".join(
62-
sponsor_data
63-
)
92+
return "\n".join(sponsor_data)
6493

6594

6695
def requirements_section(dokku_version):
6796
return "\n".join(
68-
["## Requirements", "", f"- dokku {dokku_version}", "- docker 1.8.x",]
97+
[
98+
"## Requirements",
99+
"",
100+
f"- dokku {dokku_version}",
101+
"- docker 1.8.x",
102+
]
69103
)
70104

71105

@@ -115,17 +149,31 @@ def commands_section(service, variable, alias, image, scheme, ports, unimplement
115149
return "\n".join(content)
116150

117151

118-
def usage_section(service, variable, alias, image, scheme, ports, options, unimplemented):
152+
def usage_section(
153+
service, variable, alias, image, scheme, ports, options, unimplemented
154+
):
119155
return "\n\n".join(
120156
[
121157
"## Usage",
122158
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.",
123-
usage_intro(service, variable, alias, image, scheme, ports, options, unimplemented),
124-
usage_lifecycle(service, variable, alias, image, scheme, ports, options, unimplemented),
125-
usage_automation(service, variable, alias, image, scheme, ports, options, unimplemented),
126-
usage_data_management(service, variable, alias, image, scheme, ports, options, unimplemented),
127-
usage_backup(service, variable, alias, image, scheme, ports, options, unimplemented),
128-
usage_docker_pull(service, variable, alias, image, scheme, ports, options, unimplemented),
159+
usage_intro(
160+
service, variable, alias, image, scheme, ports, options, unimplemented
161+
),
162+
usage_lifecycle(
163+
service, variable, alias, image, scheme, ports, options, unimplemented
164+
),
165+
usage_automation(
166+
service, variable, alias, image, scheme, ports, options, unimplemented
167+
),
168+
usage_data_management(
169+
service, variable, alias, image, scheme, ports, options, unimplemented
170+
),
171+
usage_backup(
172+
service, variable, alias, image, scheme, ports, options, unimplemented
173+
),
174+
usage_docker_pull(
175+
service, variable, alias, image, scheme, ports, options, unimplemented
176+
),
129177
]
130178
)
131179

@@ -135,11 +183,22 @@ def usage_intro(service, variable, alias, image, scheme, ports, options, unimple
135183
content = ["### Basic Usage"]
136184

137185
return fetch_commands_content(
138-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
186+
service,
187+
variable,
188+
alias,
189+
image,
190+
scheme,
191+
ports,
192+
options,
193+
unimplemented,
194+
commands,
195+
content,
139196
)
140197

141198

142-
def usage_lifecycle(service, variable, alias, image, scheme, ports, options, unimplemented):
199+
def usage_lifecycle(
200+
service, variable, alias, image, scheme, ports, options, unimplemented
201+
):
143202
commands = [
144203
"connect",
145204
"enter",
@@ -160,11 +219,22 @@ def usage_lifecycle(service, variable, alias, image, scheme, ports, options, uni
160219
]
161220

162221
return fetch_commands_content(
163-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
222+
service,
223+
variable,
224+
alias,
225+
image,
226+
scheme,
227+
ports,
228+
options,
229+
unimplemented,
230+
commands,
231+
content,
164232
)
165233

166234

167-
def usage_automation(service, variable, alias, image, scheme, ports, options, unimplemented):
235+
def usage_automation(
236+
service, variable, alias, image, scheme, ports, options, unimplemented
237+
):
168238
commands = ["app-links", "clone", "exists", "linked", "links"]
169239
content = [
170240
"### Service Automation",
@@ -174,11 +244,22 @@ def usage_automation(service, variable, alias, image, scheme, ports, options, un
174244
]
175245

176246
return fetch_commands_content(
177-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
247+
service,
248+
variable,
249+
alias,
250+
image,
251+
scheme,
252+
ports,
253+
options,
254+
unimplemented,
255+
commands,
256+
content,
178257
)
179258

180259

181-
def usage_data_management(service, variable, alias, image, scheme, ports, options, unimplemented):
260+
def usage_data_management(
261+
service, variable, alias, image, scheme, ports, options, unimplemented
262+
):
182263
commands = ["import", "export"]
183264
content = [
184265
"### Data Management",
@@ -188,11 +269,22 @@ def usage_data_management(service, variable, alias, image, scheme, ports, option
188269
]
189270

190271
return fetch_commands_content(
191-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
272+
service,
273+
variable,
274+
alias,
275+
image,
276+
scheme,
277+
ports,
278+
options,
279+
unimplemented,
280+
commands,
281+
content,
192282
)
193283

194284

195-
def usage_backup(service, variable, alias, image, scheme, ports, options, unimplemented):
285+
def usage_backup(
286+
service, variable, alias, image, scheme, ports, options, unimplemented
287+
):
196288
commands = [
197289
"backup-auth",
198290
"backup-deauth",
@@ -215,11 +307,22 @@ def usage_backup(service, variable, alias, image, scheme, ports, options, unimpl
215307
]
216308

217309
return fetch_commands_content(
218-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
310+
service,
311+
variable,
312+
alias,
313+
image,
314+
scheme,
315+
ports,
316+
options,
317+
unimplemented,
318+
commands,
319+
content,
219320
)
220321

221322

222-
def usage_docker_pull(service, variable, alias, image, scheme, ports, options, unimplemented):
323+
def usage_docker_pull(
324+
service, variable, alias, image, scheme, ports, options, unimplemented
325+
):
223326
service_prefix = service.upper()
224327
return "\n".join(
225328
[
@@ -233,11 +336,30 @@ def usage_docker_pull(service, variable, alias, image, scheme, ports, options, u
233336

234337

235338
def fetch_commands_content(
236-
service, variable, alias, image, scheme, ports, options, unimplemented, commands, content
339+
service,
340+
variable,
341+
alias,
342+
image,
343+
scheme,
344+
ports,
345+
options,
346+
unimplemented,
347+
commands,
348+
content,
237349
):
238350
i = 0
239351
for command in commands:
240-
output = command_help(command, service, variable, alias, image, scheme, ports, options, unimplemented)
352+
output = command_help(
353+
command,
354+
service,
355+
variable,
356+
alias,
357+
image,
358+
scheme,
359+
ports,
360+
options,
361+
unimplemented,
362+
)
241363
if output == "":
242364
continue
243365
content.append(output)
@@ -275,7 +397,9 @@ def parse_args(line):
275397
return " ".join(arguments)
276398

277399

278-
def command_help(command, service, variable, alias, image, scheme, ports, options, unimplemented):
400+
def command_help(
401+
command, service, variable, alias, image, scheme, ports, options, unimplemented
402+
):
279403
if command in unimplemented:
280404
return ""
281405

@@ -285,7 +409,7 @@ def command_help(command, service, variable, alias, image, scheme, ports, option
285409
"",
286410
"```shell",
287411
"# usage",
288-
f"dokku {service}:{command} {data['arguments_string']}",
412+
f"dokku {service}:{command} {data['arguments_string']}".strip(),
289413
"```",
290414
]
291415

@@ -442,11 +566,11 @@ def process_sentence(sentence_lines):
442566
parts = []
443567
for word in sentence.strip().split(" "):
444568
if word.isupper() and len(word) > 1:
445-
for ending in [':', '.']:
569+
for ending in [":", "."]:
446570
if word.endswith(ending):
447-
word = '`{0}`{1}'.format(word[:-1], ending)
571+
word = "`{0}`{1}".format(word[:-1], ending)
448572
else:
449-
word = '`{0}`'.format(word)
573+
word = "`{0}`".format(word)
450574
parts.append(word)
451575
text.append(" ".join(parts))
452576

@@ -491,10 +615,10 @@ def main():
491615

492616
with open("Dockerfile") as f:
493617
for line in f.readlines():
494-
if "FROM " in line:
495-
image, version = line.split(" ")[1].split(":")
496-
image = image.strip()
497-
version = version.strip()
618+
if "FROM " in line:
619+
image, version = line.split(" ")[1].split(":")
620+
image = image.strip()
621+
version = version.strip()
498622

499623
with open("config") as f:
500624
for line in f.readlines():
@@ -524,10 +648,22 @@ def main():
524648
with open("plugin.toml") as f:
525649
for line in f.readlines():
526650
if line.startswith("sponsors"):
527-
sponsors = re.search("\[([\"\w\s,_-]+)\]", line).group(1)
528-
sponsors = [s.strip("\"") for s in sponsors.split(",")]
529-
530-
text = compile(service, version, variable, alias, image, scheme, ports, sponsors, options, unimplemented, "0.19.x+")
651+
sponsors = re.search('\[(["\w\s,_-]+)\]', line).group(1)
652+
sponsors = [s.strip('"') for s in sponsors.split(",")]
653+
654+
text = compile(
655+
service,
656+
version,
657+
variable,
658+
alias,
659+
image,
660+
scheme,
661+
ports,
662+
sponsors,
663+
options,
664+
unimplemented,
665+
"0.19.x+",
666+
)
531667

532668
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
533669
readme_file = os.path.join(base_path, "README.md")

0 commit comments

Comments
 (0)