From b718ddc0c9e7f4bbdec5ee7b57ffb84ac82ad59e Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Thu, 4 Oct 2007 10:54:52 +0200 Subject: [PATCH] Allow header/footer snippets in test cases, expand lilypond-book to insert versionnumber -) Add --introduction=.. and --footer=.. options to lys-to-tely.py so that we can insert custom text form a texi file at the beginning and end of a regression test page. So far, one had to add a .ly file with a proper name (so that it gets sorted to the begin/end), which resulted in an ugly empty image and a link to a dummy .ly file at the top. The header for the lys-to-tely script must not be called *.texi, because make WWW tries to run makeinfo on all *.texi files. -) Change the buildsystem to use these additional parameters. The make variables HEADER_FILE and FOOTER_FILE are used for this. -) Change the regression tests to make use of the texi file rather than the AAA-intro-regression.ly file -) Since that header contained the lilypond version number, I also expanded lilypond-book to replace @lilypondversion (or the \lilypondversion and counterparts for latex and html) by the version. The build must then use the lilypond-book script from scripts/out/ rather than scripts/lilypond-book.py (which does not have the @VERSION_NUMBER@ replaced by the version by the build system). --- buildscripts/lys-to-tely.py | 27 +++++++++++++++---- ...egression.ly => AAA-intro-regression-texi} | 22 ++------------- input/regression/GNUmakefile | 2 ++ input/regression/musicxml/GNUmakefile | 5 ++-- input/regression/musicxml/intro-texi | 18 +++++++++++++ make/lilypond-vars.make | 2 +- make/lysdoc-rules.make | 2 +- scripts/lilypond-book.py | 19 ++++++++++++- 8 files changed, 67 insertions(+), 30 deletions(-) rename input/regression/{AAA-intro-regression.ly => AAA-intro-regression-texi} (50%) create mode 100644 input/regression/musicxml/intro-texi diff --git a/buildscripts/lys-to-tely.py b/buildscripts/lys-to-tely.py index 9150acfe39..c0a66457a9 100644 --- a/buildscripts/lys-to-tely.py +++ b/buildscripts/lys-to-tely.py @@ -6,7 +6,6 @@ TODO: * Add @nodes, plit at sections? * Less kludged first introduction file - * include *.texi files for text at start of section? ''' @@ -24,17 +23,21 @@ Construct tely doc from LY-FILEs. Options: -h, --help print this help - -o, --output=NAME write tely doc to NAME + -n, --name=NAME write tely doc to NAME -t, --title=TITLE set tely doc title TITLE + -i, --introduction=FILE use FILE as intruduction at the top + -f, --footer=FILE use FILE as footer on the bottom of the page """) sys.exit (0) -(options, files) = getopt.getopt(sys.argv[1:], 'hn:t:', [ - 'help', 'name=', 'title=']) +(options, files) = getopt.getopt(sys.argv[1:], 'hn:t:i:f:', [ + 'help', 'name=', 'title=', 'introduction=', 'footer=']) name="ly-doc" title="Ly Doc" +header = None +footer = None for opt in options: o = opt[0] a = opt[1] @@ -44,6 +47,10 @@ for opt in options: name = a elif o == '-t' or o == '--title': title = a + elif o == '-i' or o == '--introduction': + header = a + elif o == '-f' or o == '--footer': + footer = a else: raise 'unknown opt ', o @@ -79,6 +86,11 @@ if files: @node Top, , , (dir) ''' % (name, title, title) + if header: + header_text = open (header).read () + s += header_text + + def name2line (n): # UGR s = r""" @@ -93,7 +105,12 @@ if files: return s files.sort () s = s + string.join (map (lambda x: name2line (x), files), "\n") - s = s + '\n@bye\n' + s += '\n' + if footer: + footer_text = open (footer).read () + s += footer_text + s += '\n' + s = s + '@bye\n' f = "%s/%s.tely" % (dir, name) sys.stderr.write ("%s: writing %s..." % (program_name, f)) h = open (f, "w") diff --git a/input/regression/AAA-intro-regression.ly b/input/regression/AAA-intro-regression-texi similarity index 50% rename from input/regression/AAA-intro-regression.ly rename to input/regression/AAA-intro-regression-texi index d19595bf02..b270e6bccf 100644 --- a/input/regression/AAA-intro-regression.ly +++ b/input/regression/AAA-intro-regression-texi @@ -1,16 +1,6 @@ -\version "2.10.0" -%% +.ly: Be the first .ly file for lys-to-tely.py. -%% Better to make lys-to-tely.py include "introduction.texi" or -%% other .texi documents too? +@unnumbered Introduction - -\header{ -texidoc = - -#(string-append "@unnumbered Introduction - -This document presents proofs for -LilyPond " (lilypond-version) ". When the +This document presents proofs for LilyPond @lilypondversion. When the text corresponds with the shown notation, we consider LilyPond Officially BugFree (tm). This document is intended for finding bugs and for documenting bugfixes. @@ -20,12 +10,4 @@ or figure for each example to see the corresponding input file. TODO: order of tests (file names!), test only one feature per test. Smaller and neater tests. -") - -} - -% -% make sure the .png is generated. -% -\lyrics { "(left blank intentionally)" } diff --git a/input/regression/GNUmakefile b/input/regression/GNUmakefile index 753d483bd9..a57130bf63 100644 --- a/input/regression/GNUmakefile +++ b/input/regression/GNUmakefile @@ -5,5 +5,7 @@ LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc include $(depth)/make/stepmake.make TITLE=LilyPond Regression Tests +HEADER_FILE=AAA-intro-regression-texi +FOOTER_FILE= SUBDIRS=musicxml diff --git a/input/regression/musicxml/GNUmakefile b/input/regression/musicxml/GNUmakefile index ec647d8507..a6809e8b33 100644 --- a/input/regression/musicxml/GNUmakefile +++ b/input/regression/musicxml/GNUmakefile @@ -4,5 +4,6 @@ STEPMAKE_TEMPLATES=documentation texinfo tex LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc musicxml include $(depth)/make/stepmake.make -TITLE=Lilypon musicxml2ly Regression Tests - +TITLE=Lilypond musicxml2ly Regression Tests +HEADER_FILE=intro-texi +FOOTER_FILE= diff --git a/input/regression/musicxml/intro-texi b/input/regression/musicxml/intro-texi new file mode 100644 index 0000000000..ffbf320639 --- /dev/null +++ b/input/regression/musicxml/intro-texi @@ -0,0 +1,18 @@ +@unnumbered MusicXML regression and coverage test + +This document presents proofs for the musicxml2ly script provided with +LilyPond @lilypondversion. The files don't have a description yet, so +there is no official indication when the output is wrong. +These snippets are provided as unit test files in MusicXML, converted to +a .ly file by musicxml2ly and then processed by lilypond as usual. + +If something does not seem wright in the output, it might either be that this +feature has not been implemented, has been wrongly implemented, or a regression +has crept in recently... +This document is intended for finding bugs and for documenting bugfixes. + +In the web version of this document, you can click on the file name +or figure for each example to see the corresponding .ly intermediary file. + +TODO: Find a way to add a description to the .ly files for texinfo. + diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index cf9093523b..fe8820bd0b 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -22,7 +22,7 @@ the-script-dir=$(wildcard $(script-dir)) ABC2LY = $(script-dir)/abc2ly.py MUSICXML2LY = $(script-dir)/musicxml2ly.py CONVERT_LY = $(script-dir)/convert-ly.py -LILYPOND_BOOK = $(script-dir)/lilypond-book.py +LILYPOND_BOOK = $(script-dir)/out/lilypond-book ## ugh : fix me, input/new/pitch LILYPOND_BOOK_INCLUDES = -I $(src-dir)/ -I $(outdir) -I $(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/manual/ -I $(input-dir)/tutorial/ -I $(top-build-dir)/mf/$(outconfbase)/ -I $(top-build-dir)/mf/out/ -I $(input-dir)/new/pitch diff --git a/make/lysdoc-rules.make b/make/lysdoc-rules.make index 21c675e848..331231e8e6 100644 --- a/make/lysdoc-rules.make +++ b/make/lysdoc-rules.make @@ -1,4 +1,4 @@ $(outdir)/collated-files.tely: $(LY_FILES) $(OUT_LY_FILES) - $(PYTHON) $(buildscript-dir)/lys-to-tely.py --name=$(outdir)/collated-files --title="$(TITLE)" $^ + $(PYTHON) $(buildscript-dir)/lys-to-tely.py --name=$(outdir)/collated-files --introduction="$(HEADER_FILE)" --footer="$(FOOTER_FILE)" --title="$(TITLE)" $^ diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 5b9c0d738f..4599001241 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -248,6 +248,9 @@ snippet_res = { (?P <(?P(inline)?)mediaobject>\s*\s*.*?\.ly)"\s*(role="(?P.*?)")?\s*(/>|>\s*)\s*\s*)''', + 'lilypond_version': + no_match, + 'multiline_comment': r'''(?smx) (?P @@ -263,7 +266,6 @@ snippet_res = { 'verbatim': no_match, - }, ## HTML: { @@ -296,6 +298,9 @@ snippet_res = { \s*(?P.*?)\s* )''', + 'lilypond_version': + r'''(?mx)(?P)''', + 'multiline_comment': r'''(?smx) (?P @@ -362,6 +367,9 @@ snippet_res = { (?P\S+?) })''', + 'lilypond_version': + r'''(?P\\lilypond_version)''', + 'multiline_comment': no_match, @@ -430,6 +438,9 @@ snippet_res = { (?P\S+) })''', + 'lilypond_version': + r'''(?mx)(?P@lilypondversion)''', + 'multiline_comment': r'''(?smx) ^(?P @@ -1275,9 +1286,14 @@ class Lilypond_file_snippet (Lilypond_snippet): return ('\\sourcefilename \"%s\"\n\\sourcefileline 0\n%s' % (name, contents)) +class Version_snippet (Snippet): + def replacement_text (self): + return (program_version) + snippet_type_to_class = { 'lilypond_file': Lilypond_file_snippet, 'lilypond_block': Lilypond_snippet, + 'lilypond_version': Version_snippet, 'lilypond': Lilypond_snippet, 'include': Include_snippet, } @@ -1688,6 +1704,7 @@ def do_file (input_filename): # 'verb', 'singleline_comment', 'lilypond_file', + 'lilypond_version', 'include', 'lilypond', ) -- 2.39.5