@@ -5,12 +5,20 @@ import os
5
5
import re
6
6
7
7
8
- def compile (service , version , variable , alias , image , scheme , ports , unimplemented , dokku_version ):
8
+ def compile (service , version , variable , alias , image , scheme , ports , sponsors , unimplemented , dokku_version ):
9
+ prefix = "\n \n " .join ([
10
+ header (service ),
11
+ description (service , image , version ),
12
+ ])
13
+
14
+ if len (sponsors ) > 0 :
15
+ prefix += "\n \n "
16
+ prefix += sponsors_section (service , sponsors )
17
+
9
18
return (
10
19
"\n \n " .join (
11
20
[
12
- header (service ),
13
- description (service , version ),
21
+ prefix ,
14
22
requirements_section (dokku_version ),
15
23
installation_section (service , dokku_version ),
16
24
commands_section (service , variable , alias , image , scheme , ports , unimplemented ),
@@ -33,8 +41,26 @@ def header(service):
33
41
)
34
42
35
43
36
- def description (service , version ):
37
- return f"Official { service } plugin for dokku. Currently defaults to installing [{ service } { version } ](https://hub.docker.com/_/{ service } /)."
44
+ def description (service , full_image , version ):
45
+ base = "_"
46
+ image = full_image
47
+ if "/" in full_image :
48
+ base = "r/" + full_image .split ("/" )[0 ]
49
+ image = full_image .split ("/" )[1 ]
50
+
51
+ return f"Official { service } plugin for dokku. Currently defaults to installing [{ full_image } { version } ](https://hub.docker.com/{ base } /{ image } /)."
52
+
53
+
54
+ def sponsors_section (service , sponsors ):
55
+ if len (sponsors ) == 0 :
56
+ return ""
57
+
58
+ sponsor_data = ["## Sponsors" , "" , f"The { service } plugin was generously sponsored by the following:" , "" ]
59
+ sponsor_data .extend ([f"- [{ s } ](https://github.com/{ s } )" for s in sponsors ])
60
+
61
+ return "\n " .join (
62
+ sponsor_data
63
+ )
38
64
39
65
40
66
def requirements_section (dokku_version ):
@@ -469,7 +495,14 @@ def main():
469
495
if match is not None :
470
496
unimplemented = [s .strip ('"' ) for s in match .group (1 ).split (" " )]
471
497
472
- text = compile (service , version , variable , alias , image , scheme , ports , unimplemented , "0.12.x+" )
498
+ sponsors = []
499
+ with open ("plugin.toml" ) as f :
500
+ for line in f .readlines ():
501
+ if line .startswith ("sponsors" ):
502
+ sponsors = re .search ("\[([\" \w\s,_-]+)\]" , line ).group (1 )
503
+ sponsors = [s .strip ("\" " ) for s in sponsors .split ("," )]
504
+
505
+ text = compile (service , version , variable , alias , image , scheme , ports , sponsors , unimplemented , "0.12.x+" )
473
506
474
507
base_path = os .path .dirname (os .path .dirname (os .path .realpath (__file__ )))
475
508
readme_file = os .path .join (base_path , "README.md" )
0 commit comments