OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] Tools for generating Docbook programlistingfragments?

On Sat, 25 Aug 2007, Tommy Nordgren wrote:

| Do anyone know of a library for generating DocBook
| programlisting fragments from source code listings marked up
| with special comments.  The purpose is to generate the Docbook
| source and program language source, from a common
| specification.

If single-sourcing is your goal, why not make the DocBook
document your single source?  Then you need only strip out the
executable parts with a simple filter.  My colleague Dr. Allan
Stavely calls this 'lightweight literate programming'.  See my
page for the tools and a few dozen examples ranging up to
4000+-line sources:


I don't know if this fits your application, but I thought this
would be a good opportunity for me to promote one of my pet
techniques. :)

| I've tested filtering a xml file containing a programlisting
| DocBook element through a custom stylesheet, but so far I've
| been unable to avoid getting extra whitespace, when doing it
| this way.

I code mainly in Python, which is rather sensitive to whitespace.
Here's how I format code fragments:

      This next section...blah blah blah
    <programlisting role='outFile:myscript.py'
>Line 1
Line 2
Line 3
</programlisting role='outFile:myscript.py'>
      Etc. ....
Line breaks are perfectly legal within XML tags just before
the closing '>' or '/>'.   So the above formatting produces
three lines, with newline terminators, and nothing else.

This puts the work on you instead of the filter, but it
works for me.

Best regards,
John Shipman (john@nmt.edu), Applications Specialist, NM Tech Computer Center,
Speare 119, Socorro, NM 87801, (505) 835-5950, http://www.nmt.edu/~john
  ``Let's go outside and commiserate with nature.''  --Dave Farber

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]