This is the mail archive of the
mailing list for the DocBook project.
Re: xref to numbered code line?
- To: docbook at lists dot oasis-open dot org
- Subject: Re: DOCBOOK: xref to numbered code line?
- From: Norman Walsh <ndw at nwalsh dot com>
- Date: Fri, 5 Nov 1999 11:46:32 -0500
- References: <01BA10F0CD20D3119B2400805FD40F9F27809C@MDYNYCMSX1>
- Reply-To: docbook at lists dot oasis-open dot org
/ "DuCharme, Robert" <DuCharmR@moodys.com> was heard to say:
| What's the best way to mark up a code listing if I want it to appear with
| numbered lines and I want to refer to specific line numbers without hard
| coding the line numbers? If I write "In line 25, the <literal>free</literal>
| command deallocates the memory" and then insert more code above line 25, I
| don't want to have to change that "25" by hand.
| I'm assuming it's some appropriate subelement of programlisting and then an
| xref to that, but I can't figure out what.
Well, this is kind of rough to deal with. The "obvious" answer
of putting a marker, like <co>, in the programlisting at the
appropriate location is tedious because it means you have to
inject markup into your source code. And that means you can't
compile the source code that appears in your documentation.
Still, it may be the best bet. (Getting your processing system
to print linenumber references for xrefs to COs is, well, an
excercise left to the reader, at least for this week :-)
The other alternative might be to invent a structured comment
system and build the right references with a preprocessor that
injects the code into your documentation. Actually, this idea
combined with the former sounds like a good off-the-cuff answer :-)
Norman Walsh <firstname.lastname@example.org> | Men do not quit playing because
http://www.oasis-open.org/docbook/ | they grow old; they grow old
Member, DocBook Editorial Board | because they quit playing.--Oliver
| Wendell Holmes