X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=development%2Ftools%2Fgen_lfuns.py;h=0bd65f78bfac2a086f1984857cb34f8290555ded;hb=69036ced3765f40048d62be800c98af3ea2d1b4a;hp=f34fd142fdeed87305328a4fc504307e3b0f014c;hpb=db4ef7df34df4a5e5dfb081c2ceb85962cebec72;p=lyx.git diff --git a/development/tools/gen_lfuns.py b/development/tools/gen_lfuns.py index f34fd142fd..0bd65f78bf 100755 --- a/development/tools/gen_lfuns.py +++ b/development/tools/gen_lfuns.py @@ -21,7 +21,7 @@ def error(message): sys.exit(1) def usage(prog_name): - return "Usage: %s " % prog_name + return "Usage: %s []" % prog_name DOXYGEN_START = "/*!" DOXYGEN_END = "*/" @@ -47,11 +47,18 @@ LFUNS_HEADER = """# gen_lfuns.py generated this file. For more info see http://w \\lyxformat 345 \\begin_document \\begin_header -\\textclass amsart +\\textclass article +\\begin_preamble +\\renewcommand{\\descriptionlabel}[1]{\\hspace\\labelsep\\upshape\\bfseries #1:} +\\renewenvironment{description}{\\list{}{% + \\setlength{\\itemsep}{-2pt} + \\advance\\leftmargini6\\p@ \\itemindent-12\\p@ + \\labelwidth\\z@ \\let\\makelabel\\descriptionlabel}% +}{ + \\endlist +} +\\end_preamble \\use_default_options false -\\begin_modules -theorems-ams -\\end_modules \\language english \\inputencoding auto \\font_roman default @@ -65,6 +72,7 @@ theorems-ams \\graphics default \\paperfontsize default +\\spacing single \\use_hyperref false \\papersize default \\use_geometry true @@ -226,6 +234,9 @@ def parse_lfun(str): # TODO: actually insert a cross-reference here line = line.replace("#LFUN", "LFUN") + # handle the few #lyx:: cases + line = line.replace("#lyx::", "lyx::") + # the first line might not have a field in it in which # case the variable field won't have a value, so check # to avoid an error @@ -279,7 +290,7 @@ def write_fields(file, lfun): def main(argv): # parse command line arguments script_path, script_name = os.path.split(argv[0]) - if len(argv) != 3: + if len(argv) < 2: error(usage(script_name)) # input file lyxaction_path = argv[1] @@ -287,20 +298,22 @@ def main(argv): error(script_name + ": %s is not a valid path" % lyxaction_path, usage(argv[0])) # output file - lfuns_path = argv[2] - if os.path.isdir(lfuns_path): - lfuns_path = lfuns_path + "LFUNs.lyx" - elif os.path.exists(lfuns_path): - error(script_name + ": %s already exists, delete it and rerun the script" % lfuns_path) + if len(argv) == 3: + lfuns_path = argv[2] + if os.path.isdir(lfuns_path): + lfuns_path = lfuns_path + "LFUNs.lyx" + elif os.path.exists(lfuns_path): + error(script_name + ": %s already exists, delete it and rerun the script" % lfuns_path) + lfuns_file = open(lfuns_path, 'wb') + else: + lfuns_file = sys.stdout - print(script_name + ": Start processing " + argv[1]) + sys.stderr.write(script_name + ": Start processing " + argv[1] + '\n') # Read the input file and write the output file lyxaction_file = open(lyxaction_path, 'rb') - lfuns_file = open(lfuns_path, 'wb') lyxaction_text = lyxaction_file.read() - # TODO: format a proper header for LFUNs.lyx lfuns_file.write(LFUNS_HEADER) # seek to the important bit of LyXAction.cpp @@ -329,7 +342,7 @@ def main(argv): # if no more lfuns are found, EOF reached done = 1 - print(script_name + ": Created documentation for " + str(count) + " LFUNs") + sys.stderr.write(script_name + ": Created documentation for " + str(count) + " LFUNs\n") # write the last part of LFUNs.lyx lfuns_file.write(LFUNS_FOOTER) @@ -337,7 +350,7 @@ def main(argv): lyxaction_file.close() lfuns_file.close() - print(script_name + ": Finished") + sys.stderr.write(script_name + ": Finished\n") if __name__ == "__main__": main(sys.argv)