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
# bootstrap stepmake:
#
STEPMAKE_TEMPLATES=toplevel po install
+LOCALSTEPMAKE_TEMPLATES=lilypond
+
include $(depth)/make/stepmake.make
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
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
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):
#!@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
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 = ((' -- ', ' – '),
(' --- ', ' — '))
def crossmanual_ref_gettext (m):
return '<a href="' + m.group(1) + '">' + _(m.group(2)) + '</a>'
-for filename in args[3:]:
+for filename in files:
f = open (filename, 'r')
page = f.read ()
f.close()
+++ /dev/null
-#!@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 ('</?body>', 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] + '<body>' + parts[1] + '</body>' + 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
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):
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])
# -*- 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
#
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)')
if os.path.exists (p):
process_file (p)
-for filename in args[3:]:
+for filename in files:
process_file (filename)
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]
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)')
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,
-$(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
# 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
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)
--- /dev/null
+#!@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 ('</?body>', 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] + '<body>' + parts[1] + '</body>' + 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])