]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix and improve documentation files linking
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 1 Jul 2007 15:46:30 +0000 (17:46 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 1 Jul 2007 15:46:30 +0000 (17:46 +0200)
- fix linking bugs introduced when adding mass-link.py and support for
translated PDFs,
- get rid of symlinks in offline docs target so the docs are more
usable on Windows.

GNUmakefile.in
buildscripts/add_html_footer.py
buildscripts/mass-link.py
buildscripts/www_post.py
make/doclang-targets.make

index f821cc57d73a4fc8b5264ceacb03a4a16f3eb8c9..00345e39dc760f509f46524d42e724aed8d9697f 100644 (file)
@@ -99,6 +99,7 @@ local-WWW-post:
        rm -rf $(outdir)/online-root
        rm -rf $(outdir)/offline-root
        $(PYTHON) $(buildscript-dir)/www_post.py $(PACKAGE_NAME) $(TOPLEVEL_VERSION) $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(outdir) "$(WEB_TARGETS)"
+       find $(outdir)/offline-root -type l -delete
 
 
 tree-prefix = $(outdir)
index 7e331ba710aec86a369c5809f567eb0a97c473ce..802134f9f487370826242fdbc6d3ed05b528abc7 100644 (file)
@@ -83,6 +83,20 @@ def build_pages_dict (filelist):
             else:
                 pages_dict[g[0]].append (e)
 
+def source_links_replace (m, source_val):
+    return 'href="' + os.path.join (source_val, m.group (1)) + '"'
+
+# On systems without symlinks (e.g. Windows), docs are not very usable
+# Get rid of symlinks here (also in GNUmakefile.in (local-WWW-post))
+def replace_symlinks_urls (s, prefix):
+    if prefix.startswith ('Documentation/user/'):
+        s = re.sub ('(href|src)="(lily-.*?|.*?-flat-.*?)"', '\\1="../\\2"', s)
+    source_path = os.path.join (os.path.dirname (prefix), 'source')
+    if not os.path.islink (source_path):
+        return s
+    source_val = os.readlink (source_path)
+    return re.sub ('href="source/(.*?)"', lambda m: source_links_replace (m, source_val), s)
+
 def add_header (s):
     """Add header (<BODY> and doctype)"""
     if re.search (header_tag, s) == None:
@@ -102,10 +116,6 @@ def add_header (s):
             s = doctype + s
         return s
 
-def info_external_ref_remove (s):
-    """Remove info's annoying's indication of referencing external document"""
-    return re.sub (' \((lilypond|lilypond-internals|music-glossary)\)</a>', '</a>', s)
-
 def add_title (s):
     # urg
     # maybe find first node?
@@ -247,9 +257,9 @@ def add_html_footer (translation,
             in_f.close()
 
             s = re.sub ('%', '%%', s)
+            if target == 'offline':
+                s = replace_symlinks_urls (s, prefix)
             s = add_header (s)
-            # seems to be no more needed
-            # s = info_external_ref_remove (s)
 
             ### add footer
             if re.search (footer_tag, s) == None:
@@ -259,11 +269,6 @@ def add_html_footer (translation,
                 page_flavors = process_links (s, prefix, lang_ext, file_name, missing, target)
                 # Add menu after stripping: must not have autoselection for language menu.
                 page_flavors = add_menu (page_flavors, prefix, available, target, translation)
-            # urg, this stuff is outdated and seems useless, let's disable it
-            #else:
-            #    for e in [l.webext for l in langdefs.LANGUAGES]:
-            #        if not e in pages_dict[prefix]:
-            #            page_flavors[langdefs.lang_file_name (prefix, e, '.html')] = s
             subst = dict ([i for i in globals().items() if type (i[1]) is str])
             subst.update (dict ([i for i in locals().items() if type (i[1]) is str]))
             for k in page_flavors.keys():
index 61ea81e2db40a5f24036ab3117c3614be2294e3e..113495512d8c7394d0356efd05cc7f5694b4be3d 100644 (file)
@@ -5,20 +5,23 @@
 #
 # create hard or symbolic links to SOURCEDIR/FILES in DESTDIR
 #
-# if --prepend-suffix is specified, link to foo.bar will be called fooSUFFIX.bar
-# shell-wildcard expansion is performed on FILES.
-
-print "mass_link.py"
+# If --prepend-suffix is specified, link to foo.bar will be called fooSUFFIX.bar.
+# Shell wildcards expansion is performed on FILES.
 
 import sys
 import os
 import glob
 import getopt
 
+print "mass-link.py"
+
 optlist, args = getopt.getopt (sys.argv[1:], '', ['prepend-suffix='])
 link_type, source_dir, dest_dir = args[0:3]
 files = args[3:]
 
+source_dir = os.path.normpath (source_dir)
+dest_dir = os.path.normpath (dest_dir)
+
 prepended_suffix = ''
 for x in optlist:
     if x[0] == '--prepend-suffix':
@@ -46,7 +49,12 @@ sourcefiles = []
 for pattern in files:
     sourcefiles += (glob.glob (os.path.join (source_dir, pattern)))
 
-destfiles = map (lambda f: os.path.join (dest_dir, insert_suffix (os.path.basename (f))), sourcefiles)
+def relative_path (f):
+    if source_dir == '.':
+        return f
+    return f[len (source_dir) + 1:]
+
+destfiles = map (lambda f: os.path.join (dest_dir, insert_suffix (relative_path (f))), sourcefiles)
 
 def force_link (src,dest):
     if os.path.exists (dest):
index 39c0747d7e309ad19185765f1f823ddf6ae36e64..a61c75961bf29a08992c4c565eeb8f3a9a384ef4 100644 (file)
@@ -18,17 +18,21 @@ doc_dirs = ['input', 'Documentation', outdir]
 target_pattern = os.path.join (outdir, '%s-root')
 
 static_files = {
-    # ugly hack: the following overwrites HTML Info dir with a link to
-    # the (more useful) documentation index
-    os.path.join ('Documentation/user', outdir, 'index.html'):
-    '''<META HTTP-EQUIV="refresh" content="0;URL=../index.html">
-<html><body>Redirecting to the documentation index...</body></html>\n''',
     os.path.join (outdir, 'index.html'):
     '''<META HTTP-EQUIV="refresh" content="0;URL=Documentation/index.html">
 <html><body>Redirecting to the documentation index...</body></html>\n''',
     os.path.join (outdir, 'VERSION'):
     package_version + '\n' }
 
+import langdefs
+
+# ugly hack: the following overwrites HTML Info dir with a link to
+# the (more useful) documentation index
+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)
 
@@ -36,7 +40,6 @@ for f, contents in static_files.items ():
 sys.path.append (buildscript_dir)
 import mirrortree
 import add_html_footer
-import langdefs
 
 sys.stderr.write ("Mirrorring...\n")
 dirs, symlinks, files = mirrortree.walk_tree (
index 30a438692d2742bb56ad0b8abb258b0c3e048806..c585ab01ab06276f3231f53cdbde2eb8f2c69383 100644 (file)
@@ -29,7 +29,7 @@ $(outdir)/%.pdf: $(outdir)/%.texi $(outdir)/user-ln doc-po
        cd $(outdir); texi2pdf --batch $(TEXINFO_PAPERSIZE_OPTION) $(notdir $*).pdftexi
 
 local-WWW: $(outdir)/lilypond.pdf $(outdir)/lilypond/index.html
-       find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/mass-link.py --prepend-suffix .$(ISOLANG) hard . $(depth)/Documentation/user/$(outdir) $(outdir)/lilypond.pdf
+       cd $(outdir); find -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) ../$(buildscript-dir)/mass-link.py --prepend-suffix .$(ISOLANG) hard . $(top-build-dir)/Documentation/user/$(outdir) lilypond.pdf
 # ugh, this is not enough to avoid wasting build time, $(outdir)/user-ln should be touched for all languages
        touch -mr $(top-build-dir)/Documentation/user/$(outdir) $(outdir)/user-ln