]> git.donarmstrong.com Git - lilypond.git/commitdiff
Clean up .xref-map files generation
authorJohn Mandereau <john.mandereau@gmail.com>
Wed, 20 Aug 2008 13:19:59 +0000 (15:19 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Wed, 20 Aug 2008 16:38:08 +0000 (18:38 +0200)
- write these files in (top-build-dir)/out/xref-maps/, with language
used as name suffix if different from English: this is cleaner than
writing them in out-www subdirectories and creating symlinks, mainly
because it avoids hardcoding manual names in a bunch of makefiles;

- buildscripts/extract_texi_filenames.py: write "@documentlanguage" as
output file suffix if not "en", create output directory if necessary,
and fix minor nitpicks;

- remove all hardcoded manual names in makefiles.

13 files changed:
Documentation/de/user/GNUmakefile
Documentation/es/user/GNUmakefile
Documentation/fr/user/GNUmakefile
Documentation/user/GNUmakefile
buildscripts/extract_texi_filenames.py
input/lsr/GNUmakefile
lilypond-texi2html.init
make/doclang-rules.make
make/doclang-targets.make
make/doclang-vars.make
stepmake/stepmake/texinfo-rules.make
stepmake/stepmake/texinfo-targets.make
stepmake/stepmake/texinfo-vars.make

index 810efc38e774dd72e0aaad6ff1e716640648f093..fb4ca861ff22a89b2a5c0f412b1f71df7dc0be70 100644 (file)
@@ -2,14 +2,3 @@ ISOLANG = de
 depth = ../../..
 LOCALSTEPMAKE_TEMPLATES = lilypond ly doclang
 include $(depth)/make/stepmake.make
-
-
-local-WWW-1: $(XREF_MAP_FILES) $(outdir)/lilypond-snippets.xref-map \
-       $(outdir)/music-glossary.xref-map \
-       $(outdir)/lilypond-internals.xref-map
-
-$(outdir)/lilypond-snippets.xref-map:
-       ln -sf ../../../../input/lsr/$@ $@
-
-$(outdir)/lilypond-internals.xref-map $(outdir)/music-glossary.xref-map:
-       ln -sf ../../../user/$@ $@
index d51764115b973e42e72a6f6921d76c7d4227d459..1728b63e7ce1a473761c997ccf9c689e92efff12 100644 (file)
@@ -2,14 +2,3 @@ ISOLANG = es
 depth = ../../..
 LOCALSTEPMAKE_TEMPLATES = lilypond ly doclang
 include $(depth)/make/stepmake.make
-
-
-local-WWW-1: $(XREF_MAP_FILES) $(outdir)/lilypond-snippets.xref-map \
-       $(outdir)/music-glossary.xref-map \
-       $(outdir)/lilypond-internals.xref-map
-
-$(outdir)/lilypond-snippets.xref-map:
-       ln -sf ../../../../input/lsr/$@ $@
-
-$(outdir)/lilypond-internals.xref-map $(outdir)/music-glossary.xref-map:
-       ln -sf ../../../user/$@ $@
index f32ebf319fe49b6386620680696b03f49203e252..cff64c97e969a277488438805e9adc01022a46e2 100644 (file)
@@ -2,13 +2,3 @@ ISOLANG = fr
 depth = ../../..
 LOCALSTEPMAKE_TEMPLATES = lilypond ly doclang
 include $(depth)/make/stepmake.make
-
-local-WWW-1: $(XREF_MAP_FILES) $(outdir)/lilypond-snippets.xref-map \
-       $(outdir)/music-glossary.xref-map \
-       $(outdir)/lilypond-internals.xref-map
-
-$(outdir)/lilypond-snippets.xref-map:
-       ln -sf ../../../../input/lsr/$@ $@
-
-$(outdir)/lilypond-internals.xref-map $(outdir)/music-glossary.xref-map:
-       ln -sf ../../../user/$@ $@
index b930b98e166c5d6373305417e494f6262a0aafcb..688b32c42ec7be63b736bf05b8de3e1a05c2ae45 100644 (file)
@@ -125,16 +125,13 @@ $(outdir)/%/source:
        mkdir -p $(dir $@)
        ln -sf $(depth)/.. $(@)
 
-local-WWW-1: $(MASTER_TEXI_FILES) $(MASTER_TEXI_FILES:%.texi=%.xref-map) $(outdir)/lilypond-snippets.xref-map $(PDF_FILES) info
+local-WWW-1: $(MASTER_TEXI_FILES) $(PDF_FILES) info
 
 local-WWW-2: $(HTML_FILES) $(DEEP_HTML_FILES) $(source-links)
 
 $(outdir)/%.bib: %.bib
        ln -f $< $@
 
-$(outdir)/lilypond-snippets.xref-map:
-       ln -fs ../../../input/lsr/$@ $@
-
 # lilypond.texi deps
 $(top-build-dir)/mf/$(outconfbase)/feta16list.ly:
        $(MAKE) -C $(top-src-dir)/mf
index beea07e43366a485f5e04a103bdfa828a3f49505..6b89954b256f89c6ce7564f523c1d6323191bf59 100755 (executable)
@@ -1,6 +1,6 @@
 #!@PYTHON@
 # -*- coding: utf-8 -*-
-# extrace_texi_filenames.py
+# extract_texi_filenames.py
 
 # USAGE:  extract_texi_filenames.py [-o OUTDIR] FILES
 #
@@ -14,8 +14,9 @@
 # which is then used for the filename/anchor.
 #
 # If this script is run on a file texifile.texi, it produces a file
-# texifile.xref-map with tab-separated entries of the form
+# texifile[.LANG].xref-map with tab-separated entries of the form
 #        NODE\tFILENAME\tANCHOR
+# LANG is the document language in case it's not 'en'
 # Note: The filename does not have any extension appended!
 # This file can then be used by our texi2html init script to determine 
 # the correct file name and anchor for external refs
@@ -25,8 +26,6 @@ import re
 import os
 import getopt
 
-#import langdefs
-
 optlist, args = getopt.getopt (sys.argv[1:],'o:')
 files = args
 
@@ -35,6 +34,11 @@ for x in optlist:
     if x[0] == '-o':
         outdir = x[1]
 
+if not os.path.isdir (outdir):
+    if os.path.exists (outdir):
+        os.unlink (outdir)
+    os.makedirs (outdir)
+
 include_re = re.compile (r'@include ((?!../lily-).*?)\.texi$', re.M)
 whitespaces = re.compile (r'\s+')
 section_translation_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading|translationof) (.*?)\s*\n')
@@ -42,22 +46,30 @@ section_translation_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){
 def expand_includes (m, filename):
     filepath = os.path.join (os.path.dirname (filename), m.group(1)) + '.texi'
     if os.path.exists (filepath):
-        return extract_sections (filepath)
+        return extract_sections (filepath)[1]
     else:
         print "Unable to locate include file " + filepath
         return ''
 
+lang_re = re.compile (r'^@documentlanguage (.+)', re.M)
+
 def extract_sections (filename):
     result = ''
     f = open (filename, 'r')
     page = f.read ()
     f.close()
+    # Search document language
+    m = lang_re.search (page)
+    if m and m.group (1) != 'en':
+        lang_suffix = '.' + m.group (1)
+    else:
+        lang_suffix = ''
     # Replace all includes by their list of sections and extract all sections
     page = include_re.sub (lambda m: expand_includes (m, filename), page)
     sections = section_translation_re.findall (page)
     for sec in sections:
         result += "@" + sec[0] + " " + sec[1] + "\n"
-    return result
+    return (lang_suffix, result)
 
 # Convert a given node name to its proper file name (normalization as explained
 # in the texinfo manual:
@@ -101,10 +113,10 @@ def create_texinfo_anchor (title):
     return texinfo_file_name (remove_texinfo (title))
 
 unnumbered_re = re.compile (r'unnumbered.*')
-def process_sections (filename, page):
+def process_sections (filename, lang_suffix, page):
     sections = section_translation_re.findall (page)
-    # TODO: Don't rely on the file having a 4-letter extension (texi)!!!
-    p = os.path.join (outdir, filename) [:-5] + '.xref-map'
+    basename = os.path.splitext (os.path.basename (filename))[0]
+    p = os.path.join (outdir, basename) + lang_suffix + '.xref-map'
     f = open (p, 'w')
 
     this_title = ''
@@ -152,5 +164,5 @@ def process_sections (filename, page):
 
 for filename in files:
     print "extract_texi_filenames.py: Processing %s" % filename
-    sections = extract_sections (filename)
-    process_sections (filename, sections)
+    (lang_suffix, sections) = extract_sections (filename)
+    process_sections (filename, lang_suffix, sections)
index 97e188eb887d052616b348eca17b80f62a2407d7..f91dacd38d76370acdd7c6f70adcbacb75f3ffbc 100644 (file)
@@ -57,19 +57,10 @@ local-clean:
        rm -f $(INFO_IMAGES_DIR)
 
 local-WWW-1: info $(outdir)/lilypond-snippets.pdf \
-  $(outdir)/lilypond-snippets.texi \
-  $(outdir)/lilypond-snippets.xref-map \
-  $(outdir)/lilypond.xref-map \
-  $(outdir)/lilypond-learning.xref-map
+  $(outdir)/lilypond-snippets.texi
 
 local-WWW-2: $(outdir)/lilypond-snippets/index.html \
   $(outdir)/lilypond-snippets-big-page.html \
   $(source-links)
 
-%.xref-map: %.texi
-       $(PYTHON) $(buildscript-dir)/extract_texi_filenames.py $<
-
-$(outdir)/lilypond.xref-map $(outdir)/lilypond-learning.xref-map:
-       ln -sf ../../../Documentation/user/$@ $@
-
 .SECONDARY:
index 3ed3fcc6da2ff5af0479a283e61c9768ab354670..fdb02c16829a2aa48b612b6891196846f51933a0 100644 (file)
@@ -328,7 +328,8 @@ sub split_at_numbered_sections($$$)
 sub lilypond_init_map ()
 {
     my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
-    my $map_filename = "$docu_dir/${docu_name}.xref-map";
+    my $map_filename = main::locate_include_file ("${docu_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
+       || main::locate_include_file ("${docu_name}.xref-map");
     $node_to_filename_map = load_map_file ($map_filename);
 }
 push @Texi2HTML::Config::command_handler_init, \&lilypond_init_map;
@@ -442,7 +443,8 @@ sub lilypond_external_href($$$)
     # Load the map if we haven't done so already
     if (!exists($translated_books{$map_name})) {
       my ($docu_dir, $docu_name) = split_texi_filename ($Texi2HTML::THISDOC{'input_file_name'});
-      my $map_filename = "$docu_dir/${map_name}.xref-map";
+      my $map_filename = main::locate_include_file ("${map_name}.$Texi2HTML::THISDOC{current_lang}.xref-map")
+         || main::locate_include_file ("${map_name}.xref-map");
       $translated_books{$map_name} = load_map_file ($map_filename);
     }
 
index 201e49fd93ad277e8520fdd908c442b82806f54b..91f09c47a17f7fb71a1aa9dfbb64f2c67d94f4ac 100644 (file)
@@ -1,9 +1,9 @@
-$(outdir)/%/index.html: $(outdir)/%.texi $(outdir)/%.xref-map $(OUT_PNG_IMAGES) $(outdir)/version.itexi
+$(outdir)/%/index.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map $(OUT_PNG_IMAGES) $(outdir)/version.itexi
        mkdir -p $(dir $@)
        $(TEXI2HTML) --I=$(outdir) $(TEXI2HTML_FLAGS) --output=$(dir $@) --prefix=index --split=section $(TEXI2HTML_INIT) $<
        cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
 
-$(outdir)/%-big-page.html: $(outdir)/%.texi $(outdir)/%.xref-map $(OUT_PNG_IMAGES) $(outdir)/version.itexi
+$(outdir)/%-big-page.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map $(OUT_PNG_IMAGES) $(outdir)/version.itexi
        $(TEXI2HTML) --I=$(outdir) -D bigpage $(TEXI2HTML_FLAGS) --output=$@ $(TEXI2HTML_INIT) $<
        cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
 
@@ -21,8 +21,8 @@ $(outdir)/version.%: $(top-src-dir)/VERSION
 $(outdir)/%.png: $(top-build-dir)/Documentation/user/$(outdir)/%.png
        ln -f $< $@
 
-$(outdir)/%.xref-map: $(outdir)/%.texi
-       $(PYTHON) $(buildscript-dir)/extract_texi_filenames.py $<
+$(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map: $(outdir)/%.texi
+       $(PYTHON) $(buildscript-dir)/extract_texi_filenames.py -o $(XREF_MAPS_DIR) $<
 
 # This makes sure lilypond-doc gettext domain has been compiled
 # before lilypond-book runs
index 72e8ada4ad4060108160ad8633126e6e5db795f9..7f8f6799b00b506e2563c0349dfe1d1cccc5fd20 100644 (file)
@@ -1,6 +1,6 @@
 default:
 
-local-WWW-1: $(MASTER_TEXI_FILES) $(PDF_FILES) $(XREF_MAP_FILES)
+local-WWW-1: $(MASTER_TEXI_FILES) $(PDF_FILES) $(XREF_MAPS_FILES)
 
 # BIG_PAGE_HTML_FILES is defined differently in each language makefile
 local-WWW-2: $(DEEP_HTML_FILES) $(BIG_PAGE_HTML_FILES)
index f7b25ae284c9888659daf6fe84032cf6baa007f9..bd5d7d372cb75f88799d7753e9bbfc26f58f3369 100644 (file)
@@ -5,6 +5,14 @@ LANGS = $(shell $(PYTHON) $(buildscript-dir)/langdefs.py)
 SOURCE_PNG_IMAGES=$(shell ls $(top-src-dir)/Documentation/user/*.png)
 OUT_PNG_IMAGES=$(SOURCE_PNG_IMAGES:$(top-src-dir)/Documentation/user/%.png=$(outdir)/%.png) $(outdir)/context-example.png
 
+TELY_FILES := $(call src-wildcard,*.tely)
+MASTER_TEXI_FILES := $(TELY_FILES:%.tely=$(outdir)/%.texi)
+DEEP_HTML_FILES := $(TELY_FILES:%.tely=$(outdir)/%/index.html)
+PDF_FILES := $(TELY_FILES:%.tely=$(outdir)/%.pdf)
+
+ITELY_FILES := $(call src-wildcard,*.itely)
+ITEXI_FILES := $(call src-wildcard,*.itexi)
+
 DOCUMENTATION_INCLUDES = \
   -I $(top-src-dir)/Documentation/user \
   -I $(top-build-dir)/Documentation/user/$(outdir)
@@ -13,18 +21,15 @@ LILYPOND_BOOK_INCLUDES += $(DOCUMENTATION_INCLUDES)
 MAKEINFO_FLAGS += --force --enable-encoding $(DOCUMENTATION_INCLUDES)
 MAKEINFO = LANG= $(MAKEINFO_PROGRAM) $(MAKEINFO_FLAGS)
 
+# texi2html xref map files
+XREF_MAPS_DIR=$(top-build-dir)/out/xref-maps
+XREF_MAPS_FILES=$(TELY_FILES:%.tely=$(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map)
+
+# texi2html flags
 TEXI2HTML_INIT= --init-file=$(top-src-dir)/lilypond-texi2html.init
 TEXI2HTML_LANG=--lang=$(ISOLANG)
-TEXI2HTML_FLAGS += $(TEXI2HTML_LANG) $(DOCUMENTATION_INCLUDES)
+TEXI2HTML_FLAGS += $(TEXI2HTML_LANG) $(DOCUMENTATION_INCLUDES) \
+  -I $(XREF_MAPS_DIR)
 TEXI2HTML = LANG= $(TEXI2HTML_PROGRAM)
 
 TEXI2PDF_FLAGS += -q --batch $(DOCUMENTATION_INCLUDES)
-
-TELY_FILES := $(call src-wildcard,*.tely)
-MASTER_TEXI_FILES := $(TELY_FILES:%.tely=$(outdir)/%.texi)
-DEEP_HTML_FILES := $(TELY_FILES:%.tely=$(outdir)/%/index.html)
-PDF_FILES := $(TELY_FILES:%.tely=$(outdir)/%.pdf)
-XREF_MAP_FILES := $(TELY_FILES:%.tely=$(outdir)/%.xref-map)
-
-ITELY_FILES := $(call src-wildcard,*.itely)
-ITEXI_FILES := $(call src-wildcard,*.itexi)
index fc23bcb3fd8ee8e2e8916adc315c923dc4f73933..b44b6300ec23d082960eece70ea257bf228566ed 100644 (file)
@@ -26,12 +26,12 @@ endif
 $(outdir)/%.info: $(outdir)/%.texi $(outdir)/$(INFO_IMAGES_DIR).info-images-dir.dep $(outdir)/version.itexi
        $(MAKEINFO) -I$(outdir) --output=$@ $<
 
-$(outdir)/%-big-page.html: $(outdir)/%.texi $(outdir)/%.xref-map $(outdir)/version.itexi
+$(outdir)/%-big-page.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
        $(TEXI2HTML) --I=$(outdir) -D bigpage --output=$@ $(TEXI2HTML_INIT) $< 
        cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
 
 
-$(outdir)/%.html: $(outdir)/%.texi $(outdir)/%.xref-map $(outdir)/version.itexi
+$(outdir)/%.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
        $(TEXI2HTML) --I=$(outdir) --output=$@ $(TEXI2HTML_INIT) $<
        cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
 
@@ -44,7 +44,7 @@ $(outdir)/%.pdf.omf: %.texi
 $(outdir)/%.ps.gz.omf: %.texi
        $(call GENERATE_OMF,ps.gz)
 
-$(outdir)/%/index.html: $(outdir)/%.texi $(outdir)/%.xref-map $(outdir)/version.itexi
+$(outdir)/%/index.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
        mkdir -p $(dir $@)
        $(TEXI2HTML) --I=$(outdir) --output=$(dir $@) --prefix=index --split=section $(TEXI2HTML_INIT) $<
        cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
@@ -59,8 +59,8 @@ $(outdir)/%.texi: %.texi
        rm -f $@
        cp $< $@
 
-%.xref-map: %.texi
-       $(PYTHON) $(buildscript-dir)/extract_texi_filenames.py $<
+$(XREF_MAPS_DIR)/%.xref-map: $(outdir)/%.texi
+       $(PYTHON) $(buildscript-dir)/extract_texi_filenames.py -o $(XREF_MAPS_DIR) $<
 
 
 $(outdir)/version.%: $(top-src-dir)/VERSION
index 8b6669af21a28dcb24a68a297c5d4ee821656f5a..6d25079ebe8bfa020d512cc2ac6727d3cf5e4055 100644 (file)
@@ -2,7 +2,7 @@
 
 default: $(INFO_FILES)
 
-local-WWW-2: $(addprefix $(outdir)/,$(TEXI_FILES:.texi=.html))
+local-WWW-1: $(XREF_MAPS_FILES)
 
 local-doc: $(OUTTXT_FILES)
 
index d0ffdf90d6f9a3ebd73c7d95630ed1cc219ca5f3..1a67332d4bdcca35adc0c8ba8870d6611bc005d9 100644 (file)
@@ -13,10 +13,16 @@ TEXINFO_PAPERSIZE_OPTION= $(if $(findstring $(PAPERSIZE),a4),,-t @afourpaper)
 MAKEINFO_FLAGS = --enable-encoding
 MAKEINFO = LANG= $(MAKEINFO_PROGRAM) $(MAKEINFO_FLAGS)
 
+# texi2html xref map files
+XREF_MAPS_DIR=$(top-build-dir)/out/xref-maps
+XREF_MAPS_FILES=$(INFO_DOCS:%=$(XREF_MAPS_DIR)/%.xref-map)
+
+# texi2html flags
 ifneq ($(ISOLANG),) 
 TEXI2HTML_LANG = --lang=$(ISOLANG)
 endif
-TEXI2HTML_FLAGS += --css-ref=lilypond.css $(DOCUMENTATION_INCLUDES)
+TEXI2HTML_FLAGS += --css-ref=lilypond.css $(DOCUMENTATION_INCLUDES) \
+  --I=$(XREF_MAPS_DIR)
 TEXI2HTML_INIT = --init-file=$(top-src-dir)/lilypond-texi2html.init
 TEXI2HTML = $(TEXI2HTML_PROGRAM) $(TEXI2HTML_FLAGS) $(TEXI2HTML_LANG)