A script in the Python language extracts the various output files from DocBook source files. Command line arguments are:
litlxml file ...
Each DocBook-XML source file named on the command line is
read, and all the programlisting
elements with the correct role
attribute are assembled and written to the corresponding
files.
If you are using the Unix make utility to build your document and source files, you
can add lines to your Makefile to take care
of building the program source files.
The exact rules depend on whether your literate programs
are executable or not. We'll assume that both executable
and non-executable programs are produced, and that the
variable BASENAME is the name of your
DocBook file minus its “.xml” extension. below.
First, define three variables like this:
MODULES =m1 m2 ...EXECUTABLES =e1 e2 ...CODE_TARGETS = $(EXECUTABLES) $(MODULES)
where
, m1, and so forth
are the names of non-executable files, and
m2,
e1, and so on
are the names of your executable files.
e2
Then, in the rules part of your Makefile, change the first (default) target
to read like this:
all: web pdf code
Add these rules:
code: $(CODE_TARGETS)
$(CODE_TARGETS): $(BASENAME).xml
litlxml $<; \
chmod +x $(EXECUTABLES)
If no executables are produced, change the latter rule to:
$(CODE_TARGETS): $(BASENAME).xml
litlxml $<
A model Makefile is included in Writing documentation with DocBook-XML 4.3.