import getopt
program_name = 'lys-to-tely'
+
include_snippets = '@lysnippets'
+fragment_options = 'printfilename,texidoc'
def help ():
sys.stdout.write (r"""Usage: %(program_name)s [OPTIONS]... LY-FILE...
Construct tely doc from LY-FILEs.
Options:
- -h, --help print this help
- -o, --output=NAME write tely doc to NAME
- -t, --title=TITLE set tely doc title TITLE
- --template=TEMPLATE use TEMPLATE as Texinfo template file,
+ -h, --help print this help
+ -f, --fragment-options=OPTIONS use OPTIONS as lilypond-book fragment
+ options
+ -o, --output=NAME write tely doc to NAME
+ -t, --title=TITLE set tely doc title TITLE
+ --template=TEMPLATE use TEMPLATE as Texinfo template file,
instead of standard template; TEMPLATE should contain a command
- '%(include_snippets)s' to tell where to insert LY-FILEs. When this option
- is used, NAME and TITLE are ignored
+ '%(include_snippets)s' to tell where to insert LY-FILEs. When this
+ option is used, NAME and TITLE are ignored.
""" % vars ())
sys.exit (0)
-(options, files) = getopt.getopt (sys.argv[1:], 'hn:t:',
- ['help', 'name=', 'title=', 'template='])
+(options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:',
+ ['fragment-options=', 'help', 'name=', 'title=', 'template='])
name = "ly-doc"
title = "Ly Doc"
name = a
elif o == '-t' or o == '--title':
title = a
+ elif o == '-f' or o == '--fragment-options':
+ fragment_options = a
elif o == '--template':
template = open (a, 'r').read ()
else:
- raise 'unknown opt ', o
+ raise Exception ('unknown option: ' + o)
def name2line (n):
# UGR
@end html
@end ifhtml
-@lilypondfile[printfilename,texidoc]{%s}""" % (n, n)
+@lilypondfile[%s]{%s}""" % (n, fragment_options, n)
return s
if files:
import sys
import os
import glob
+import re
USAGE = ''' Usage: makelsr.py LSR_SNIPPETS_DIR
This script must be run from top of the source tree;
TAGS.extend (['vocal-music', 'chords', 'piano-music',
'percussion', 'guitar', 'strings', 'bagpipes', 'ancient-notation'])
-TAGS.append ('other')
+# other
+TAGS.extend (['contexts-and-engravers', 'tweaks-and-overrides', 'paper-and-layout', 'breaks',
+'spacing', 'midi', 'titles', 'other'])
def exit_with_usage (n=0):
sys.stderr.write (USAGE)
unsafe = []
unconverted = []
+# mark the section that will be printed verbatim by lilypond-book
+end_header_re = re.compile ('(\\header {.*?}\n)\n', re.M | re.S)
+
+def mark_verbatim_section (ly_code):
+ return end_header_re.sub ('\\1% begin verbatim\n', ly_code)
+
def copy_ly (srcdir, name, tags):
global unsafe
global unconverted
dest = os.path.join (DEST, name)
f = open (dest, 'w')
f.write (LY_HEADER % ', '.join (tags))
- f.write (open (os.path.join (srcdir, name)).read ())
+ f.write (mark_verbatim_section (open (os.path.join (srcdir, name)).read ()))
f.close ()
e = os.system('convert-ly -e ' + dest)
if e:
GENERATED_ITELY_FILES = $(IN_ITELY_FILES:%-intro.itely=$(outdir)/%.itely)
$(outdir)/%.itely: %-intro.itely %.snippet-list
- xargs $(PYTHON) $(buildscript-dir)/lys-to-tely.py --name=$@ --template=$< < $*.snippet-list
+ xargs $(PYTHON) $(buildscript-dir)/lys-to-tely.py -f printfilename,texidoc,verbatim --name=$@ --template=$< < $*.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) $<
@node Ancient notation
-@unnumbered Ancient notation
+@unnumberedsec Ancient notation
@lysnippets
@node Bagpipes
-@unnumbered Bagpipes
+@unnumberedsec Bagpipes
@lysnippets
@node Chords
-@unnumbered Chords
+@unnumberedsec Chords
@lysnippets
--- /dev/null
+@node Contexts and engravers
+@unnumberedsec Contexts and engravers
+
+@lysnippets
+
@node Editorial and educational use
-@unnumbered Editorial and educational use
+@unnumberedsec Editorial and educational use
@lysnippets
@node Expressive marks
-@unnumbered Expressive marks
+@unnumberedsec Expressive marks
@lysnippets
@node Guitar
-@unnumbered Guitar
+@unnumberedsec Guitar
@lysnippets
--- /dev/null
+@node MIDI
+@unnumberedsec MIDI
+
+@lysnippets
+
@node Other
-@unnumbered Other
+@unnumberedsec Other
@lysnippets
--- /dev/null
+@node Paper and layout
+@unnumberedsec Paper and layout
+
+@lysnippets
+
@node Percussion
-@unnumbered Percussion
+@unnumberedsec Percussion
@lysnippets
@node Piano
-@unnumbered Piano
+@unnumberedsec Piano
@lysnippets
@node Pitches
-@unnumbered Pitches
+@unnumberedsec Pitches
@lysnippets
@node Repeats
-@unnumbered Repeats
+@unnumberedsec Repeats
@lysnippets
@node Rhythms
-@unnumbered Rhythms
+@unnumberedsec Rhythms
@lysnippets
@node Simultaneous notes
-@unnumbered Simultaneous notes
+@unnumberedsec Simultaneous notes
@lysnippets
@iftex
@afourpaper
+@c don't replace quotes with directed quotes
+@tex
+\gdef\SETtxicodequoteundirected{Foo}
+\gdef\SETtxicodequotebacktick{Bla}
+@end tex
@end iftex
@finalout
@end lilypond
@c maybe generate/update @menu and @includes automatically? --jm
+@ifnottex
@menu
Musical notation
* Pitches::
* Ancient notation::
Other collections
+* Contexts and engravers::
+* Tweaks and overrides::
+* Paper and layout::
+* Titles::
+* Spacing::
+* MIDI::
* Other::
@end menu
+@end ifnottex
+@iftex
@contents
+@end iftex
@include pitches.itely
@include rhythms.itely
@c @include bagpipes.itely
@include ancient-notation.itely
+@include contexts-and-engravers.itely
+@include tweaks-and-overrides.itely
+@include paper-and-layout.itely
+@include titles.itely
+@include spacing.itely
+@include midi.itely
@include other.itely
@bye
--- /dev/null
+@node Spacing
+@unnumberedsec Spacing
+
+@lysnippets
+
@node Staff notation
-@unnumbered Staff notation
+@unnumberedsec Staff notation
@lysnippets
@node Strings
-@unnumbered Strings
+@unnumberedsec Strings
@lysnippets
@node Text
-@unnumbered Text
+@unnumberedsec Text
@lysnippets
--- /dev/null
+@node Titles
+@unnumberedsec Titles
+
+@lysnippets
+
--- /dev/null
+@node Tweaks and overrides
+@unnumberedsec Tweaks and overrides
+
+@lysnippets
+
@node Vocal music
-@unnumbered Vocal music
+@unnumberedsec Vocal music
@lysnippets