program_version = '@TOPLEVEL_VERSION@'
program_name = os.path.basename (sys.argv[0])
+# Check if program_version contains @ characters. This will be the case if
+# the .py file is called directly while building the lilypond documentation.
+# If so, try to check for the env var LILYPOND_VERSION, which is set by our
+# makefiles and use its value.
+at_re = re.compile (r'@')
+if at_re.match (program_version):
+ if os.environ.has_key('LILYPOND_VERSION'):
+ program_version = os.environ['LILYPOND_VERSION']
+ else:
+ program_version = "unknown"
+
original_dir = os.getcwd ()
backend = 'ps'
%s
%s
-''' % ( _ ('Copyright (c) %s by') % '2001--2007',
+''' % ( _ ('Copyright (c) %s by') % '2001--2008',
' '.join (authors),
_ ("Distributed under terms of the GNU General Public License."),
_ ("It comes with NO WARRANTY.")))
action='store_true')
p.add_option_group ('',
description=(
- _ ("Report bugs via")
- + ' http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs\n'))
+ _ ("Report bugs via %s")
+ % ' http://post.gmane.org/post.php'
+ '?group=gmane.comp.gnu.lilypond.bugs') + '\n')
return p
lilypond_binary = os.path.join ('@bindir@', 'lilypond')
LINE_WIDTH = 'line-width'
LILYQUOTE = 'lilyquote'
NOFRAGMENT = 'nofragment'
+NOGETTEXT = 'nogettext'
NOINDENT = 'noindent'
NOQUOTE = 'noquote'
NORAGGED_RIGHT = 'noragged-right'
NOTIME = 'notime'
OUTPUT = 'output'
OUTPUTIMAGE = 'outputimage'
-PACKED = 'packed'
PAPER = 'paper'
PREAMBLE = 'preamble'
PRINTFILENAME = 'printfilename'
TEXIDOC = 'texidoc'
TEXINFO = 'texinfo'
VERBATIM = 'verbatim'
+VERSION = 'lilypondversion'
FONTLOAD = 'fontload'
FILENAME = 'filename'
ALT = 'alt'
'verbatim':
no_match,
-
+
+ 'lilypondversion':
+ no_match,
},
##
HTML: {
(?s)
(?P<match>
(?P<code><pre>\s.*?</pre>\s))''',
+
+ 'lilypondversion':
+ r'''(?mx)
+ (?P<match>
+ <lilypondversion\s*/>)''',
},
##
\\begin\s*{verbatim}
.*?
\\end\s*{verbatim}))''',
+
+ 'lilypondversion':
+ r'''(?smx)
+ (?P<match>
+ \\lilypondversion)[^a-zA-Z]''',
+
},
##
@example
\s.*?
@end\s+example\s))''',
+
+ 'lilypondversion':
+ r'''(?mx)
+ [^@](?P<match>
+ @lilypondversion)[^a-zA-Z]''',
+
},
}
EXAMPLEINDENT,
FRAGMENT,
NOFRAGMENT,
+ NOGETTEXT,
NOINDENT,
PRINTFILENAME,
DOCTITLE,
RAGGED_RIGHT: r'''ragged-right = ##t''',
NORAGGED_RIGHT: r'''ragged-right = ##f''',
-
- PACKED: r'''packed = ##t''',
},
##
<imagedata fileref="%(base)s.png" format="PNG"/></imageobject>''',
VERBATIM: r'''<programlisting>%(verb)s</programlisting>''',
+
+ VERSION: program_version,
PRINTFILENAME: '<textobject><simpara><ulink url="%(base)s.ly"><filename>%(filename)s</filename></ulink></simpara></textobject>'
},
VERBATIM: r'''<pre>
%(verb)s</pre>''',
+
+ VERSION: program_version,
},
##
VERBATIM: r'''\noindent
\begin{verbatim}%(verb)s\end{verbatim}''',
+ VERSION: program_version,
+
FILTER: r'''\begin{lilypond}[%(options)s]
%(code)s
\end{lilypond}''',
%(verb)s@end verbatim
''',
+ VERSION: program_version,
+
ADDVERSION: r'''@example
\version @w{"@version{}"}
@end example
ly_var_def_re = re.compile (r'^([a-zA-Z]+)[\t ]*=', re.M)
ly_comment_re = re.compile (r'(%+[\t ]*)(.*)$', re.M)
+ly_context_id_re = re.compile ('\\\\(?:new|context)\\s+(?:[a-zA-Z]*?(?:Staff\
+(?:Group)?|Voice|FiguredBass|FretBoards|Names|Devnull))\\s+=\\s+"?([a-zA-Z]+)"?\\s+')
def ly_comment_gettext (t, m):
return m.group (1) + t (m.group (2))
s = re.sub (r"(?m)(^|[' \\#])%s([^a-zA-Z])" % v,
"\\1" + t (v) + "\\2",
s)
+ for id in ly_context_id_re.findall (s):
+ s = re.sub (r'(\s+|")%s(\s+|")' % id,
+ "\\1" + t (id) + "\\2",
+ s)
return s
texinfo_lang_re = re.compile ('(?m)^@documentlanguage (.*?)( |$)')
self.do_options (os, self.type)
def verb_ly (self):
- return verb_ly_gettext (self.substring ('code'))
+ if NOGETTEXT in self.option_dict:
+ return self.substring ('code')
+ else:
+ return verb_ly_gettext (self.substring ('code'))
def ly (self):
contents = self.substring ('code')
file (path + '.txt', 'w').write ('image of music')
def relevant_contents (self, ly):
- return re.sub (r'\\(version|sourcefileline|sourcefilename)[^\n]*\n', '', ly)
+ return re.sub (r'\\(version|sourcefileline|sourcefilename)[^\n]*\n|' +
+ NOGETTEXT + '[,\]]', '', ly)
def link_all_output_files (self, output_dir, output_dir_files, destination):
existing, missing = self.all_output_files (output_dir, output_dir_files)
% (name, self.contents))
+class LilyPondVersionString (Snippet):
+ """A string that does not require extra memory."""
+ def __init__ (self, type, match, format, line_number):
+ Snippet.__init__ (self, type, match, format, line_number)
+
+ def replacement_text (self):
+ return output[self.format][self.type]
+
+
snippet_type_to_class = {
'lilypond_file': LilypondFileSnippet,
'lilypond_block': LilypondSnippet,
'lilypond': LilypondSnippet,
'include': IncludeSnippet,
+ 'lilypondversion': LilyPondVersionString,
}
def find_linestarts (s):
'lilypond_file',
'include',
'lilypond',
+ 'lilypondversion',
)
progress (_ ("Dissecting..."))
chunks = find_toplevel_snippets (source, global_options.format, snippet_types)