1
1
#!/usr/bin/env python3
2
2
# -*- coding: utf-8 -*-
3
3
from __future__ import print_function
4
+
4
5
import os
5
6
import re
6
7
7
8
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
+ )
13
28
14
29
if len (sponsors ) > 0 :
15
30
prefix += "\n \n "
@@ -21,8 +36,19 @@ def compile(service, version, variable, alias, image, scheme, ports, sponsors, o
21
36
prefix ,
22
37
requirements_section (dokku_version ),
23
38
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
+ ),
26
52
]
27
53
)
28
54
.replace ("\n \n \n \n \n " , "\n " )
@@ -55,17 +81,25 @@ def sponsors_section(service, sponsors):
55
81
if len (sponsors ) == 0 :
56
82
return ""
57
83
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
+ ]
59
90
sponsor_data .extend ([f"- [{ s } ](https://github.com/{ s } )" for s in sponsors ])
60
91
61
- return "\n " .join (
62
- sponsor_data
63
- )
92
+ return "\n " .join (sponsor_data )
64
93
65
94
66
95
def requirements_section (dokku_version ):
67
96
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
+ ]
69
103
)
70
104
71
105
@@ -115,17 +149,31 @@ def commands_section(service, variable, alias, image, scheme, ports, unimplement
115
149
return "\n " .join (content )
116
150
117
151
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
+ ):
119
155
return "\n \n " .join (
120
156
[
121
157
"## Usage" ,
122
158
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
+ ),
129
177
]
130
178
)
131
179
@@ -135,11 +183,22 @@ def usage_intro(service, variable, alias, image, scheme, ports, options, unimple
135
183
content = ["### Basic Usage" ]
136
184
137
185
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 ,
139
196
)
140
197
141
198
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
+ ):
143
202
commands = [
144
203
"connect" ,
145
204
"enter" ,
@@ -160,11 +219,22 @@ def usage_lifecycle(service, variable, alias, image, scheme, ports, options, uni
160
219
]
161
220
162
221
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 ,
164
232
)
165
233
166
234
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
+ ):
168
238
commands = ["app-links" , "clone" , "exists" , "linked" , "links" ]
169
239
content = [
170
240
"### Service Automation" ,
@@ -174,11 +244,22 @@ def usage_automation(service, variable, alias, image, scheme, ports, options, un
174
244
]
175
245
176
246
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 ,
178
257
)
179
258
180
259
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
+ ):
182
263
commands = ["import" , "export" ]
183
264
content = [
184
265
"### Data Management" ,
@@ -188,11 +269,22 @@ def usage_data_management(service, variable, alias, image, scheme, ports, option
188
269
]
189
270
190
271
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 ,
192
282
)
193
283
194
284
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
+ ):
196
288
commands = [
197
289
"backup-auth" ,
198
290
"backup-deauth" ,
@@ -215,11 +307,22 @@ def usage_backup(service, variable, alias, image, scheme, ports, options, unimpl
215
307
]
216
308
217
309
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 ,
219
320
)
220
321
221
322
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
+ ):
223
326
service_prefix = service .upper ()
224
327
return "\n " .join (
225
328
[
@@ -233,11 +336,30 @@ def usage_docker_pull(service, variable, alias, image, scheme, ports, options, u
233
336
234
337
235
338
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 ,
237
349
):
238
350
i = 0
239
351
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
+ )
241
363
if output == "" :
242
364
continue
243
365
content .append (output )
@@ -275,7 +397,9 @@ def parse_args(line):
275
397
return " " .join (arguments )
276
398
277
399
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
+ ):
279
403
if command in unimplemented :
280
404
return ""
281
405
@@ -285,7 +409,7 @@ def command_help(command, service, variable, alias, image, scheme, ports, option
285
409
"" ,
286
410
"```shell" ,
287
411
"# usage" ,
288
- f"dokku { service } :{ command } { data ['arguments_string' ]} " ,
412
+ f"dokku { service } :{ command } { data ['arguments_string' ]} " . strip () ,
289
413
"```" ,
290
414
]
291
415
@@ -442,11 +566,11 @@ def process_sentence(sentence_lines):
442
566
parts = []
443
567
for word in sentence .strip ().split (" " ):
444
568
if word .isupper () and len (word ) > 1 :
445
- for ending in [':' , '.' ]:
569
+ for ending in [":" , "." ]:
446
570
if word .endswith (ending ):
447
- word = ' `{0}`{1}' .format (word [:- 1 ], ending )
571
+ word = " `{0}`{1}" .format (word [:- 1 ], ending )
448
572
else :
449
- word = ' `{0}`' .format (word )
573
+ word = " `{0}`" .format (word )
450
574
parts .append (word )
451
575
text .append (" " .join (parts ))
452
576
@@ -491,10 +615,10 @@ def main():
491
615
492
616
with open ("Dockerfile" ) as f :
493
617
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 ()
498
622
499
623
with open ("config" ) as f :
500
624
for line in f .readlines ():
@@ -524,10 +648,22 @@ def main():
524
648
with open ("plugin.toml" ) as f :
525
649
for line in f .readlines ():
526
650
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
+ )
531
667
532
668
base_path = os .path .dirname (os .path .dirname (os .path .realpath (__file__ )))
533
669
readme_file = os .path .join (base_path , "README.md" )
0 commit comments