summaryrefslogtreecommitdiff
path: root/info/dtxgallery/conditional-code.dtx
blob: 658ff48ed1882788cbf6bb7ce95c7d49188c431a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% \iffalse meta-comment
%
% Part of Will Robertson's DTXGALLERY bundle, version 1.
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{fancyvrb}
\begin{document}
  \DocInput{conditional-code.dtx}
\end{document}
%</driver>
% \fi
%
% \section{Conditional inclusion of code}
%
% From previous examples the |%<*guard>|\dots|%</guard>| syntax should be a little familiar. This example demonstrates conditional extraction of such elements in the source document into multiple files. This technique makes it easy, say, to maintain a `debug' version of a package without polluting the public source with code for testing.
%
%    \begin{macrocode}
%<A>  code in `A'
%<B>  code in `B'
%<!A>  code not in `A'
%<!B>  code not in `B'
%<A&B>  code in `A' and `B'
%<A|B>  code in `A' or `B'
%<(A|B)&!(A&B)>  code in `A' xor `B'
%    \end{macrocode}
% Note the change in the typeset source when guards are nested: \\
% (this is equivalent to \verb|%<A&B>|)
%    \begin{macrocode}
%<*A>
%<B>  `B' nested inside `A'
%</A>
%    \end{macrocode}
% 
% \section{Verbatim files that are produced}
% \begin{minipage}{0.45\linewidth}
% \subsection{Generated from `A'}
% \VerbatimInput[frame=single]{A.txt}
% \end{minipage}\hfill
% \begin{minipage}{0.45\linewidth}
% \subsection{Generated from `B'}
% \VerbatimInput[frame=single]{B.txt}
% \end{minipage}
% \subsection{Generated from `A' and `B'}
% \VerbatimInput[frame=single]{AB.txt}
%
% \Finale
\endinput