From 91708b30fba67f8fd589980e03ff420c26473a5a Mon Sep 17 00:00:00 2001 From: John Mandereau Date: Fri, 29 Feb 2008 16:43:15 +0100 Subject: [PATCH] Change Snippets compilation - clean up input/lsr/GNUmakefile - compile Snippets (input/lsr) in Info, rename 'snippets' to 'lilypond-snippets' to avoid possible name clash in /usr/share/info, - move local-install-info target from Documentation/user/GNUmakefile to texinfo-targets.make, - lilypond-book: fix output_print_filename (use format argument iso. global options format) and call this function properly for Texinfo snippet formatting, - add generic purpose @rlsr macro; immediate use is for linking to snippets tags, but it could be used later to link to individual snippets, - www_post.py, add_html_footer.py: add ad-hoc code to make xrefs to Snippets work. --- .gitignore | 1 + Documentation/index.html.in | 6 +- Documentation/user/GNUmakefile | 79 +------------------ Documentation/user/macros.itexi | 23 +++++- buildscripts/add_html_footer.py | 12 ++- buildscripts/lys-to-tely.py | 4 +- buildscripts/www_post.py | 4 + input/lsr/GNUmakefile | 33 ++++++-- .../{snippets.tely => lilypond-snippets.tely} | 28 +++---- scripts/lilypond-book.py | 11 +-- stepmake/stepmake/texinfo-targets.make | 69 +++++++++++++++- 11 files changed, 146 insertions(+), 124 deletions(-) rename input/lsr/{snippets.tely => lilypond-snippets.tely} (86%) diff --git a/.gitignore b/.gitignore index 78ddd2aade..014cbcf08c 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ pats tags test-output-distance Documentation/user/lilypond +input/lsr/lilypond-snippets diff --git a/Documentation/index.html.in b/Documentation/index.html.in index adc9705778..82f04b82b9 100644 --- a/Documentation/index.html.in +++ b/Documentation/index.html.in @@ -101,9 +101,9 @@ href="user/lilypond-program/index.html">Application Usage (AU) in PDF)
(how to install and run the program) -
  • Snippets -(in one big page, -in PDF) +
  • Snippets +(in one big page, +in PDF)
    (Short tricks, tips, and examples) diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile index f94800161c..0a39a41a46 100644 --- a/Documentation/user/GNUmakefile +++ b/Documentation/user/GNUmakefile @@ -24,11 +24,13 @@ PDF_FILES = $(TELY_FILES:%.tely=$(outdir)/%.pdf) # this prevents aux files from being reused for translated docs TEXI2PDF_FLAGS = --tidy +MAIN_INFO_DOC = lilypond INFO_DOCS = lilypond lilypond-internals music-glossary lilypond-program lilypond-learning INFO_FILES = $(INFO_DOCS:%=$(outdir)/%.info) ifeq ($(out),www) INFO_IMAGES_DIR = lilypond +DEST_INFO_IMAGES_SUBDIR = Documentation/user endif STEPMAKE_TEMPLATES=tex texinfo omf documentation @@ -48,80 +50,6 @@ info: $(INFO_FILES) xml: $(outdir)/lilypond/lilypond.xml $(outdir)/lilypond-internals/lilypond-internals.xml -# There are two modes for info: with and without images. -ifeq ($(out),www) - -# This builds all .info targets with images, in out-www. -# Viewable with a recent Emacs, doing: C-u C-h i out-www/lilypond.info - -local-install-info: info - -$(INSTALL) -d $(DESTDIR)$(infodir) -ifneq ($(patsubst %/local,%,$(DESTDIR)$(prefix)),/usr) -## Can not have absolute symlinks because some binary packages build schemes -## install files in nonstandard root. Best we can do is to notify the -## builder or packager. - @echo - @echo "***************************************************************" - @echo "Please add or update the LilyPond direntries, do" - @echo - @echo " install-info --info-dir=$(infodir) $(outdir)/lilypond.info" - @echo - @echo "For images in the INFO docs to work, do: " - @echo - @echo " (cd $(infodir) && ln -sfT ../doc/lilypond/html/Documentation/user lilypond)" - @echo "or add something like that to the postinstall script." - @echo -else # installing directly into standard /usr/... - -$(INSTALL) -d $(DESTDIR)$(infodir) - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-program.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-learning.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-internals.info - -install-info --remove --info-dir=$(infodir) $(outdir)/music-glossary.info - install-info --info-dir=$(infodir) $(outdir)/lilypond.info - cd $(infodir) && ln -sfT $(webdir)/Documentation/user lilypond -endif # installing directly into standard /usr/... - -local-uninstall-WWW: - rm -f $(infodir)/lilypond - -else # out!=www - -local-install-info: info - -$(INSTALL) -d $(DESTDIR)$(package_infodir) -ifneq ($(patsubst %/local,%,$(DESTDIR)$(prefix)),/usr) -## Can not have absolute symlinks because some binary packages build schemes -## install files in nonstandard root. Best we can do is to notify the -## builder or packager. - @echo - @echo "***************************************************************" - @echo "Please add or update the LilyPond direntries, do" - @echo - @echo " install-info --info-dir=$(infodir) out/lilypond.info" - @echo - @echo "For images in the INFO docs to work, do" - @echo - @echo " make out=www install-info " - @echo - @echo "and read the extra instructions." - @echo -else # installing directly into standard /usr/... - -$(INSTALL) -d $(DESTDIR)$(infodir) - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-program.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-learning.info - -install-info --remove --info-dir=$(infodir) $(outdir)/lilypond-internals.info - -install-info --remove --info-dir=$(infodir) $(outdir)/music-glossary.info - install-info --info-dir=$(infodir) $(outdir)/lilypond.info - @echo - @echo "***************************************************************" - @echo "For images in the INFO docs to work, do" - @echo - @echo " make out=www install-info " - @echo -endif # installing into standard /usr/* root# installing into /usr/... - -endif # out!=www # All web targets, except info image symlinks and info docs are # installed in non-recursing target from TOP-SRC-DIR @@ -191,7 +119,8 @@ DEEP_HTML_FILES =\ $(outdir)/lilypond-learning/index.html # Symlinks to refer to external source documents from split and non-split HTML -source-links = $(outdir)/source $(outdir)/lilypond/source $(outdir)/music-glossary/source $(outdir)/lilypond-program/source $(outdir)/lilypond-learning/source +source-links = $(outdir)/source $(outdir)/lilypond/source $(outdir)/music-glossary/source \ + $(outdir)/lilypond-program/source $(outdir)/lilypond-learning/source $(outdir)/source: @rm -f $(@) diff --git a/Documentation/user/macros.itexi b/Documentation/user/macros.itexi index 40905c2333..4ef3123bfd 100644 --- a/Documentation/user/macros.itexi +++ b/Documentation/user/macros.itexi @@ -167,6 +167,10 @@ @ref{\TEXT\,,,lilypond-learning-big-page} @end macro +@macro rlsr{TEXT} +@ref{\TEXT\,,,lilypond-snippets-big-page} +@end macro + @end ifset @@ -197,6 +201,10 @@ @ref{\TEXT\,,,lilypond-learning} @end macro +@macro rlsr{TEXT} +@ref{\TEXT\,,,lilypond-snippets} +@end macro + @end ifclear @end ifhtml @@ -230,6 +238,10 @@ @ref{\TEXT\,,,lilypond-learning} @end macro +@macro rlsr{TEXT} +@ref{\TEXT\,,,lilypond-snippets} +@end macro + @end ifdocbook @@ -261,6 +273,10 @@ @ref{\TEXT\,,,lilypond-learning} @end macro +@macro rlsr{TEXT} +@ref{\TEXT\,,,lilypond-snippets} +@end macro + @end ifinfo @@ -279,17 +295,18 @@ @macro rprogram{TEXT} program usage manual, @ref{\TEXT\,,,lilypond-program} -@c @internalsref{\TEXT\} @end macro @macro ruser{TEXT} notation reference, @ref{\TEXT\,,,lilypond} -@c @internalsref{\TEXT\} @end macro @macro rlearning{TEXT} learning manual, @ref{\TEXT\,,,lilypond-learning} -@c @internalsref{\TEXT\} +@end macro + +@macro rlsr{TEXT} +@ref{\TEXT\,,,lilypond-snippets} @end macro @end iftex diff --git a/buildscripts/add_html_footer.py b/buildscripts/add_html_footer.py index b410b2a39e..da827c1301 100644 --- a/buildscripts/add_html_footer.py +++ b/buildscripts/add_html_footer.py @@ -89,13 +89,19 @@ def source_links_replace (m, source_val): splitted_docs_re = re.compile ('(input/lsr/out-www/snippets|Documentation/user/out-www/(lilypond|music-glossary|lilypond-program|lilypond-learning))/') -# On systems without symlinks (e.g. Windows), docs are not very usable -# Get rid of symlinks references here +snippets_ref_re = re.compile (r'href="(\.\./)?lilypond-snippets') + +## Windows does not support symlinks. +# This function avoids creating symlinks for splitted HTML manuals # Get rid of symlinks in GNUmakefile.in (local-WWW-post) # this also fixes missing PNGs only present in translated docs -def replace_symlinks_urls (s, prefix): +def _urls (s, prefix): if splitted_docs_re.match (prefix): s = re.sub ('(href|src)="(lily-.*?|.*?[.]png)"', '\\1="../\\2"', s) + + # fix Snippets xrefs ad hoc + s = snippets_ref_re.sub ('href="source/input/lsr/lilypond-snippets', s) + source_path = os.path.join (os.path.dirname (prefix), 'source') if not os.path.islink (source_path): return s diff --git a/buildscripts/lys-to-tely.py b/buildscripts/lys-to-tely.py index 22aff30be5..e2df5a6bc3 100644 --- a/buildscripts/lys-to-tely.py +++ b/buildscripts/lys-to-tely.py @@ -81,7 +81,6 @@ for opt in options: raise Exception ('unknown option: ' + o) def name2line (n): - # UGR s = r""" @ifhtml @html @@ -89,7 +88,8 @@ def name2line (n): @end html @end ifhtml -@lilypondfile[%s]{%s}""" % (os.path.basename (n), fragment_options, n) +@lilypondfile[%s]{%s} +""" % (os.path.basename (n), fragment_options, n) return s if files: diff --git a/buildscripts/www_post.py b/buildscripts/www_post.py index e27aeb7d2e..278895aff9 100644 --- a/buildscripts/www_post.py +++ b/buildscripts/www_post.py @@ -82,6 +82,10 @@ 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: f = open (os.path.join (target_pattern % 'online', 'Documentation/.htaccess'), 'w') diff --git a/input/lsr/GNUmakefile b/input/lsr/GNUmakefile index 1ca2cbbf52..ec25f7310d 100644 --- a/input/lsr/GNUmakefile +++ b/input/lsr/GNUmakefile @@ -6,6 +6,12 @@ STEPMAKE_TEMPLATES=documentation texinfo tex LOCALSTEPMAKE_TEMPLATES=lilypond ly EXTRA_DIST_FILES += README $(call src-wildcard,*.snippet-list) +MAIN_INFO_DOC = lilypond-snippets +INFO_DOCS = lilypond-snippets +INFO_FILES = $(INFO_DOCS:%=$(outdir)/%.info) +INFO_IMAGES_DIR = lilypond-snippets +DEST_INFO_IMAGES_SUBDIR = input/lsr + include $(depth)/make/stepmake.make IN_ITELY_FILES = $(call src-wildcard,*-intro.itely) @@ -14,14 +20,25 @@ GENERATED_ITELY_FILES = $(IN_ITELY_FILES:%-intro.itely=$(outdir)/%.itely) $(outdir)/%.itely: %-intro.itely %.snippet-list xargs $(PYTHON) $(buildscript-dir)/lys-to-tely.py -f printfilename,texidoc,verbatim --name=$@ --template=$< < $(filter %.snippet-list, $^) -$(outdir)/snippets.texi: snippets.tely $(GENERATED_ITELY_FILES) - $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $< +$(outdir)/lilypond-snippets.texi: $(GENERATED_ITELY_FILES) + +info: $(INFO_FILES) + +ifneq ($(out),www) +# cancel install-info target +# (there is no lilypond-snippets.info without images) +local-install-info: + true +endif -$(outdir)/snippets-big-page.html: $(outdir)/snippets.texi $(OUT_PNG_IMAGES) - $(MAKEINFO) -I$(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $< +# All web targets, except info image symlinks and info docs are +# installed in non-recursing target from TOP-SRC-DIR +local-install-WWW: local-install-info +local-uninstall-WWW: local-uninstall-info -$(outdir)/snippets/index.html: $(outdir)/snippets.texi $(OUT_PNG_IMAGES) $(OUT_EPS_IMAGES) - mkdir -p $(dir $@) - $(MAKEINFO) -I$(outdir) --output=$(dir $@) --css-include=$(top-src-dir)/Documentation/texinfo.css --html $< +local-clean: + rm -f $(INFO_IMAGES_DIR) -local-WWW: $(outdir)/snippets.pdf $(outdir)/snippets/index.html $(outdir)/snippets-big-page.html +local-WWW: info $(outdir)/lilypond-snippets.pdf \ + $(outdir)/lilypond-snippets/index.html \ + $(outdir)/lilypond-snippets-big-page.html diff --git a/input/lsr/snippets.tely b/input/lsr/lilypond-snippets.tely similarity index 86% rename from input/lsr/snippets.tely rename to input/lsr/lilypond-snippets.tely index 5059eb7014..85cde176e0 100644 --- a/input/lsr/snippets.tely +++ b/input/lsr/lilypond-snippets.tely @@ -1,5 +1,5 @@ \input texinfo @c -*- coding: utf-8; mode: texinfo; -*- -@setfilename snippets.info +@setfilename lilypond-snippets.info @settitle LilyPond snippets @documentencoding UTF-8 @documentlanguage en @@ -13,6 +13,11 @@ @end tex @end iftex +@dircategory GNU LilyPond --- the music typesetter +@direntry +* LilyPond Snippets: (lilypond-snippets) Short tricks, tips, and examples. +@end direntry + @finalout @titlepage @@ -33,8 +38,8 @@ LSR web site and database, and the University of Milano for hosting LSR. Please note that this document 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 may be for a newer -version (see below). +based on a stable LilyPond version, and this document is for version +@value{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, @@ -43,20 +48,6 @@ and not all LSR tags may appear in this document. In the HTML version of this document, you can click on the file name or figure for each example to see the corresponding input file. -@lilypond[ragged-right] -\score { - \context Lyrics { - \override Score.RehearsalMark #'self-alignment-X = #LEFT - \override Score.RehearsalMark #'font-size = #-1 - \mark #(ly:export (string-append - "This document is for LilyPond version " (lilypond-version) ".")) - s2 - } - \layout { - indent = 0.0\pt - } -} -@end lilypond @end titlepage @iftex @@ -74,8 +65,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 may be for a newer version (see -below). +LilyPond version, and this document is for version @value{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/scripts/lilypond-book.py b/scripts/lilypond-book.py index 96c5dcc9c5..824cbabef9 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -1245,19 +1245,12 @@ class Lilypond_snippet (Snippet): if PRINTFILENAME in self.option_dict: base = self.basename () filename = os.path.basename (self.substring ('filename')) - str = output[global_options.format][PRINTFILENAME] % vars () + str = output[format][PRINTFILENAME] % vars () return str def output_texinfo (self): - str = '' - if self.output_print_filename (TEXINFO): - str += ('@html\n' - + self.output_print_filename (HTML) - + '\n@end html\n') - str += ('@tex\n' - + self.output_print_filename (LATEX) - + '\n@end tex\n') + str = self.output_print_filename (TEXINFO) base = self.basename () if TEXIDOC in self.option_dict: texidoc = base + '.texidoc' diff --git a/stepmake/stepmake/texinfo-targets.make b/stepmake/stepmake/texinfo-targets.make index 875a5e929c..8f421dfedc 100644 --- a/stepmake/stepmake/texinfo-targets.make +++ b/stepmake/stepmake/texinfo-targets.make @@ -11,8 +11,6 @@ check-info: texinfo-all-menus-update ## info stuff local-install: install-info local-uninstall: uninstall-info -local-install-info: -local-uninstall-info: install-info: local-install-info uninstall-info: local-uninstall-info @@ -22,6 +20,73 @@ install-info: $(INFO_FILES) uninstall-info: $(INFO_INSTALL_COMMAND) local-uninstall +# There are two modes for info: with and without images. +ifeq ($(out),www) + +# This builds all .info targets with images, in out-www. +# Viewable with a recent Emacs, doing: C-u C-h i out-www/lilypond.info + +local-install-info: info + -$(INSTALL) -d $(DESTDIR)$(infodir) +ifneq ($(patsubst %/local,%,$(DESTDIR)$(prefix)),/usr) +## Can not have absolute symlinks because some binary packages build schemes +## install files in nonstandard root. Best we can do is to notify the +## builder or packager. + @echo + @echo "***************************************************************" + @echo "Please add or update the LilyPond direntries, do" + @echo + @echo " install-info --info-dir=$(infodir) $(outdir)/$(MAIN_INFO_DOC).info" + @echo + @echo "For images in the INFO docs to work, do: " + @echo + @echo " (cd $(infodir) && ln -sfT ../doc/lilypond/html/$(DEST_INFO_IMAGES_SUBDIR) $(INFO_IMAGES_DIR))" + @echo "or add something like that to the postinstall script." + @echo +else # installing directly into standard /usr/... + -$(INSTALL) -d $(DESTDIR)$(infodir) + $(foreach f,$(INFO_FILES),install-info --remove --info-dir=$(infodir) $(f) ; )true + install-info --info-dir=$(infodir) $(outdir)/$(MAIN_INFO_DOC).info + cd $(infodir) && ln -sfT $(webdir)/$(DEST_INFO_IMAGES_SUBDIR) $(INFO_IMAGES_DIR) +endif # installing directly into standard /usr/... + +local-uninstall-WWW: + rm -f $(infodir)/$(INFO_IMAGES_DIR) + +else # out!=www + +local-install-info: info + -$(INSTALL) -d $(DESTDIR)$(package_infodir) +ifneq ($(patsubst %/local,%,$(DESTDIR)$(prefix)),/usr) +## Can not have absolute symlinks because some binary packages build schemes +## install files in nonstandard root. Best we can do is to notify the +## builder or packager. + @echo + @echo "***************************************************************" + @echo "Please add or update the LilyPond direntries, do" + @echo + @echo " install-info --info-dir=$(infodir) out/$(MAIN_INFO_DOC).info" + @echo + @echo "For images in the INFO docs to work, do" + @echo + @echo " make out=www install-info " + @echo + @echo "and read the extra instructions." + @echo +else # installing directly into standard /usr/... + -$(INSTALL) -d $(DESTDIR)$(infodir) + $(foreach f,$(INFO_FILES),install-info --remove --info-dir=$(infodir) $(f) ; )true + install-info --info-dir=$(infodir) $(outdir)/$(MAIN_INFO_DOC).info + @echo + @echo "***************************************************************" + @echo "For images in the INFO docs to work, do" + @echo + @echo " make out=www install-info " + @echo +endif # installing into standard /usr/* root# installing into /usr/... + +endif # out!=www + TEXINFO_ALL_MENUS_UPDATE_EL ='\ (let ((error nil)\ -- 2.39.2