Commit c451c58097d60890c53bc6b3d633cac7519ba9b4

vimdoc2html.py: --template file arg
Author: Mr Alin
Author date (UTC): 2024-03-15 16:06
Committer name: Mr Alin
Committer date (UTC): 2024-03-15 16:06
Parent(s): 4adee8312a5921e4dc1de7a7021ab9eabdcac1d8
Signing key:
Tree: c14a5a0cbc969e5ae2ecc3304c43d4673e1fd01e
File Lines added Lines deleted
vimdoc2html.py 7 1
File vimdoc2html.py changed (mode: 100755) (index fcb3c90..c045067)
... ... TEMPLATE = u'''\
47 47 </body> </body>
48 48 </html>\ </html>\
49 49 ''' '''
50 template = TEMPLATE
50 51
51 52 script_dir = path.dirname(path.realpath(__file__)) script_dir = path.dirname(path.realpath(__file__))
52 53
 
... ... script_dir = path.dirname(path.realpath(__file__))
54 55 parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
55 56 parser.add_argument('-r', '--raw', dest='raw', action='store_true', parser.add_argument('-r', '--raw', dest='raw', action='store_true',
56 57 help="Don't wrap output into template") help="Don't wrap output into template")
58 parser.add_argument('-t', '--template',
59 help="template file (overrides builtin template)")
57 60 parser.add_argument('vimdoc', nargs=1, help='Vim documentation file') parser.add_argument('vimdoc', nargs=1, help='Vim documentation file')
58 61 args = parser.parse_args() args = parser.parse_args()
59 62 raw_output = args.raw raw_output = args.raw
 
... ... with io.open(src_filename, 'r', encoding='utf-8') as doc_file:
74 77 contents = doc_file.read() contents = doc_file.read()
75 78 with io.open(css_path, 'r', encoding='utf-8') as css_file: with io.open(css_path, 'r', encoding='utf-8') as css_file:
76 79 style = css_file.read() style = css_file.read()
80 if args.template is not None:
81 with io.open(args.template, 'r', encoding='utf-8') as template_file:
82 template = template_file.read()
77 83
78 84 # produce formatted html # produce formatted html
79 85 html = vimd2h.VimDoc2HTML(tags).to_html(contents) html = vimd2h.VimDoc2HTML(tags).to_html(contents)
 
... ... with io.open(html_path, 'w', encoding='utf-8') as html_file:
84 90 html_file.write(html) html_file.write(html)
85 91 else: else:
86 92 html_file.write( html_file.write(
87 TEMPLATE.format(title=path.basename(src_filename),
93 template.format(title=path.basename(src_filename),
88 94 style=style, style=style,
89 95 html=html)) html=html))
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vimdoc2html

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vimdoc2html

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master