From: John Mandereau Date: Sat, 19 Apr 2008 16:36:29 +0000 (+0200) Subject: Merge branch 'master' of /home/lilycvs/git/lily/ X-Git-Tag: release/2.11.45-1~43 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b9c3fa6bdea9d17ef1e93d3595e1b3f69233a49a;hp=2aa01c375a60a5b5c9a41721dd0645e230aa6e49;p=lilypond.git Merge branch 'master' of /home/lilycvs/git/lily/ * 'master' of /home/lilycvs/git/lily/: Add --latex lilypond-book option --- diff --git a/Documentation/GNUmakefile b/Documentation/GNUmakefile index dbf4805d50..1524efc58b 100644 --- a/Documentation/GNUmakefile +++ b/Documentation/GNUmakefile @@ -1,7 +1,7 @@ depth = .. NAME = documentation -LANGS = $(shell $(PYTHON) $(buildscript-dir)/langdefs.py) +LANGS = $(shell $(PYTHON) $(top-src-dir)/python/langdefs.py) SUBDIRS=user bibliography pictures topdocs misc po $(LANGS) STEPMAKE_TEMPLATES=documentation texinfo tex LOCALSTEPMAKE_TEMPLATES=lilypond ly diff --git a/GNUmakefile.in b/GNUmakefile.in index fb0265a36e..92f33fb18a 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -30,6 +30,8 @@ INSTALLATION_FILES=$(config_make) VERSION # bootstrap stepmake: # STEPMAKE_TEMPLATES=toplevel po install +LOCALSTEPMAKE_TEMPLATES=lilypond + include $(depth)/make/stepmake.make @@ -85,7 +87,7 @@ local-WWW-post: echo -e 'AddDefaultCharset utf-8\nAddCharset utf-8 .html\nAddCharset utf-8 .en\nAddCharset utf-8 .nl\nAddCharset utf-8 .txt\n' > $(top-build-dir)/.htaccess $(PYTHON) $(buildscript-dir)/mutopia-index.py -o $(outdir)/examples.html input/ find $(outdir) -name '*-root' | xargs rm -rf - $(PYTHON) $(buildscript-dir)/www_post.py $(PACKAGE_NAME) $(TOPLEVEL_VERSION) $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(outdir) "$(WEB_TARGETS)" + $(PYTHON) $(buildscript-dir)/www_post.py $(PACKAGE_NAME) $(TOPLEVEL_VERSION) $(buildscript-dir) $(outdir) "$(WEB_TARGETS)" find $(outdir)/offline-root -type l -delete diff --git a/buildscripts/add_html_footer.py b/buildscripts/add_html_footer.py index bd7d8409ce..3c1bf0a225 100644 --- a/buildscripts/add_html_footer.py +++ b/buildscripts/add_html_footer.py @@ -231,15 +231,13 @@ def add_menu (page_flavors, prefix, available, target, translation): return page_flavors -def add_html_footer (translation, - package_name = '', +def add_html_footer (package_name = '', package_version = '', target = 'offline', name_filter = lambda s: s): """Add header, footer to a number of HTML files Arguments: - translation gettext translations dictionary, with language codes as keys package_name=NAME set package_name to NAME package_version=VERSION set package version to VERSION targets=offline|online set page processing depending on the target @@ -248,6 +246,7 @@ def add_html_footer (translation, negotiation name_filter a HTML file name filter """ + translation = langdefs.translation localtime = time.strftime ('%c %Z', time.localtime (time.time ())) if re.search ("http://", mail_address): diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py index 65efe8f283..a63fc3c359 100644 --- a/buildscripts/html-gettext.py +++ b/buildscripts/html-gettext.py @@ -1,7 +1,7 @@ #!@PYTHON@ # html-gettext.py -# USAGE: html-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES +# USAGE: html-gettext.py [-o OUTDIR] LANG FILES # # -o OUTDIR specifies that output files should be written in OUTDIR # rather than be overwritten @@ -11,22 +11,20 @@ import sys import re import os import getopt -import gettext + +import langdefs optlist, args = getopt.getopt(sys.argv[1:],'o:') -buildscript_dir, localedir, lang = args[0:3] +lang = args[0] +files = args [1:] outdir = '.' for x in optlist: if x[0] == '-o': outdir = x[1] -sys.path.append (buildscript_dir) -import langdefs - double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep -t = gettext.translation('lilypond-doc', localedir, [lang]) -my_gettext = t.gettext +my_gettext = langdefs.translation[lang] html_codes = ((' -- ', ' – '), (' --- ', ' — ')) @@ -80,7 +78,7 @@ def h_gettext (m): def crossmanual_ref_gettext (m): return '' + _(m.group(2)) + '' -for filename in args[3:]: +for filename in files: f = open (filename, 'r') page = f.read () f.close() diff --git a/buildscripts/langdefs.py b/buildscripts/langdefs.py deleted file mode 100644 index 4c9a0a7d8b..0000000000 --- a/buildscripts/langdefs.py +++ /dev/null @@ -1,64 +0,0 @@ -#!@PYTHON@ -#-*- coding: utf-8 -*- - -""" -Documentation i18n module -""" - -import re - -def lang_file_name (p, langext, ext): - if langext != '': - return p + '.' + langext + ext - return p + ext - -class LanguageDef: - def __init__ (self, code, name, webext=None, double_punct_char_sep='', html_filter=lambda s: s): - self.code = code - self.name = name - self.enabled = True - if webext == None: - self.webext = self.code - else: - self.webext = webext - self.double_punct_char_sep = double_punct_char_sep - self.html_filter = html_filter - - def file_name (self, prefix, ext): - return lang_file_name (prefix, self.webext, ext) - - -# All language information needed for documentation i18n is defined -# here. For each 'Documentation/ab' directory containing docs -# translated in 'ab', there should be one entry in LANGUAGES. - -site = LanguageDef ('en', 'English', webext='') - -html_page_body = re.compile ('', re.M | re.I) -french_html_typo_rules = ((' :', ' :'), - (' ;', ' ;'), - (' ?', ' ?'), - (' !', ' !')) - -def french_html_filter (page): - parts = html_page_body.split (page) - for r in french_html_typo_rules: - parts[1] = parts[1].replace (r[0], r[1]) - return parts[0] + '' + parts[1] + '' + parts[2] - -fr = LanguageDef ('fr', 'français', double_punct_char_sep=' ', html_filter = french_html_filter) -es = LanguageDef ('es', 'español') -de = LanguageDef ('de', 'deutsch') - -# Outdated or broken translations may be disabled -# (please run 'make web-clean' before doing that): -#fr.enabled = False - -LANGUAGES = (site, fr, es, de) - -if __name__ == '__main__': - print ' '.join ([l.code for l in LANGUAGES if l.enabled and l.code != 'en']) -else: - LANGDICT = {} - for l in LANGUAGES: - LANGDICT[l.code] = l diff --git a/buildscripts/mass-link.py b/buildscripts/mass-link.py index 947cd8ccef..17412e5559 100644 --- a/buildscripts/mass-link.py +++ b/buildscripts/mass-link.py @@ -54,7 +54,10 @@ def relative_path (f): return f return f[len (source_dir) + 1:] -destfiles = map (lambda f: os.path.join (dest_dir, insert_suffix (relative_path (f))), sourcefiles) +destfiles = [os.path.join (dest_dir, insert_suffix (relative_path (f))) for f in sourcefiles] + +destdirs = set ([os.path.dirname (dest) for dest in destfiles]) +[os.makedirs (d) for d in destdirs if not os.path.exists (d)] def force_link (src,dest): if os.path.exists (dest): diff --git a/buildscripts/mirrortree.py b/buildscripts/mirrortree.py index 507d56639a..0aa0bc8812 100644 --- a/buildscripts/mirrortree.py +++ b/buildscripts/mirrortree.py @@ -41,7 +41,7 @@ def walk_tree (tree_roots = [], for current_dir, dirs, files in os.walk(d): i = 0 while i < len(dirs): - if exclude_dirs_re.search (dirs[i]): + if exclude_dirs_re.search (os.path.join (current_dir, dirs[i])): del dirs[i] else: p = os.path.join (current_dir, dirs[i]) diff --git a/buildscripts/texi-gettext.py b/buildscripts/texi-gettext.py index 2c99352666..8fbc2243b7 100644 --- a/buildscripts/texi-gettext.py +++ b/buildscripts/texi-gettext.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # texi-gettext.py -# USAGE: texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES +# USAGE: texi-gettext.py [-o OUTDIR] LANG FILES # # -o OUTDIR specifies that output files should rather be written in OUTDIR # @@ -13,24 +13,22 @@ import sys import re import os import getopt -import gettext + +import langdefs optlist, args = getopt.getopt (sys.argv[1:],'o:') -buildscript_dir, localedir, lang = args[0:3] +lang = args[0] +files = args[1:] outdir = '.' for x in optlist: if x[0] == '-o': outdir = x[1] -sys.path.append (buildscript_dir) -import langdefs - double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep -t = gettext.translation('lilypond-doc', localedir, [lang]) -_doc = t.gettext +_doc = langdefs.translation[lang] -include_re = re.compile (r'@include ((?!lily-).*?)\.texi$', re.M) +include_re = re.compile (r'@include ((?!../lily-).*?)\.texi$', re.M) whitespaces = re.compile (r'\s+') ref_re = re.compile (r'(?ms)@(rglos|ruser|rprogram|ref)(\{)(.*?)(\})') node_section_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)') @@ -75,5 +73,5 @@ well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '') if os.path.exists (p): process_file (p) -for filename in args[3:]: +for filename in files: process_file (filename) diff --git a/buildscripts/www_post.py b/buildscripts/www_post.py index 278895aff9..b2d7ca510c 100644 --- a/buildscripts/www_post.py +++ b/buildscripts/www_post.py @@ -9,9 +9,8 @@ import sys import os import re -import gettext -package_name, package_version, buildscript_dir, localedir, outdir, targets = sys.argv[1:] +package_name, package_version, buildscript_dir, outdir, targets = sys.argv[1:] targets = targets.split (' ') outdir = os.path.normpath (outdir) doc_dirs = ['input', 'Documentation', outdir] @@ -49,7 +48,7 @@ sys.stderr.write ("Mirrorring...\n") dirs, symlinks, files = mirrortree.walk_tree ( tree_roots = doc_dirs, process_dirs = outdir, - exclude_dirs = '(^|/)(' + '|'.join ([l.code for l in langdefs.LANGUAGES]) + r'|po|out|.*?[.]t2d|\w*?-root)(/|$)', + exclude_dirs = '(^|/)(' + r'|po|out|out-test|.*?[.]t2d|\w*?-root)(/|$)|Documentation/(' + '|'.join ([l.code for l in langdefs.LANGUAGES]) + ')', find_files = r'.*?\.(?:midi|html|pdf|png|txt|ly|signature)$|VERSION', exclude_files = r'lily-[0-9a-f]+.*\.(pdf|txt)') @@ -92,17 +91,10 @@ if 'online' in targets: f.write ('#.htaccess\nDirectoryIndex index\n') f.close () -# load gettext messages catalogs -translation = {} -for l in langdefs.LANGUAGES: - if l.enabled and l.code != 'en': - translation[l.code] = gettext.translation('lilypond-doc', localedir, [l.code]).gettext - add_html_footer.build_pages_dict (html_files) for t in targets: sys.stderr.write ("Processing HTML pages for %s target...\n" % t) add_html_footer.add_html_footer ( - translation = translation, package_name = package_name, package_version = package_version, target = t, diff --git a/input/lsr/GNUmakefile b/input/lsr/GNUmakefile index d26872b5fd..6103529167 100644 --- a/input/lsr/GNUmakefile +++ b/input/lsr/GNUmakefile @@ -59,4 +59,4 @@ local-clean: local-WWW: info $(outdir)/lilypond-snippets.pdf \ $(outdir)/lilypond-snippets/index.html \ $(outdir)/lilypond-snippets-big-page.html \ - source-links + $(source-links) diff --git a/input/lsr/lilypond-snippets.tely b/input/lsr/lilypond-snippets.tely index 98d5eb1da1..b052256c49 100644 --- a/input/lsr/lilypond-snippets.tely +++ b/input/lsr/lilypond-snippets.tely @@ -13,6 +13,8 @@ @end tex @end iftex +@include version.itexi + @dircategory GNU LilyPond --- the music typesetter @direntry * LilyPond Snippets: (lilypond-snippets). Short tricks, tips, and examples. @@ -65,7 +67,7 @@ This document shows a selected set of LilyPond snippets from the Please note that it is not an exact subset of LSR: some snippets come from @file{input/new} LilyPond sources directory, and snippets from LSR are converted through @command{convert-ly}, as LSR is based on a stable -LilyPond version, and this document is for version @value{version}. +LilyPond version, and this document is for version @version{}. Snippets are grouped by tags; tags listed in the table of contents match a section of LilyPond notation manual. Snippets may have several tags, diff --git a/make/doclang-rules.make b/make/doclang-rules.make index 3a82132ec9..6c4dbc532d 100644 --- a/make/doclang-rules.make +++ b/make/doclang-rules.make @@ -6,7 +6,7 @@ $(outdir)/%-big-page.html: $(outdir)/%.texi $(outdir)/version.itexi -$(MAKEINFO) -P $(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $< $(outdir)/%.pdftexi: $(outdir)/%.texi doc-po $(outdir)/version.itexi - $(PYTHON) $(buildscript-dir)/texi-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) $< + $(PYTHON) $(buildscript-dir)/texi-gettext.py $(ISOLANG) $< $(outdir)/%.pdf: $(outdir)/%.pdftexi cd $(outdir); texi2pdf $(TEXI2PDF_FLAGS) $(TEXINFO_PAPERSIZE_OPTION) $(notdir $*).pdftexi diff --git a/make/doclang-targets.make b/make/doclang-targets.make index 4f4750c9a7..4fd4bad694 100644 --- a/make/doclang-targets.make +++ b/make/doclang-targets.make @@ -2,9 +2,9 @@ default: # BIG_PAGE_HTML_FILES is defined differently in each language makefile local-WWW: $(DEEP_HTML_FILES) $(PDF_FILES) doc-po $(BIG_PAGE_HTML_FILES) - find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) + find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(ISOLANG) find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME' | sed 's!$(outdir)/!!g' | xargs $(PYTHON) $(buildscript-dir)/mass-link.py --prepend-suffix .$(ISOLANG) hard $(outdir) $(top-build-dir)/Documentation/user/$(outdir) $(TELY_FILES:%.tely=%.pdf) - find $(outdir) \( -name 'lily-??????????.png' -o -name 'lily-??????????.ly' \) | sed 's!$(outdir)/!!g' | xargs $(PYTHON) $(buildscript-dir)/mass-link.py hard $(outdir) $(top-build-dir)/Documentation/user/$(outdir) + find $(outdir) \( -name 'lily-*.png' -o -name 'lily-*.ly' \) | sed 's!$(outdir)/!!g' | xargs $(PYTHON) $(buildscript-dir)/mass-link.py hard $(outdir) $(top-build-dir)/Documentation/user/$(outdir) doc-po: $(MAKE) -C $(depth)/Documentation/po out=www messages diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 6096bfb790..7fa9aa9ab3 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -48,6 +48,8 @@ endif TEXINPUTS=$(top-src-dir)/tex/:: export TEXINPUTS +export LYDOC_LOCALEDIR:= $(top-build-dir)/Documentation/po/out-www + #texi-html for www only: LILYPOND_BOOK_FORMAT=$(if $(subst out-www,,$(notdir $(outdir))),texi,texi-html) LY2DVI = $(LILYPOND_BINARY) diff --git a/python/langdefs.py b/python/langdefs.py new file mode 100644 index 0000000000..2b79caee70 --- /dev/null +++ b/python/langdefs.py @@ -0,0 +1,79 @@ +#!@PYTHON@ +#-*- coding: utf-8 -*- + +""" +Documentation i18n module +""" + +import re + +def lang_file_name (p, langext, ext): + if langext != '': + return p + '.' + langext + ext + return p + ext + +class LanguageDef: + def __init__ (self, code, name, webext=None, double_punct_char_sep='', html_filter=lambda s: s): + self.code = code + self.name = name + self.enabled = True + if webext == None: + self.webext = self.code + else: + self.webext = webext + self.double_punct_char_sep = double_punct_char_sep + self.html_filter = html_filter + + def file_name (self, prefix, ext): + return lang_file_name (prefix, self.webext, ext) + + +# All language information needed for documentation i18n is defined +# here. For each 'Documentation/ab' directory containing docs +# translated in 'ab', there should be one entry in LANGUAGES. + +site = LanguageDef ('en', 'English', webext='') + +html_page_body = re.compile ('', re.M | re.I) +french_html_typo_rules = ((' :', ' :'), + (' ;', ' ;'), + (' ?', ' ?'), + (' !', ' !')) + +def french_html_filter (page): + parts = html_page_body.split (page) + for r in french_html_typo_rules: + parts[1] = parts[1].replace (r[0], r[1]) + return parts[0] + '' + parts[1] + '' + parts[2] + +fr = LanguageDef ('fr', 'français', double_punct_char_sep=' ', html_filter = french_html_filter) +es = LanguageDef ('es', 'español') +de = LanguageDef ('de', 'deutsch') + +# Outdated or broken translations may be disabled +# (please run 'make web-clean' before doing that): +#fr.enabled = False + +LANGUAGES = (site, fr, es, de) + +if __name__ == '__main__': + print ' '.join ([l.code for l in LANGUAGES if l.enabled and l.code != 'en']) +else: + LANGDICT = {} + for l in LANGUAGES: + LANGDICT[l.code] = l + + try: + import gettext + import os + + translation = {} + for l in LANGUAGES: + if l.enabled and l.code != 'en': + t = gettext.translation('lilypond-doc', + os.environ['LYDOC_LOCALEDIR'], + [l.code]) + translation[l.code] = t.gettext + except: + sys.stderr.write ('URGUHIU\n') + translation = dict ([(l.code, lambda x: x) for l in LANGUAGES]) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index dbbc86b766..7be0bc78b6 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -217,6 +217,8 @@ global_options = None default_ly_options = { 'alt': "[image of music]" } +document_language = '' + # # Is this pythonic? Personally, I find this rather #define-nesque. --hwn # @@ -830,6 +832,7 @@ def verbatim_html (s): texinfo_lang_re = re.compile ('(?m)^@documentlanguage (.*?)( |$)') def set_default_options (source, default_ly_options, format): + global document_language if LINE_WIDTH not in default_ly_options: if format == LATEX: textwidth = get_latex_textwidth (source) @@ -837,9 +840,9 @@ def set_default_options (source, default_ly_options, format): elif format == TEXINFO: m = texinfo_lang_re.search (source) if m and not m.group (1).startswith ('en'): - default_ly_options[LANG] = m.group (1) + document_language = m.group (1) else: - default_ly_options[LANG] = '' + document_language = '' for regex in texinfo_line_widths: # FIXME: @layout is usually not in # chunk #0: @@ -1327,7 +1330,7 @@ class LilypondSnippet (Snippet): base = self.basename () if TEXIDOC in self.option_dict: texidoc = base + '.texidoc' - translated_texidoc = texidoc + default_ly_options[LANG] + translated_texidoc = texidoc + document_language if os.path.exists (translated_texidoc): str += '@include %(translated_texidoc)s\n\n' % vars () elif os.path.exists (texidoc): diff --git a/stepmake/stepmake/documentation-rules.make b/stepmake/stepmake/documentation-rules.make index 81469e2e6f..b87e6428fa 100644 --- a/stepmake/stepmake/documentation-rules.make +++ b/stepmake/stepmake/documentation-rules.make @@ -13,5 +13,3 @@ $(outdir)/%.png: %.xpm $(outdir)/%.txt: $(outdir)/%.1 troff -man -Tascii $< | grotty -b -u -o > $@ -include $(stepdir)/texinfo-rules.make -