Changes

From Wiki
Jump to navigation Jump to search

< Sample documents

At my work, we have to add some sort of revision history to certain documents. This is also an example for the use of \getparameters (see Commands with KeyVal arguments).

A downloadable version of the macro is available here, and a PDF example of the output here.

Note that background=screen is depricated and should be replaced by something like background=color,backgroundcolor=gray.

\useregime[il1]
\enableregime[il1]
\useencoding[ffr]
\definehspace[fr][:][.16667em]
\definehspace[fr][;][.16667em]
\definehspace[fr][!][.16667em]
\definehspace[fr][?][.16667em]
\mainlanguage[fr]
\newdimen\BigWidth \BigWidth=18cm
\setupscreens[screen=0.85]
\setupcolors[state=start]
\setupheadertexts[Rév.: \the\RevC]
\def\Vfil{\vskip0pt plus3fil\relax}
\def\In[#1,#2]{\ifx#1\empty\else\in[#1]\fi\if\relax#2\else, \In[#2]\fi}
\def\BigTitle{\centerline{\framed[width=\BigWidth,offset=2mm,
      background=screen]{\bfb\setupinterlinespace\cbox{Title}}}}
\def\Auteur{Peter}

\def\startChanges{\hbox to \hsize\bgroup\hss\SetTableToWidth{\BigWidth}%
  \starttable[s1 | c | c | p(95mm) | p(17mm) | p(37mm) |]
  \HL\BL[5]\AR\VL Rv.\VL Date\VL Origine de la mise à jour\VL modifié\VL
  Auteur\VL\AR\HL}
\def\stopChanges{\stoptable\hss\egroup}\newcount\RevC
\def\Changes[#1]{%
  \getgparameters[Changes][Date=,Labels=,#1]% Auteur, Modif, Labels, Date
  \doifundefined{ChangesAuteur}{\gdef\ChangesAuteur{\Auteur}}%
  \doifundefined{ChangesModif}{\gdef\ChangesModif{First version}}%
  \ifnum\RevC=0 \BigTitle \vskip0.5ex \Vfil \startChanges \fi
  \global\advance\RevC by 1 \VL \the\RevC \VL \ChangesDate \VL
  \ChangesModif \VL \expandafter\In\expandafter[\ChangesLabels,\relax]\VL
  \ChangesAuteur \VL\AR\HL}
\def\Destinataires#1{\stopChanges\Vfil
  \def\temp{#1}\ifx\temp\empty\else\noindenting Destinataires:\crlf#1\blank\fi
\centerline{\SetTableToWidth{\BigWidth}%
\bf\starttable[| c | c | c |]
\HL\BL[3]\AR\VL Approbateur\VL Date\VL Visa\VL\AR\HL
\VL\vbox to 2cm{}\VL\VL\VL\AR\HL
\stoptable}\par\page\completecontent}

\starttext
\Changes[Date=1/2/2004]
\Changes[Date=3/4/2004,Modif=Some modifications,Labels={sec:S1,sec:S2},
  Auteur=Jérôme]
\Changes[Date=5/6/2004,Modif=Some other modifications,Labels=sec:S2]
%
\Destinataires{Peter, Olivier}

\section[sec:S1]{A section}
some text
\subsection{Bla}
\subsection{Bla}

\section[sec:S2]{Another section}
some text
\stoptext