@@ -5,12 +5,20 @@ import os
55import re
66
77
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+
918 return (
1019 "\n \n " .join (
1120 [
12- header (service ),
13- description (service , version ),
21+ prefix ,
1422 requirements_section (dokku_version ),
1523 installation_section (service , dokku_version ),
1624 commands_section (service , variable , alias , image , scheme , ports , unimplemented ),
@@ -33,8 +41,26 @@ def header(service):
3341 )
3442
3543
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+ )
3864
3965
4066def requirements_section (dokku_version ):
@@ -469,7 +495,14 @@ def main():
469495 if match is not None :
470496 unimplemented = [s .strip ('"' ) for s in match .group (1 ).split (" " )]
471497
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+" )
473506
474507 base_path = os .path .dirname (os .path .dirname (os .path .realpath (__file__ )))
475508 readme_file = os .path .join (base_path , "README.md" )
0 commit comments