diff --git a/.gitignore b/.gitignore index 699d493b59..0888a4e30f 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,8 @@ local.mk /runtime/doc/errors.log # Don't include the mpack files. /runtime/doc/*.mpack +# Also don't include intermediary doc output +/tmp-*-doc # CLion /.idea/ diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index f2f003033e..4b04ebb5fb 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -39,6 +39,7 @@ Each function :help block is formatted as follows: parameter is marked as [out]. - Each function documentation is separated by a single line. """ +import argparse import os import re import sys @@ -841,7 +842,7 @@ def delete_lines_below(filename, tokenstr): fp.writelines(lines[0:i]) -def main(config): +def main(config, args=None): """Generates: 1. Vim :help docs @@ -987,7 +988,8 @@ def main(config): with open(mpack_file, 'wb') as fp: fp.write(msgpack.packb(fn_map_full, use_bin_type=True)) - shutil.rmtree(output_dir) + if not args.keep_tmpfiles: + shutil.rmtree(output_dir) def filter_source(filename): @@ -1005,6 +1007,15 @@ def filter_source(filename): fp.read(), flags=re.M)) +def parse_args(): + ap = argparse.ArgumentParser() + ap.add_argument('source_filter', nargs='*', + help="Filter source file(s)") + ap.add_argument('-k', '--keep-tmpfiles', action='store_true', + help="Keep temporary files") + return ap.parse_args() + + Doxyfile = textwrap.dedent(''' OUTPUT_DIRECTORY = {output} INPUT = {input} @@ -1041,9 +1052,10 @@ Doxyfile = textwrap.dedent(''' ''') if __name__ == "__main__": - if len(sys.argv) > 1: - filter_source(sys.argv[1]) + args = parse_args() + if len(args.source_filter) > 0: + filter_source(args.source_filter[0]) else: - main(Doxyfile) + main(Doxyfile, args) # vim: set ft=python ts=4 sw=4 tw=79 et :