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)) |