On Thursday 18 March 2004 01:48 am, Vladimir Prus wrote:
> Douglas Gregor wrote:
> > On Thursday 04 March 2004 03:22 am, Vladimir Prus wrote:
> > > Hello,
> > > I'm documenting a library, and would like to include an example in
> > > tutorial. I already have the example as .cpp file, so the question is:
> > > how to include that .cpp file into documentation. Is there something
> > > like
> > >
> > > <include-example href="../examples/multiple_sources.cpp"/>
> > >
> > > ? Do I have any alternatives other than copy-paste?
> >
> > Nothing that I know of. The way I've been doing it for test cases is
> > exactly the opposite, where all of the code is in the BoostBook XML and
> > we build the .cpp files from it. This lets me more easily talk about
> > program snippets in the tutorial text (see, e.g., Boost.Function) and put
> > them into an actual test case for regression testing. It's the literate
> > programming approach, essentially.
>
> Unfortunately, when examples are somewhat large (100 lines), I'd like to
> avoid including full text in docs. IIRC, LaTex has some module which allows
> to include specific lines of a program and add highlighting to it. Would be
> nice to have something like that. But I realize this might not be easy.
>
> - Volodya
We have the same thing for tests, which could trivially be extended to work
for any file. Here's how it works for tests:
<source>
<![CDATA[
#include <boost/function.hpp>
#include <iostream>
]]>
<snippet name="function.tutorial.mul_ints"/>
<snippet name="function.tutorial.int_div"/>
int main()
{
<snippet name="function.tutorial.arith.cxx98"/>
<snippet name="function.tutorial.use_int_div"/>
<snippet name="function.tutorial.call_int_div"/>
<snippet name="function.tutorial.check_empty"/>
<snippet name="function.tutorial.clear"/>
<snippet name="function.tutorial.use_mul_ints"/>
return 0;
}
</source>
The "snippet" element brings in the contents of the <programlisting> with the
same name, so you can present whatever bits and pieces you want in the
tutorial and hide the rest in a <source> element (which does not show up in
the actual documentation, of course).
Doug
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Boost-docs mailing list
[EMAIL PROTECTED]
Unsubscribe and other administrative requests:
https://lists.sourceforge.net/lists/listinfo/boost-docs