lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code examples in docs


From: Urs Liska
Subject: Re: Code examples in docs
Date: Sat, 9 Apr 2016 14:18:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0



-------- Weitergeleitete Nachricht --------
Betreff:        Re: Code examples in docs
Datum:  Sat, 9 Apr 2016 12:56:12 +0100
Von:    James <address@hidden>
An:     Urs Liska <address@hidden>



Hello Urs

On 09/04/16 12:27, Urs Liska wrote:
>
> Am 9. April 2016 12:56:42 MESZ, schrieb James <address@hidden>:
>> Urs,
>>
>> $LILYPOND_GIT/Documentation/lilypond-texi2html.init
>>
>> --snip--
>>
>> # Examples should be formatted similar to quotes:
>> $Texi2HTML::Config::complex_format_map->{'example'} = {
>>    'begin' => q{"<blockquote>"},
>>    'end' => q{"</blockquote>\n"},
>>    'style' => 'code',
>>   };
>>
>> --snip--
>>
>> ?
> No help, but thanks anyway.
> That's the snippet David already pointed at. It's obviously an indicator how 
> "@example" sections are to be rendered.
>
> Urs

But @lilypond and @end lilypond sections - which I assume you are 
wanting - are not 'blockquotes' are they?

They are!

> Or did I completely misunderstand what it is you want?

What I'm looking for is the following:

Take lines 222ff. of Documentation/notation/ancient.itely (the alphabetically 
first example):

@lilypond[quote,ragged-right,verbatim]
\relative {
  \[ g' c, a' f d' \]
  a g f
  \[ e f a g \]
}
@end lilypond

This is rendered in 
http://lilypond.org/doc/v2.19/Documentation/notation/ancient-notation_002d_002dcommon-features#ligatures
as

<blockquote><pre class="verbatim">\relative {
  \[ g' c, a' f d' \]
  a g f
  \[ e f a g \]
}
</pre><p>
 <a href="../c7/lily-6852500f.ly">
  <img src="../c7/lily-6852500f.png" alt="[image of music]" align="middle" 
border="0">
 </a>
</p>
</blockquote>

What I want is to find the code that creates this HTML, and particularly the 
<pre> element with the displayed code. 
I hope this is in Python because then I would want to make use of Frescobaldi's 
independent python-ly library
to finally produce code examples with syntax highlighting.

The BookHTMLOutputFormat.snippet_output method in python/book_html.py seems to 
do exactly this (with the only
(and maybe telling?) difference that this code doesn't seem to insert the 
'class="verbatim"' attribute).
But my earlier research indicates that this code is not used to render the 
LilyPond examples in the docs but
exclusively in the lilypond-book regression tests.

Does this make it clearer? Do you have any idea?

Urs

> James

>
>> Line #1040
>>
>> James
>>
>> On 07/04/16 23:54, Urs Liska wrote:
>>> Am 07.04.2016 um 11:11 schrieb Carl Sorensen:
>>>> On 4/7/16 12:11 AM,
>> "address@hidden on behalf of Urs
>> Liska" <address@hidden on behalf of
>>>> address@hidden> wrote:
>>>>
>>>>> However, when *deleting* the .py and .pyc files an error was
>> triggered,
>>>>> when lilypond-book tries to import book_html.
>>>>>
>>>>> Looking further into it I realized:
>>>>> - book_base keeps an array with "formatters"
>>>>> - upon importing any specific book_X it registers an instance of
>> the
>>>>> formatter class in book_base
>>>>> - So if book_html is empty no HTML formatter is registered with
>>>>> lilypond-book
>>>>>
>>>>> This is why there is no error with the empty file.
>>>>> However, this isn't an answer to my question yet. If the HTML
>> formatter
>>>>> is *not* used to produce the HTML included in the doc pages, what
>> else?
>>>>> Any further ideas?
>>>> What about if you delete python/out and redo make doc?
>>>>
>>>> Just wondering if there's something wrong with the build script that
>>>> python/out isn't properly recreated when python/*.py changes.  In my
>>>> setup, python/*.py is not executable, but python/out/*.py is.  So
>> make is
>>>> apparently copying the .py files, setting them executable, and
>> creating
>>>> the .pyc files.
>>> Hm, I've did a rebuild from scratch and immediately emptied the two
>>> book_html.py files, and *now* I got an error upon trying to create
>> the
>>> HTML files. So while I think it wasn't related to the scripts itself
>> it
>>> had to do with the state of my build directory.
>>>
>>>> Again, untested.  But I have done a grep for blockquote and it only
>> shows
>>>> up in book_html.py as far as I can see.  So I think it must be
>>>> book_html.py.
>>> I finally found out where the code in book_html.py actually leads to.
>>> With some brute force I  took care of replacing the snippet and image
>>> with a paragraph that I could then grep in the rendered docs. And it
>>> ended up exclusively in the lilypond-book regtests.
>>>
>>> So obviously the book_XXX.py files are really for lilypond-book and
>>> don't have anything to do with the building of LilyPond docs.
>>>
>>> Which brings us back to the original issue: Where is the code that
>>> generates the blockquotes with the LilyPond code snippets and images?
>>>
>>> Probably David's pointer to texi2html is plausible, but I must say
>>> reading through lilypond-texi2html.init doesn't really help. The
>>> references to <blockquote> that David found obviously don't point to
>>> LilyPond examples but rather to @example. And the rest of that file
>> is
>>> definitely not related to LilyPond code examples.
>>>
>>> So it is really strange, I'm completely at a loss to find out where
>> to
>>> start looking further ...
>>>
>>> Urs
>>>
>>>> Thanks,
>>>>
>>>> Carl
>>>>
>>> _______________________________________________
>>> lilypond-devel mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/lilypond-devel
>>>
>>>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]