This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: Including only a part of an external source code
- From: cbbrowne at acm dot org
- To: Joachim Ziegler <ziegler at mpi-sb dot mpg dot de>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Fri, 24 Jan 2003 07:40:17 -0500
- Subject: Re: DOCBOOK-APPS: Including only a part of an external source code
- References: <3E31303B.5040301@mpi-sb.mpg.de>
> I'm planning to use DocBook to write a tutorial for the LEDA library
> (Library of Efficient Data Types and Algorithms).
>
> In this tutorial I will present many quite long code examples. i.e.
> source files of about 100 lines.
>
> I've just learned how I can include an external code file with something
> like
>
> <programlisting linenumbering="numbered"><textobject><textdata
> fileref="Code/HelloLEDAWorld.C"/></textobject></programlisting>
>
> This markup always include the file as a whole - but sometimes I want to
> include only a part of a file, for example the C++ class definitons,
> then explain them, and later include hte rest of the code.
>
> Is there a way to do this with DocBook and one of its tools?
When I was working on a book last year, writing using DocBook, I wound
up splitting the files into fragments, and having a Makefile manage
assembling them. The start of the Makefile looked like the following:
SCRIPTS = Actions.py pclient.py ComplexAction.py
all: $(SCRIPTS)
PYTHONACTS= ActionHeader.py \
Action1.py Action2.py Action3.py Action4.py Action5.py \
Action6.py ActionGeneral.py
Actions.py: $(PYTHONACTS)
cat $(PYTHONACTS) > Actions.py
Make was managing the fragments, not DocBook.
The main alternative would be to construct a bit of code that knows how
to extract the bits that you want to present out of the "main" program
file. That's more complex to configure (probably a bizarre "grep").
--
(reverse (concatenate 'string "moc.enworbbc@" "enworbbc"))
http://www3.sympatico.ca/cbbrowne/publications.html
"A foolish consistency is the hobgoblin of little minds."
-- Ralph Waldo Emerson