diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/auxiliar/makelsr.py | 59 | ||||
-rw-r--r-- | scripts/build/www_post.py | 15 |
2 files changed, 35 insertions, 39 deletions
diff --git a/scripts/auxiliar/makelsr.py b/scripts/auxiliar/makelsr.py index 80628cbf16..88731719c1 100755 --- a/scripts/auxiliar/makelsr.py +++ b/scripts/auxiliar/makelsr.py @@ -5,23 +5,31 @@ import os import glob import re +os.environ['PYTHONPATH'] += ':python' +import langdefs + +DEST = os.path.join ('Documentation', 'snippets') +NEW_LYS = os.path.join ('Documentation', 'snippets', 'new') +TEXIDOCS = [os.path.join ('Documentation', language_code, 'texidocs') + for language_code in langdefs.LANGDICT] + USAGE = ''' Usage: makelsr.py [LSR_SNIPPETS_DIR] This script must be run from top of the source tree; -it updates snippets input/lsr with snippets in input/new or LSR_SNIPPETS_DIR. -If a snippet is present in both directories, the one from input/new is preferred. -''' - -LY_HEADER_LSR = '''%% Do not edit this file; it is auto-generated from LSR http://lsr.dsi.unimi.it +it updates snippets %(DEST)s with snippets +from %(NEW_LYS)s or LSR_SNIPPETS_DIR. +If a snippet is present in both directories, the one +from %(NEW_LYS)s is preferred. +''' % vars () + +LY_HEADER_LSR = '''%% Do not edit this file; it is automatically +%% generated from LSR http://lsr.dsi.unimi.it %% This file is in the public domain. ''' -LY_HEADER_NEW = '''%% Do not edit this file; it is auto-generated from input/new +LY_HEADER_NEW = '''%% Do not edit this file; it is automatically +%% generated from %s %% This file is in the public domain. -''' - -DEST = os.path.join ('input', 'lsr') -NEW_LYS = os.path.join ('input', 'new') -TEXIDOCS = os.path.join ('input', 'texidocs') +''' % NEW_LYS TAGS = [] # NR 1 @@ -70,11 +78,13 @@ ly_new_version_re = re.compile (r'\\version\s*"(.+?)"') # add tags to ly files from LSR def add_tags (ly_code, tags): - return begin_header_re.sub ('\\g<0>\n lsrtags = "' + tags + '"\n', ly_code, 1) + return begin_header_re.sub ('\\g<0>\n lsrtags = "' + tags + '"\n', + ly_code, 1) # for snippets from input/new, add message for earliest working version def add_version (ly_code): - return '''%% Note: this file works from version ''' + ly_new_version_re.search (ly_code).group (1) + '\n' + return '''%% Note: this file works from version ''' + \ + ly_new_version_re.search (ly_code).group (1) + '\n' def copy_ly (srcdir, name, tags): global unsafe @@ -83,15 +93,16 @@ def copy_ly (srcdir, name, tags): tags = ', '.join (tags) s = open (os.path.join (srcdir, name)).read () - texidoc_translations_path = os.path.join (TEXIDOCS, - os.path.splitext (name)[0] + '.texidoc') - if os.path.exists (texidoc_translations_path): - texidoc_translations = open (texidoc_translations_path).read () - # Since we want to insert the translations verbatim using a - # regexp, \\ is understood as ONE escaped backslash. So we have - # to escape those backslashes once more... - texidoc_translations = texidoc_translations.replace ('\\', '\\\\') - s = begin_header_re.sub ('\\g<0>\n' + texidoc_translations, s, 1) + for path in TEXIDOCS: + texidoc_translation_path = \ + os.path.join (path, os.path.splitext (name)[0] + '.texidoc') + if os.path.exists (texidoc_translation_path): + texidoc_translation = open (texidoc_translation_path).read () + # Since we want to insert the translations verbatim using a + # regexp, \\ is understood as ONE escaped backslash. So we have + # to escape those backslashes once more... + texidoc_translation = texidoc_translation.replace ('\\', '\\\\') + s = begin_header_re.sub ('\\g<0>\n' + texidoc_translation, s, 1) if in_dir and in_dir in srcdir: s = LY_HEADER_LSR + add_tags (s, tags) @@ -188,7 +199,7 @@ if unsafe: sys.stderr.write (''' Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY! - git add input/lsr/*.ly + git add %s/*.ly xargs git diff HEAD < lsr-unsafe.txt -''') +''' % DEST) diff --git a/scripts/build/www_post.py b/scripts/build/www_post.py index c568734c1b..b329390a5d 100644 --- a/scripts/build/www_post.py +++ b/scripts/build/www_post.py @@ -29,20 +29,8 @@ static_files = { <html><body>Redirecting to the documentation index...</body></html>\n''', os.path.join (outdir, 'VERSION'): package_version + '\n', - os.path.join ('input', 'lsr', outdir, 'index.html'): - '''<META HTTP-EQUIV="refresh" content="0;URL=../../index.html"> -<html><body>Redirecting to the documentation index...</body></html>\n''' } -for l in langdefs.LANGUAGES: - static_files[os.path.join ( - 'Documentation', - 'user', - outdir, - l.file_name ('index', '.html'))] = \ - '<META HTTP-EQUIV="refresh" content="0;URL=../' + l.file_name ('index', '.html') + \ - '">\n<html><body>Redirecting to the documentation index...</body></html>\n' - for f, contents in static_files.items (): open (f, 'w').write (contents) @@ -85,9 +73,6 @@ for t in targets: if not os.path.exists (dest): os.symlink (p, dest) - ## ad-hoc renaming to make xrefs between PDFs work - os.rename (os.path.join (out_root, 'input/lsr/lilypond-snippets.pdf'), - os.path.join (out_root, 'Documentation/user/lilypond-snippets.pdf')) # need this for content negotiation with documentation index if 'online' in targets: |