Commit ecc4cd5e authored by Guillaume Pasero's avatar Guillaume Pasero

DOC: replace lstlisting by minted for syntax coloration

parent a2626eb7
......@@ -3,4 +3,4 @@
TEXINPUTS=$TEXINPUTS:${ITK_TEXINPUTS}
export TEXINPUTS
${LATEX_COMPILER} -file-line-error -halt-on-error "$@"
${LATEX_COMPILER} -file-line-error -halt-on-error -shell-escape "$@"
......@@ -89,7 +89,7 @@ SET(DVIPS_CONVERTER_OPTIONS -D600)
# Option for html generation
SET(TEX4HT_OPTIONS html,2,sections+)
SET(TEX4HT_OPTIONS "html,2,sections+ \"\" \"\" -shell-escape")
SET (HTML_OUTPUT "SoftwareGuide-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
# Copy RELEASE_NOTES.txt from OTB source tree to Software Guide build directory
......
......@@ -112,17 +112,17 @@ section~\ref{chapter:WriteAFilter}, page~\pageref{chapter:WriteAFilter}.
The first step is to write a persistent mean image filter. We need to
include the appropriate header :
\begin{lstlisting}
\begin{minted}{cpp}
#include "otbPersistentImageFilter.h"
\end{lstlisting}
\end{minted}
Then, we declare the class prototype as follows:
\begin{lstlisting}
\begin{minted}{cpp}
template<class TInputImage >
class ITK_EXPORT PersistentMeanImageFilter :
public PersistentImageFilter<TInputImage, TInputImage>
\end{lstlisting}
\end{minted}
Since the output image will only be used for streaming purpose, we do
not need to declare different input and output template types.
......@@ -131,14 +131,14 @@ In the \emph{private} section of the class, we will declare a member which
will be used to store temporary results, and a member which will be
used to store the final result.
\begin{lstlisting}
\begin{minted}{cpp}
private:
// Temporary results container
std::vector<PixelType> m_TemporarySums;
// Final result member
double m_Mean;
\end{lstlisting}
\end{minted}
Next, we will write the \verb?Reset()? method implementation in the
\emph{protected} section of the class. Proper allocation of the
......@@ -146,7 +146,7 @@ temporary results container with respect to the number of threads is
handled here.
\begin{lstlisting}
\begin{minted}{cpp}
protected:
virtual void Reset()
{
......@@ -160,13 +160,13 @@ protected:
// Reset the final result
m_Mean = 0.;
}
\end{lstlisting}
\end{minted}
Now, we need to write the \verb?ThreadedGenerateData()? methods (also
in the \emph{protected} section), were
temporary results will be computed for each piece of stream.
\begin{lstlisting}
\begin{minted}{cpp}
virtual void ThreadedGenerateData(const RegionType&
outputRegionForThread, itk::ThreadIdType threadId)
{
......@@ -190,12 +190,12 @@ for (it.GoToBegin(); !it.IsAtEnd(); ++it, progress.CompletedPixel())
m_TemporarySums[threadId]+= value;
}
\end{lstlisting}
\end{minted}
Last, we need to define the \verb?Synthetize()? method (still in the
\emph{protected} section), which will yield the final results:
\begin{lstlisting}
\begin{minted}{cpp}
virtual void Synthetize()
{
// For each thread
......@@ -214,7 +214,7 @@ if(nbPixels!=0)
m_Mean/=nbPixels;
}
}
\end{lstlisting}
\end{minted}
\subsection{Second step: Decorating the filter and using it}
......@@ -222,41 +222,41 @@ Now, to use the filter, one only has to decorate it with the
\doxygen{otb}{PersistentFilterStreamingDecorator}. First step is
to include the appropriate header:
\begin{lstlisting}
\begin{minted}{cpp}
#include "otbPersistentMeanImageFilter.h"
#include "otbPersistentFilterStreamingDecorator.h"
\end{lstlisting}
\end{minted}
Then, we decorate the filter with some typedefs:
\begin{lstlisting}
\begin{minted}{cpp}
typedef otb::PersistentMeanImageFilter<ImageType>
PersitentMeanFilterType;
typedef otb::PersistentFilterStreamingDecorator
< PersitentMeanFilterType> StreamingMeanFilterType;
\end{lstlisting}
\end{minted}
Now, the decorated filter can be used like any standard filter:
\begin{lstlisting}
\begin{minted}{cpp}
StreamingMeanFilterType::Pointer filter =
StreamingMeanFilterType::New();
filter->SetInput(reader->GetOutput());
filter->Update();
\end{lstlisting}
\end{minted}
\subsection{Third step: one class to rule them all}
It is often convenient to avoid the few typedefs of the previous
section by deriving a new class from the decorated filter:
\begin{lstlisting}
\begin{minted}{cpp}
template<class TInputImage >
class ITK_EXPORT StreamingMeanImageFilter :
public PersistentFilterStreamingDecorator<
PersistentImageFilter<TInputImage, TInputImage> >
\end{lstlisting}
\end{minted}
This also allows to redefine setters and getters for parameters,
avoiding to call the \verb?GetFilter()? method to set them.
......@@ -32,40 +32,7 @@
\definecolor{listlightgray}{gray}{0.955}
\definecolor{listwhite}{gray}{1.0}
\usepackage{listings}
\newcommand{\lstsetcpp}
{
\lstset{frame = tb,
framerule = 0.25pt,
float,
fontadjust,
backgroundcolor={\color{listlightgray}},
basicstyle = {\ttfamily\footnotesize},
keywordstyle = {\ttfamily\color{listkeyword}\textbf},
identifierstyle = {\ttfamily},
commentstyle = {\ttfamily\color{listcomment}\textit},
stringstyle = {\ttfamily},
showstringspaces = false,
showtabs = false,
numbers = none,
numbersep = 6pt,
numberstyle={\ttfamily\color{listnumbers}},
tabsize = 2,
language=[ANSI]C++,
floatplacement=!h
}
}
\newcommand{\lstsetpython}
{
\lstset{language=Python
}
}
\newcommand{\lstsetjava}
{
\lstset{language=Java
}
}
\usepackage{minted}
\newif\ifitkFullVersion
\itkFullVersiontrue
......@@ -170,8 +137,6 @@ colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue},
\hyperbaseurl{http://www.orfeo-toolbox.org}
\lstsetcpp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
......
......@@ -248,14 +248,12 @@ in order to launch each internal application. The order should be compatible wit
image parameter connexions. If you want to do "in-memory" connexions, you can do it between
two calls to \code{ExecuteInternal()}, for instance :
\small
\begin{lstlisting}
\begin{minted}{cpp}
ExecuteInternal("a");
GetInternalApplication("b")->SetParameterInputImage("in",
GetInternalApplication("a")->GetParameterOutputImage("out"));
ExecuteInternal("b");
\end{lstlisting}
\normalsize
\end{minted}
The application BundleToPerfectSensor is a simple example of composite applications.
For a more complex example, you can check the application TrainImagesClassifier.
......
......@@ -92,8 +92,7 @@ sub ParseCxxFile {
$tagfound = 1;
$dumpinglatex = 0;
$dumpingcode = 1;
print OUTFILE "\\small\n";
print OUTFILE "\\begin{lstlisting}\n";
print OUTFILE "\\begin{minted}{cpp}\n";
}
elsif( /$endlatextag/ ) {
$tagfound = 1;
......@@ -102,8 +101,7 @@ sub ParseCxxFile {
elsif( /$endcodesnippettag/ ) {
$tagfound = 1;
$dumpingcode = 0;
print OUTFILE "\\end{lstlisting}\n";
print OUTFILE "\\normalsize\n";
print OUTFILE "\\end{minted}\n";
}
if( !$tagfound ) {
if( $dumpinglatex ) {
......
......@@ -4,7 +4,7 @@
TEXINPUTS=$TEXINPUTS:${ITK_TEXINPUTS}
export TEXINPUTS
mkdir ${HTML_OUTPUT}
mkdir -p ${HTML_OUTPUT}
cd ${HTML_OUTPUT}
${TEX4HT_COMPILER} "$@" ${TEX4HT_OPTIONS}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment