]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/lsr-work.itexi
CG changes - LSR section
[lilypond.git] / Documentation / contributor / lsr-work.itexi
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @node LSR work
3 @chapter LSR work
4
5 @menu
6 * Introduction to LSR::
7 * Adding and editing snippets::
8 * Approving snippets::
9 * LSR to Git::
10 * Fixing snippets in LilyPond sources::
11 * Renaming a snippet::
12 * Updating the LSR to a new version::
13 @end menu
14
15
16 @node Introduction to LSR
17 @section Introduction to LSR
18
19 The
20 @uref{http://lsr.dsi.unimi.it/, LilyPond Snippet Repository (LSR)}
21 is a collection of lilypond examples.  A subset of these examples
22 are automatically imported into the documentation, making it easy
23 for users to contribute to the docs without learning Git and
24 Texinfo.
25
26
27 @node Adding and editing snippets
28 @section Adding and editing snippets
29
30 @subheading General guidelines
31
32 When you create (or find!) a nice snippet, if it is supported by
33 the LilyPond version running on the LSR, please add it to the LSR.
34 Go to @uref{http://lsr.dsi.unimi.it/, LSR} and log in -- if you haven't
35 already, create an account.  Follow the instructions on the website.
36 These instructions also explain how to modify existing snippets.
37
38 If you think the snippet is particularly informative and you think it
39 should be included in the documentation, tag it with @qq{docs} and one
40 or more other categories, or ask on the development list for
41 somebody who has editing permissions to do it .
42
43 Please make sure that the lilypond code follows the guidelines in
44 @ref{LilyPond formatting}.
45
46 If a new snippet created for documentation purposes compiles with
47 LilyPond version currently on LSR, it should be added to LSR, and a
48 reference to the snippet should be added to the documentation.
49 Please ask a documentation editor to add a reference to it in an
50 appropriate place in the docs.  (Note -- it should appear in the
51 snippets document automatically, once it has been imported into
52 git and built.  See @ref{LSR to Git}.
53
54 If the new snippet uses new features that are not available in the
55 current LSR version, the snippet should be added to
56 @file{Documentation/snippets/new} and a reference should be added to the
57 manual.
58
59 Snippets created or updated in @file{Documentation/snippets/new} should
60 be copied to @file{Documentation/snippets} by invoking at top of the
61 source tree
62
63 @example
64 scripts/auxiliar/makelsr.py
65 @end example
66
67 @noindent
68 @command{makelsr} also copies translated texidoc fields and snippet titles into
69 snippets in @file{Documentation/snippets}.  Note: this, in turn, could
70 make the translated texidoc fields to appear as out of sync when you
71 run @code{make check-translation}, if the originals changed from the
72 last translation update, even if the translations are also updated;
73 see @ref{Documentation translation maintenance} for details about
74 updating the docs; in particular, see @ref{Updating translation
75 committishes} to learn how to mark these translated fields as fully
76 updated.
77
78 Be sure that @command{make doc} runs successfully before submitting a
79 patch, to prevent breaking compilation.
80
81 @subheading Formatting snippets in @file{Documentation/snippets/new}
82
83 When adding a file to this directory, please start the file with
84
85 @example
86 \version "2.x.y"
87 \header @{
88 % Use existing LSR tags other than 'docs'; see makelsr.py for
89 % the list of tags used to sort snippets.  E.g.:
90   lsrtags = "rhythms,expressive-marks"
91 % This texidoc string will be formatted by Texinfo
92   texidoc = "
93 This code demonstrates ...
94 "
95 % Please put doctitle last so that the '% begin verbatim'
96 % mark will be added correctly by makelsr.py.
97   doctitle = "Snippet title"
98 @}
99 @end example
100
101 @noindent
102 and name the file @file{snippet-title.ly}.
103
104 @noindent
105 Please ensure that the version number you use at the top of the
106 example is the minimum version that the file will compile with:
107 for example, if the LSR is currently at 2.14.2 and your example
108 requires 2.15.30, but the current development version of
109 @code{lilypond} is 2.17.5, put @code{\version "2.15.30"} in the
110 example.
111
112 @noindent
113 Please also pay particular attention to the lines beginning
114 @code{lsrtags = } and @code{doctitle =}.  The tags must match tags used
115 in the documentation, and the @code{doctitle} must match the
116 filename.
117
118 @node Approving snippets
119 @section Approving snippets
120
121 The main task of LSR editors is approving snippets.  To find a list of
122 unapproved snippets, log into @uref{http://lsr.dsi.unimi.it/, LSR} and
123 select @qq{No} from the dropdown menu to the right of the word
124 @qq{Approved} at the bottom of the interface, then click
125 @qq{Enable filter}.
126
127 Check each snippet:
128
129 @enumerate
130
131 @item
132 Does the snippet make sense and does what the author claims that
133 it does?  If you think the snippet is particularly helpful, add
134 the @qq{docs} tag and at least one other tag.
135
136 @item
137 If the snippet is tagged with @qq{docs}, check to see if it
138 matches our guidelines for @ref{LilyPond formatting}.
139
140 Also, snippets tagged with @qq{docs} should not be explaining
141 (replicating) existing material in the docs.  They should not
142 refer to the docs; the docs should refer to them.
143
144 @item
145 If the snippet uses scheme, check that everything looks good and
146 there are no security risks.
147
148 @warning{Somebody could sneak a @code{#'(system "rm -rf /")}
149 command into our source tree if you do not do this!  Take this
150 step @strong{VERY SERIOUSLY}.}
151
152 @item
153 If all is well, check the box labelled @qq{approved} and save the
154 snippet.
155
156 @end enumerate
157
158
159 @node LSR to Git
160 @section LSR to Git
161
162 @subheading Introduction
163 Snippets used in the documentation are in
164 @file{$LILYPOND_GIT/Documentation/snippets}.  This directory
165 contains a complete set of the snippets in the LSR which are
166 tagged with 'docs'.  The exact method for getting them there is
167 described below, but in essence they come from downloading a
168 tarball from the LSR and importing into the directory using the
169 @code{makelsr} script.
170
171 Any snippets which are too bleeding edge to run on the LSR (which
172 uses a stable development version) are put into
173 @file{$LILYPOND_GIT/Documentation/snippets/new}.  Once the LSR has
174 been upgraded so that these will run, then they are transferred to
175 the LSR and deleted from @file{/snippets/new}.
176
177 'Git' is the shorthand name for the Git repository that contains
178 all the development code.  For further information on setting this
179 up see, @ref{Working with source code}.  An alternative to setting
180 up a Git repository for people wanting to do LSR work is to get
181 the source code from
182 @uref{http://lilypond.org/website/development.html}.
183
184 @subheading Importing the LSR to Git
185
186 @enumerate
187
188 @item
189 Make sure that @command{convert-ly} script and the
190 @command{lilypond} binary are a
191 bleeding edge version -- the latest release or even better, a fresh
192 snapshot from Git master.
193
194 @item
195 Start by creating a list of updated snippets from your local
196 repository.  From the top source directory, run:
197
198 @example
199 scripts/auxiliar/makelsr.py
200 @end example
201
202 Commit the changes and make a patch.  Check the patch has nothing
203 other than minor changes - in particular changes to the commitish
204 for translations.  If all is good and you're confident in what
205 you've done, this can be pushed directly to staging.
206
207 @item
208 Next, download the updated snippets and run makelsr against them.
209 From the top source directory, run:
210
211 @smallexample
212 wget http://lsr.dsi.unimi.it/download/lsr-snippets-docs-@var{YYYY-MM-DD}.tar.gz
213 tar -xzf lsr-snippets-docs-@var{YYYY-MM-DD}.tar.gz
214 scripts/auxiliar/makelsr.py lsr-snippets-docs-@var{YYYY-MM-DD}
215 @end smallexample
216
217 @noindent
218 where @var{YYYY-MM-DD} is the current date, e.g. 2011-12-25.
219
220 @item
221 Follow the instructions printed on the console to manually check for
222 unsafe files.  These are:
223
224 @example
225 Unsafe files printed in lsr-unsafe.txt: CHECK MANUALLY!
226   git add Documentation/snippets/*.ly
227   xargs git diff HEAD < lsr-unsafe.txt
228 @end example
229
230 First, it's important to check for any added files and add them to
231 the files git is tracking.  Run @code{git status} and look
232 carefully to see if files have been added.  If so, add them with
233 @code{git add}.
234
235 As the console says, makelsr creates a list of possibly unsafe
236 files in @file{lsr-unsafe.txt} by running @code{lilypond} against each
237 snippet using the @code{-dsafe} switch.  This list can be quite
238 long.  However, by using the command @code{xargs git diff HEAD < lsr-unsafe.txt}
239 git will take that list and check whether any of the snippets are
240 different from the snippet already in master.  If any is different
241 it must be checked manually VERY CAREFULLY.
242
243 @warning{Somebody could sneak a @code{#'(system "rm -rf /")}
244 command into our source tree if you do not do this!  Take this
245 step @strong{VERY SERIOUSLY}.}
246
247 If there is any doubt about any of the files, you are strongly
248 advised to run a review on Rietveld.
249
250 @item
251 If a Review is not needed, commit the changes and push to staging.
252
253 @end enumerate
254
255 Note that whenever there is a snippet in
256 @file{Documentation/snippets/new} and another from the LSR with
257 the same file name, @command{makelsr.py} will overwrite the LSR
258 version with the one from @file{Documentation/snippets/new}.
259
260
261 @node Fixing snippets in LilyPond sources
262 @section Fixing snippets in LilyPond sources
263
264 If some snippet from @file{Documentation/snippets} causes the
265 documentation compilation to fail, the following steps should be
266 followed to fix it reliably.
267
268 @enumerate
269
270 @item
271 Look up the snippet filename @file{@var{foo}.ly} in the error output
272 or log, then fix the file @file{Documentation/snippets/@var{foo}.ly} to make the
273 documentation build successfully.
274
275 @item
276 Determine where it comes from by looking at its first line, e.g. run
277
278 @example
279 head -1 Documentation/snippets/@var{foo}.ly
280 @end example
281
282 @item
283 @strong{If the snippet comes from the LSR}, also apply the fix to the
284 snippet in the LSR and send a notification email to an LSR editor with CC to
285 the development list -- see @ref{Adding and editing snippets}.  The
286 failure may sometimes not be caused by the snippet in LSR but by the
287 syntax conversion made by @command{convert-ly}; in this case, try to fix
288 @command{convert-ly} or report the problem on the development list, then
289 run @command{makelsr.py} again, see @ref{LSR to Git}.  In some cases,
290 when some features has been introduced or vastly changed so it requires
291 (or takes significant advantage of) important changes in the snippet, it
292 is simpler and recommended to write a new version of the snippet in
293 @file{Documentation/snippets/new}, then run @command{makelsr.py}.
294
295 @item
296 @strong{If the snippet comes from}
297 @file{Documentation/snippets/new}, apply the same fix in
298 @file{Documentation/snippets/new/@var{foo}.ly} that you did in
299 @file{Documentation/snippets/@var{foo}.ly}.  If the build failure
300 was caused by a translation string, you may have to fix
301 @file{input/texidocs/@var{foo}.texidoc} instead.
302
303 @item
304 When you've done, commit your changes to Git and ensure they're
305 pushed to the correct branch.
306
307 @end enumerate
308
309
310 @node Renaming a snippet
311 @section Renaming a snippet
312
313 Due to the potential duality of snippets (i.e. they may exist both
314 in the LSR database, and in @code{Documentation/snippets/new/}),
315 this process is a bit more involved than we might like.
316
317 @enumerate
318 @item
319 Send an email LSR editor, requesting the renaming.
320
321 @item
322 The LSR editor does the renaming (or debates the topic with you),
323 then warns the LSR-to-git person (wanted: better title) about the
324 renaming.
325
326 @item
327 LSR-to-git person does his normal job, but then also renames any
328 copies of the snippets in @code{Documentation/snippets/new/}, and
329 any instances of the snippet name in the documentation.
330
331 @code{git grep} is highly recommended for this task.
332
333 @end enumerate
334
335
336 @node Updating the LSR to a new version
337 @section Updating the LSR to a new version
338
339 To update the LSR, perform the following steps:
340
341 @enumerate
342
343 @item
344 Start by emailing the LSR maintainer, Sebastiano, and liaising
345 with him to ensure that updating the snippets is synchronised with
346 updating the binary running the LSR.
347
348 @item
349 Download the latest snippet tarball from
350 @uref{http://lsr.dsi.unimi.it/download/} and extract it.
351 The relevant files can be found in the @file{all} subdirectory.
352 Make sure your shell is using an English language version, for
353 example @code{LANG=en_US}, then run @command{convert-ly} on all
354 the files.  Use the command-line option @code{--to=version} to
355 ensure the snippets are updated to the correct stable version.
356
357 @item
358 Make sure that you are using @command{convert-ly} from the latest
359 available release to gain best advantage from the latest
360 @code{converting-rules-updates}.
361
362 For example:
363
364 @itemize
365
366 @item
367 LSR-version: 2.12.2
368 @item
369 intended LSR-update to 2.14.2
370 @item
371 latest release 2.15.30
372
373 @end itemize
374
375 Use convert-ly from 2.15.30 and the following terminal command
376 for all files:
377
378 @example
379 convert-ly -e -t2.14.2 *.ly
380 @end example
381
382 @item
383 There might be no conversion rule for some old commands. To make
384 an initial check for possible problems you can run the following
385 script on a copy of the @file{all} subdirectory:
386
387 @example
388 #!/bin/bash
389
390 for LILYFILE in *.ly
391 do
392   STEM=$(basename "$LILYFILE" .ly)
393   echo "running $LILYFILE..."
394   convert-ly -e -t<version> "$LILYFILE" >& "$STEM".txt
395 done
396
397 grep refer *.txt
398 grep smart *.txt
399 TODO: better script
400 @end example
401
402 @item
403 Copy relevant snippets (i.e. snippets whose version is equal to
404 or less than the new version of LilyPond running on the LSR) from
405 @file{Documentation/snippets/new/} into the set of files to be
406 used to make the tarball.  Make sure
407 you only choose snippets which are already present in the LSR,
408 since the LSR software isn't able to create new snippets this way.
409 If you don't have a Git repository for LilyPond, you'll find these
410 snippets in the source-tarball on
411 @uref{http://lilypond.org/website/development.html}.
412 Don't rename any files at this stage.
413
414 @item
415 Verify that all files compile with the new version of LilyPond,
416 ideally without any warnings or errors.  To ease the process,
417 you may use the shell script that appears after this list.
418
419 Due to the workload involved, we @emph{do not} require that you
420 verify that all snippets produce the expected output.  If you
421 happen to notice any such snippets and can fix them, great; but as
422 long as all snippets compile, don't delay this step due to some
423 weird output.  If a snippet is not compiling, update it manually.
424 If it's not possible, delete it for now.
425
426 @item
427 Remove all headers and version-statements from the files.  Phil
428 Holmes has a @code{python} script that will do this and which
429 needs testing.  Please ask him for a copy if you wish to do this.
430
431 @item
432 Create a tarball and send it back to Sebastiano. Don't forget to
433 tell him about any deletions.
434
435 @item
436 Use the LSR web interface to change any descriptions you want to.
437 Changing the titles of snippets is a bit fraught, since this also
438 changes the filenames.  Only do this as a last resort.
439
440 @item
441 Use the LSR web interface to add the other snippets from
442 @file{Documentation/snippets/new/} which compile with the new
443 LilyPond version of the LSR.  Ensure that they are correctly
444 tagged, including the tag @code{docs} and that they are approved.
445
446 @item
447 When LSR has been updated, wait a day for the tarball to update,
448 then download another snippet tarball. Verify that
449 the relevant snippets from @file{Documentation/snippets/new/} are
450 now included, then delete those snippets from
451 @file{Documentation/snippets/new/}.
452
453 @item
454 Commit all the changes.  @emph{Don't forget to add new files to
455 the git repository with @code{git add}}.  Run @code{make},
456 @code{make doc} and
457 @code{make test} to ensure the changes don't break the build. Any
458 snippets that have had their file name changed or have been
459 deleted could break the build, and these will need correcting
460 step by step.
461
462 @end enumerate
463
464
465 Below is a shell script to run all @file{.ly} files in a directory
466 and redirect terminal output to text files, which are then
467 searched for the word "failed" to see which snippets do not compile.
468
469 @smallexample
470 #!/bin/bash
471
472 for LILYFILE in *.ly
473 do
474   STEM=$(basename "$LILYFILE" .ly)
475   echo "running $LILYFILE..."
476   lilypond --format=png -ddelete-intermediate-files "$LILYFILE" >& "$STEM".txt
477 done
478
479 grep failed *.txt
480 TODO: better script
481 @end smallexample
482
483 Sometimes @code{grep failed *.txt} will not discover all
484 problematic files. In addition you may want to use:
485
486 @example
487 grep ERROR *.txt
488 grep error *.txt
489 grep warning *.txt
490 @end example