X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fbuild%2Fextract_texi_filenames.py;h=9e338b5daf0f26312c7b5c6ddf55cd80a5ea859d;hb=32a34dcef0c0041c6d62677487a380b5c8b85712;hp=fcb464d53d07b4ef7a99cfaccce2a0d1d1ea7cab;hpb=f41973ff763d5972a85995b6d40c864281ec6714;p=lilypond.git diff --git a/scripts/build/extract_texi_filenames.py b/scripts/build/extract_texi_filenames.py index fcb464d53d..9e338b5daf 100644 --- a/scripts/build/extract_texi_filenames.py +++ b/scripts/build/extract_texi_filenames.py @@ -34,11 +34,12 @@ import re import os import getopt -options_list, files = getopt.getopt (sys.argv[1:],'o:s:hI:m:', +options_list, files = getopt.getopt (sys.argv[1:],'o:s:hI:m:k:q', ['output=', 'split=', 'help', 'include=', 'master-map-file=', - 'known-missing-files=']) + 'known-missing-files=', + 'quiet']) help_text = r"""Usage: %(program_name)s [OPTIONS]... TEXIFILE... Extract files names for texinfo (sub)sections from the texinfo files. @@ -50,8 +51,9 @@ Options: -o, --output=DIRECTORY write .xref-map files to DIRECTORY -s, --split=MODE split manual according to MODE. Possible values are section and custom (default) - --known-missing-files a filename which has a list of files known + -k, --known-missing-files a filename which has a list of files known to be missing for this make + -q, --quiet suppress most messages """ def help (text): @@ -64,6 +66,8 @@ include_path = ['.',] master_map_file = '' known_missing_files = [] known_missing_files_file = '' +docs_without_directories = ['changes', 'music-glossary'] +suppress_output = False initial_map = {} for opt in options_list: o = opt[0] @@ -74,7 +78,12 @@ for opt in options_list: if os.path.isdir (a): include_path.append (a) else: - print 'NOT A DIR from: ', os.getcwd (), a + path_list = a.split('/') + file_name = path_list[len(path_list)-1] + if not (file_name in docs_without_directories): + print a, 'is not a directory.' + print 'Please consider adding it to the list of ' + print 'known missing files in extract_texi_filename.py.' elif o == '-o' or o == '--output': outdir = a elif o == '-s' or o == '--split': @@ -87,6 +96,8 @@ for opt in options_list: known_missing_files_file = a else: print 'Missing files list file not found: ', a + elif o == '-q' or o == '--quiet': + suppress_output = True else: raise Exception ('unknown option: ' + o) @@ -100,11 +111,12 @@ if not os.path.isdir (outdir): os.unlink (outdir) os.makedirs (outdir) -include_re = re.compile (r'@include ((?!../lily-).*?\.i?te(xi|ly))$', re.M) +# Only look at @include if it is not preceeded by a @c: +include_re = re.compile (r'^(?!.*@c .*@include)@include ((?!../lily-).*?\.i?te(xi|ly))$', re.M) whitespaces = re.compile (r'\s+') section_translation_re = re.compile ('^@(node|(?:unnumbered|appendix)\ (?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|\ -(?:major|chap|(?:sub){0,2})heading|lydoctitle|translationof) \ +(?:major|chap|(?:sub){0,2})heading|lydoctitle|translationof|nodeprefix) \ (.+)$', re.MULTILINE) external_node_re = re.compile (r'\s+@c\s+external.*') @@ -120,8 +132,8 @@ def expand_includes (m, filename): return extract_sections (filepath)[1] if not (include_name in known_missing_files): # Not found - print 'No such file: ' + include_name - print 'Search path: ' + ':'.join (include_path) + print 'Warning: No such file: ' + include_name + \ + ' (search path: ' + ':'.join (include_path)+')' return '' lang_re = re.compile (r'^@documentlanguage (.+)', re.M) @@ -210,9 +222,11 @@ def process_sections (filename, lang_suffix, page): sections = section_translation_re.findall (page) basename = os.path.splitext (os.path.basename (filename))[0] p = os.path.join (outdir, basename) + lang_suffix + '.xref-map' - print 'writing:', p + if not suppress_output: + print 'writing:', p f = open (p, 'w') + node_prefix_title = '' this_title = '' this_filename = 'index' this_anchor = '' @@ -247,6 +261,9 @@ def process_sections (filename, lang_suffix, page): this_filename = anchor elif original_node in initial_map: this_filename = initial_map[original_node][2] + elif sec[0] == "nodeprefix": + node_prefix_title = remove_texinfo (sec[1]) + node_prefix_anchor = create_texinfo_anchor (sec[1]) else: # Some pages might not use a node for every section, so # treat this case here, too: If we already had a section @@ -258,6 +275,10 @@ def process_sections (filename, lang_suffix, page): this_anchor = create_texinfo_anchor (sec[1]) had_section = True + if sec[0] == "lydoctitle" and node_prefix_title: + this_title = "%s: %s" % (node_prefix_title, this_title) + this_anchor = "%s-%s" % (node_prefix_anchor, this_anchor) + if split == 'custom': # unnumbered nodes use the previously used file name, # only numbered nodes get their own filename! However, @@ -287,6 +308,7 @@ if master_map_file: initial_map[m.group (1)] = (m.group (1), m.group (2), m.group (3)) for filename in files: - print "extract_texi_filenames.py: Processing %s" % filename + if not suppress_output: + print "extract_texi_filenames.py: Processing %s" % filename (lang_suffix, sections) = extract_sections (filename) process_sections (filename, lang_suffix, sections)