% \iffalse
%% File: source3.dtx Copyright (C) 1990-2006 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the ``expl3 bundle'' (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/cgi-bin/cvsweb.cgi/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%% \fi

% This document will typeset the LaTeX3 sources as a single document.
% This will produce quite a large file (roughly ??? pages) and may
% take a long time.
%
% Some notes on processing this document are contained at the end
% of this document, after \end{document}
% 
% DPC 1997/11/17
% JLB 2005/03/09 copied from source2e.tex for l3in2e sources
% First a special index style for makeindex
%

\begin{filecontents}{source3.ist}
actual '='
quote '!'
level '>'
preamble
"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
postamble
"\n\n \\end{theindex}\n"
item_x1   "\\efill \n \\subitem "
item_x2   "\\efill \n \\subsubitem "
delim_0   "\\pfill "
delim_1   "\\pfill "
delim_2   "\\pfill "
% The next lines will produce some warnings when
% running Makeindex as they try to cover two different
% versions of the program:
lethead_prefix   "{\\bfseries\\hfil "
lethead_suffix   "\\hfil}\\nopagebreak\n"
lethead_flag       1
heading_prefix   "{\\bfseries\\hfil "
heading_suffix   "\\hfil}\\nopagebreak\n"
headings_flag       1

% and just for source3:
% Remove R so I is treated in sequence I J K not I II III
page_precedence "rnaA"
\end{filecontents}

\begin{filecontents}{l3doc.cfg}
  \DisableCrossrefs
  \AtEndOfClass{\OnlyDescription}
\end{filecontents}

\begin{filecontents}{l3full.cfg}

% Set up the Index and Change History to use \part
  \IndexPrologue{\part*{Index}%
                 \markboth{Index}{Index}%
                 \addcontentsline{toc}{part}{Index}%
                 The italic numbers denote the pages where the
                 corresponding entry is described,
                 numbers underlined point to the definition,
                 all others indicate the places where it is used.}

  \GlossaryPrologue{\part*{Change History}%
%                Allow control names to be hyphenated here...
                 {\GlossaryParms\ttfamily\hyphenchar\font=`\-}%
                 \markboth{Change History}{Change History}%
                 \addcontentsline{toc}{part}{Change History}}

  \RecordChanges
  \CodelineIndex
  \EnableCrossrefs
  \AlsoImplementation
  \setcounter{IndexColumns}{2}
\end{filecontents}


\documentclass{l3doc}

\listfiles

% Do not index some TeX primitives, and some common plain TeX commands.

%% to be filled in  later\DoNotIndex{...}
% The standard \changes command modified slightly to better cope with
% this multiple file document.
%\makeatletter
%\def\changes@#1#2#3{%
%  \let\protect\@unexpandable@protect
%  \edef\@tempa{\noexpand\glossary{#2\space\currentfile\space#1\levelchar
%                                 \ifx\saved@macroname\@empty
%                                   \space
%                                   \actualchar
%                                   \generalname
%                                 \else
%                                   \expandafter\@gobble
%                                   \saved@macroname
%                                   \actualchar
%                                   \string\verb\quotechar*%
%                                   \verbatimchar\saved@macroname
%                                   \verbatimchar
%                                 \fi
%                                 :\levelchar #3}}%
%  \@tempa\endgroup\@esphack}
%\makeatother

% Needed for documentation in ltoutenc.dtx
\usepackage{textcomp}

\begin{document}
 \title{The \LaTeX3 Sources}
 \author{\Team}

 \pagenumbering{roman}
 \maketitle
 \renewcommand\maketitle{}

 \tableofcontents

 \clearpage

 \pagenumbering{arabic}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Each of the following \DocInput lines includes a file with extension
% .dtx. Each of these files may be typeset separately. For instance
% latex l3boxes.dtx
% will typeset the source of the LaTeX3 box commands.
%
% If this file is processed, each of these separate dtx files will be
% contained as a part of a single document. Using ltxdoc.cfg you can
% then optionally produce a combined index and/or change history for
% the entire source of the format file. Note that such a document will
% be quite large (about ??? pages).
%

 \DocInput{l3names.dtx} % System dependant initialisation

 \DocInput{l3basics.dtx} %

 \DocInput{l3chk.dtx}    % Checking assignments

 \DocInput{l3tlp.dtx}  % 

 \DocInput{l3expan.dtx}  % 

 \DocInput{l3num.dtx}  % 

 \DocInput{l3seq.dtx}  % 

 \DocInput{l3alloc.dtx}  % 

 \DocInput{l3io.dtx}  % 

 \DocInput{l3clist.dtx}  % 

 \DocInput{l3prop.dtx}  % 

 \DocInput{l3int.dtx}  % 

 \DocInput{l3skip.dtx}  % 

 \DocInput{l3toks.dtx}  % 

 \DocInput{l3messages.dtx}  % 

 \DocInput{l3box.dtx}  % 

 \DocInput{l3precom.dtx}  % 

 \DocInput{l3quark.dtx}  % 

 \DocInput{l3prg.dtx}  % 

 \DocInput{l3token.dtx}  % 

 \DocInput{l3xref.dtx}  % 

 \DocInput{l3calc.dtx}  % 

%% \DocInput{l3vers.dtx}   % Current version date

 \includeltpatch       % Corrections distributed after the full release

% Stop here if ltxdoc.cfg says \AtEndOfClass{\OnlyDescription}
\StopEventually{\PrintIndex\end{document}}

\clearpage
\pagestyle{headings}

% Make TeX shut up.
\hbadness=10000
\newcount\hbadness
\hfuzz=\maxdimen

\typeout{%
  \string # Produce change log with^^J%
  makeindex -s gglo.ist -o source3.gls source3.glo}


\PrintChanges

\clearpage

% makeindex needs a symbol between the parts of composite page numbers
% but we dont want one, so:
\typeout{%
  \string # Produce index with^^J%
  makeindex -s source3.ist source3.idx}

\begingroup
\def\endash{--}
\catcode`\-\active
\def-{\futurelet\temp\indexdash}
\def\indexdash{\ifx\temp-\endash\fi}

\PrintIndex
\endgroup

% Make sure that the index is not printed twice
% (ltxdoc.cfg might have a second \PrintIndex command)
\let\PrintChanges\relax
\let\PrintIndex\relax

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

To use this file to produce a fully indexed source code
you need to execute the following (or equivalent) commands:

   latex source3.tex

   makeindex -s source3.ist source3.idx
   makeindex -s gglo.ist -o source3.gls source3.glo

   latex source3.tex
   latex source3.tex


The makeindex style source3.ist is used in place of the usual
doc gind.ist to ensure that I is used in the sequence I J K
not I II II, which would be the default makeindex behaviour.

The third run with latex is only required to get the table of
contents entries for the change log and index. You may speed things up
by using the \includeonly mechanism so as not to typeset the source
files on the second run. This involves changing the file
ltxdoc.cfg
between the latex runs.

The following unix script automates this.
  (It could easily be ported to scripts for DOS or VMS,
   rm is ReMove a file, and echo "..." > file writes ... to "file".)


After this script (after the second ==============) is a similar script
that will produce the documentation for all the files in the base
distribution that are *not* included in source3.dvi. This second script
was requested, but before using it, beware it will take a long time!
It may however be modified as required, eg to not typeset the fdd files
or whatever...

==============
#!/bin/sh

rm  -f source3.gls source3.ind source3.toc

# First run: 
# Create new standard ltxdoc.cfg file
# Pass the (possibly empty) list of arguments supplied on the
# command line to article class.
#
# If you use A4 paper, running this script with argument
#    a4paper
# may save about 30 pages.
#
echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg


# Now LaTeX the file with this cfg file.
#
latex source3.tex


# Make the Change log and Glossary.
#
makeindex -s source3.ist source3.idx
makeindex -s gglo.ist -o source3.gls source3.glo


# Second run: append \includeonly{} to ltxdoc.cfg to speed up things
# (this run needed only to get changes and index listed in .toc file)
#
# Note that the index will not be made incorrect by the insertion
# of the table of contents as the front matter uses a diferent page
# numbering scheme.
#
echo "\includeonly{}" >> ltxdoc.cfg

latex source3.tex


# Third and final run, to put everything together.
# First restore the cfg file:
#
echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg
latex source3.tex


==============
#!/bin/sh

# Running this script will process all the dtx fdd and *guide.tex
# and ltnews*.tex files in the LaTeX distribution, except the dtx
# files included in source3.tex. 
# (The shell first script in the comments of source3.tex will
#  process those.)

# Any command line arguments (eg a4paper) are taken as options to the
# article class.

# This script is likely to take ages!

echo "\PassOptionsToClass{$*}{article}"                  > ltxdoc.cfg
echo "\batchmode"                                       >> ltxdoc.cfg

# The next four lines produce full indexes and change logs
# you may not want those.
echo "\AtBeginDocument{\RecordChanges}"                 >> ltxdoc.cfg
echo "\AtEndDocument{\PrintChanges}"                    >> ltxdoc.cfg
echo "\AtBeginDocument{\CodelineIndex\EnableCrossrefs}" >> ltxdoc.cfg
echo "\AtEndDocument{\PrintIndex}"                      >> ltxdoc.cfg

# If you do not want any code listings, just documentation, then instead
# of the above four lines, uncomment the following:
# echo "\AtBeginDocument{\OnlyDescription}"                >> ltxdoc.cfg

echo "\PassOptionsToClass{$*}{article}"                  > ltxguide.cfg
echo "\batchmode"                                       >> ltxguide.cfg

cp ltxguide.cfg ltnews.cfg


for i in *dtx *fdd *guide.tex ltnews*.tex
do
B=`basename $i .dtx`

if (grep "Include{$B}" source3.tex >/dev/null ; )
then
echo In source3: $i
else
echo latex $i
  if (latex $i > /dev/null) 
  then
    echo latex $i
    latex $i > /dev/null
    echo makeindex -s gind.ist $B.idx
    makeindex -s gind.ist $B.idx > /dev/null 2> /dev/null
    echo makeindex -s gglo.ist -o $B.gls $B.glo
    makeindex -s gglo.ist -o $B.gls $B.glo > /dev/null 2> /dev/null
    echo latex $i
    latex $i > /dev/null
  else
    echo "!!! LaTeX ERROR: $i. (See $B.log.)"
  fi
fi

done
