| 1 |
% \iffalse meta-comment |
| 2 |
% $Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $ |
| 3 |
% |
| 4 |
% Copyright (C) 2009-2010 by Martin Scharrer <[email protected]> |
| 5 |
% |
| 6 |
% This work may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in |
| 10 |
% |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 14 |
% version 2008/05/04 or later. |
| 15 |
% |
| 16 |
% This work has the LPPL maintenance status `maintained'. |
| 17 |
% |
| 18 |
% The Current Maintainer of this work is Martin Scharrer. |
| 19 |
% |
| 20 |
% This work consists of the files svn-prov.dtx, svn-prov.ins |
| 21 |
% and the derived file svn-prov.sty. |
| 22 |
% |
| 23 |
% \fi |
| 24 |
% |
| 25 |
% \iffalse |
| 26 |
%<*driver> |
| 27 |
\RequirePackage{svn-prov} |
| 28 |
%</driver> |
| 29 |
%<*driver|package> |
| 30 |
\def\svnprov@version{v3.\rev} |
| 31 |
%</driver|package> |
| 32 |
%<*driver> |
| 33 |
\ProvidesFileSVN{$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 34 |
[\svnprov@version\space DTX for \filebase.sty] |
| 35 |
\DefineFileInfoSVN |
| 36 |
\GetFileInfoSVN* |
| 37 |
% Re-require package to check date |
| 38 |
\RequirePackage{svn-prov}[\filedate] |
| 39 |
|
| 40 |
\documentclass{article} |
| 41 |
\usepackage{ydoc} |
| 42 |
\usepackage[hyperfootnotes=false]{hyperref} |
| 43 |
\usepackage{booktabs} |
| 44 |
|
| 45 |
\makeatletter |
| 46 |
%%% Examples %%% |
| 47 |
\RequirePackage{fancyvrb} |
| 48 |
\RequirePackage{listings} |
| 49 |
|
| 50 |
\renewenvironment{example} |
| 51 |
{\begingroup\VerbatimOut[gobble=4]{\jobname.exa}} |
| 52 |
{\endVerbatimOut\endgroup\formatexample} |
| 53 |
|
| 54 |
\usepackage{ifthen,calc} |
| 55 |
|
| 56 |
\def\examplebeforetext{The following code:} |
| 57 |
\def\exampleaftertext{is equivalent to:} |
| 58 |
|
| 59 |
\def\formatexample{% |
| 60 |
\par\noindent\examplebeforetext |
| 61 |
\lstinputlisting{\jobname.exa}\medskip |
| 62 |
\exampleaftertext\\[\medskipamount]% |
| 63 |
{\catcode`\%=14% |
| 64 |
\input{\jobname.exa}}% |
| 65 |
\par\bigskip |
| 66 |
} |
| 67 |
|
| 68 |
\lstset{% |
| 69 |
%numbers=left, |
| 70 |
numberstyle=\scriptsize\sffamily, |
| 71 |
basicstyle=\ttfamily, |
| 72 |
stepnumber=1, |
| 73 |
language=[latex]tex, |
| 74 |
}% |
| 75 |
|
| 76 |
|
| 77 |
\usepackage{xspace} |
| 78 |
\let\pkg\relax |
| 79 |
\newcommand*{\pkg}[1]{% |
| 80 |
\href{http://tug.ctan.org/pkg/#1}{\texttt{#1}}% |
| 81 |
% URL footnote (for print-out) on first appearance: |
| 82 |
\@ifundefined{seen@package@#1}{% |
| 83 |
\footnote{CTAN: \url{http://tug.ctan.org/pkg/#1}}% |
| 84 |
\@namedef{seen@package@#1}{1}% |
| 85 |
}{}% |
| 86 |
\xspace |
| 87 |
} |
| 88 |
|
| 89 |
\def\darg#1{\texttt{\frenchspacing\char`\{\$#1\$\char`\}}} |
| 90 |
|
| 91 |
\makeatother |
| 92 |
|
| 93 |
\EnableCrossrefs |
| 94 |
\CodelineIndex |
| 95 |
\RecordChanges |
| 96 |
|
| 97 |
\let\manualnewpage\newpage |
| 98 |
\listfiles |
| 99 |
\begin{document} |
| 100 |
\DocInput{svn-prov.dtx} |
| 101 |
\PrintChanges |
| 102 |
\manualnewpage |
| 103 |
\PrintIndex |
| 104 |
\end{document} |
| 105 |
%</driver> |
| 106 |
% \fi |
| 107 |
% |
| 108 |
% \CheckSum{423} |
| 109 |
% |
| 110 |
% \CharacterTable |
| 111 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 112 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 113 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 114 |
% Exclamation \! Double quote \" Hash (number) \# |
| 115 |
% Dollar \$ Percent \% Ampersand \& |
| 116 |
% Acute accent \' Left paren \( Right paren \) |
| 117 |
% Asterisk \* Plus \+ Comma \, |
| 118 |
% Minus \- Point \. Solidus \/ |
| 119 |
% Colon \: Semicolon \; Less than \< |
| 120 |
% Equals \= Greater than \> Question mark \? |
| 121 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 122 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 123 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 124 |
% Right brace \} Tilde \~} |
| 125 |
% |
| 126 |
% |
| 127 |
% \changes{v0.922}{2009/04/26}{Initial version} |
| 128 |
% \changes{v1.}{2009/05/03}{Added \cs{DefineFileInfoSVN} macro.} |
| 129 |
% \changes{v2.}{2010/03/25}{Fixed issues when used in font definition \texttt{*.fd} files due to changed catcodes. |
| 130 |
% Also fixed error which occurred when Id line was not expanded.} |
| 131 |
% |
| 132 |
% ^^A \GetFileInfo{\jobname.dtx} |
| 133 |
% |
| 134 |
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\gdef,\xdef,\let,\@tempa} |
| 135 |
% \DoNotIndex{\g@tempa,\textbackslash,\ifx,\if,\ifnum,\else,\fi,\relax,\space} |
| 136 |
% \DoNotIndex{\@ifnextchar,\@gobble,\@undefined,\begingroup,\endgroup,\empty} |
| 137 |
% \DoNotIndex{\expandafter,\NeedsTeXFormat} |
| 138 |
% |
| 139 |
% \title{The \textsf{svn-prov} package\\\large Use SVN Id keywords for package, |
| 140 |
% class and file header} |
| 141 |
% \author{Martin Scharrer \\ \url{[email protected]}} |
| 142 |
% \GetFileInfoSVN{svnprov} |
| 143 |
% \date{Version~\fileversion\ - \filetoday} |
| 144 |
% |
| 145 |
% \maketitle |
| 146 |
% |
| 147 |
% \section{Introduction} |
| 148 |
% This package is directed to authors of \LaTeX\ packages and classes which use |
| 149 |
% the version control software |
| 150 |
% \href{http://subversion.tigris.org/}{Subversion}\footnote |
| 151 |
% {WWW: \url{http://subversion.tigris.org/}} (SVN) for their source files. It |
| 152 |
% introduces three macros which are Subversion variants of the standard \LaTeX\ |
| 153 |
% header macros \cs{ProvidesPackage}, \cs{ProvidesClass} and \cs{ProvidesFile} |
| 154 |
% which are used to identify package, class and other files, respectively. |
| 155 |
% Instead of providing the package/class/file name and date manually they are |
| 156 |
% extracted from a Subversion Id keywords string which |
| 157 |
% is updated automatically by every time the source file is committed to the |
| 158 |
% repository. |
| 159 |
% |
| 160 |
% A similar package exists for RCS, the pre-predecessor of Subversion, in the |
| 161 |
% \pkg{pgf} bundle which is called \texttt{pgfrcs}. |
| 162 |
% For further support for Subversion keywords see the author's other package |
| 163 |
% \pkg{svn-multi}. |
| 164 |
% |
| 165 |
% \section{Usage} |
| 166 |
% ^^A\subsection{Subversion Id Keyword} |
| 167 |
% The following macros need an Id keyword which can initially be written as |
| 168 |
% `|$||Id:$|' and will be expanded by Subversion into the following format at |
| 169 |
% the next commit:\par\smallskip |
| 170 |
% \texttt{\frenchspacing\${}Id: \meta{filename} \meta{revision} \meta{date} |
| 171 |
% \meta{time} \meta{author} \$} |
| 172 |
% \par\smallskip |
| 173 |
% \noindent e.g. for the source file of this document:\par\smallskip |
| 174 |
% |$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $| |
| 175 |
% \par\smallskip |
| 176 |
% \noindent For this to work the Subversion \emph{property} \texttt{svn:keywords} must be |
| 177 |
% set to (at least) `|Id|' for the source file(s). e.g.\ using the command |
| 178 |
% line:\par\smallskip |
| 179 |
% \texttt{svn propset 'svn:keyword' 'Id' \meta{filename(s)}} |
| 180 |
% \par\smallskip\noindent |
| 181 |
% \nopagebreak[3]\unskip |
| 182 |
% More information about using Subversion in the \LaTeX\ workflow can be found in the |
| 183 |
% Prac\TeX{} Journal issue 2007-3\footnote |
| 184 |
% {URL: |
| 185 |
% \ttfamily\url{http://www.tug.org/pracjourn/2007-3/}\char`\{\href |
| 186 |
% {http://www.tug.org/pracjourn/2007-3/skiadas-svn}{skiadas-svn}\char`\|\href |
| 187 |
% {http://www.tug.org/pracjourn/2007-3/ziegenhagen}{ziegenhagen}\char`\|\href |
| 188 |
% {http://www.tug.org/pracjourn/2007-3/scharrer}{scharrer}\char`\}}. |
| 189 |
% |
| 190 |
% ^^A\subsection{Main Macros} |
| 191 |
% \manualnewpage%% |
| 192 |
% \DescribeMacro\ProvidesPackageSVN [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>] |
| 193 |
% \DescribeMacro\ProvidesClassSVN [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>] |
| 194 |
% \DescribeMacro\ProvidesFileSVN [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>] |
| 195 |
% |
| 196 |
% All of these macros await a valid Subversion Id keyword string as a mandatory |
| 197 |
% argument. The file name and date is extracted from this string. For cases when |
| 198 |
% the file source is not stored in the correct file but packed inside a |
| 199 |
% different one, like a |.dtx| file, the correct file name can be provided by an |
| 200 |
% optional argument. Because the file extension of package and class files is |
| 201 |
% predefined and therefore ignored this is not needed for them when they are |
| 202 |
% packed inside a corresponding |.dtx| file, i.e. one with the same base name. |
| 203 |
% |
| 204 |
% As with the standard macros mentioned above additional information can be given optionally. |
| 205 |
% Since v0.3 the SVN macro provide two optional arguments (before only one). |
| 206 |
% If only one optional argument is given it is taken as a description text which may start |
| 207 |
% with an potential version number. This version number must start with `|v|' and not include spaces |
| 208 |
% and is extracted from the description. |
| 209 |
% Alternatively the version number and the description can be provided using two separate optional arguments. |
| 210 |
% If no optional argument is given the default string \cs{revinfo} (see below) is used instead. |
| 211 |
% |
| 212 |
% All three optional arguments can include the following macros which are only valid |
| 213 |
% inside them, but not afterwards\footnote{They can be set using \cs{GetFileInfoSVN}}: |
| 214 |
% \begin{description} |
| 215 |
% \item[\cs{rev}] File revision. |
| 216 |
% \item[\cs{Rev}] File revision followed by a space. |
| 217 |
% \item[\cs{revinfo}] The default information used: |
| 218 |
% ``\texttt{\frenchspacing(SVN Rev: \meta{revision})}''. |
| 219 |
% \item[\cs{filebase}] File base name (file name without extension). |
| 220 |
% \item[\cs{fileext}] File extension (without leading dot). |
| 221 |
% \item[\cs{filename}] File name. |
| 222 |
% \item[\cs{filedate}] File date (in the format YYYY/MM/DD). |
| 223 |
% \item[\cs{filerev}] File revision, like \cs{rev}. |
| 224 |
% \end{description} |
| 225 |
% |
| 226 |
% ^^A\subsection{Other Macros} |
| 227 |
% \par\medskip |
| 228 |
% \DescribeMacro\GetFileInfoSVN{<name>} |
| 229 |
% \DescribeMacro\GetFileInfoSVN* |
| 230 |
% This macro\marginpar{\it\raggedright Non-star version added in v3. 2010/04/11} |
| 231 |
% sets the macros \cs{filebase}, \cs{fileext}, \cs{filename}, \cs{filedate}, \cs{fileversion}, \cs{filerev}, |
| 232 |
% \cs{fileinfo} and \cs{filetoday} to the corresponding values of the file given by \meta{name}. The file must have been |
| 233 |
% read/loaded before and use both a \cs{Provides\ldots SVN} macro and \cs{DefineFileInfoSVN}, otherwise the above macros |
| 234 |
% will be set to |\relax|. The \meta{name} can be either the real filename or the optional short name used with |
| 235 |
% \cs{DefineFileInfoSVN}. |
| 236 |
% |
| 237 |
% The star version of this macro provides the file information of the last file which called one of the |
| 238 |
% \cs{Provides\ldots SVN} macros. |
| 239 |
% |
| 240 |
% The macros \cs{fileversion} and \cs{fileinfo} hold the file version and description taken from optional argument of |
| 241 |
% the \cs{Provide...SVN} macro. The version is defined only if this argument starts with `|v|' and is otherwise empty. |
| 242 |
% It includes all text up to the first space. |
| 243 |
% The \cs{filetoday} macro generates a text representation of the \cs{filedate} using the \cs{today} macro. The format can be |
| 244 |
% adjusted to a different language with the |\date|\meta{language} macro from the \pkg{babel} package. |
| 245 |
% The other macros are described above. |
| 246 |
% |
| 247 |
% |
| 248 |
% \par\medskip |
| 249 |
% \DescribeMacro\DefineFileInfoSVN[<name>] |
| 250 |
% Defined\marginpar{\it\raggedright New in v1. 2009/05/03} |
| 251 |
% a set of macros which provide the information collected by a previous |
| 252 |
% \cs{Provides\ldots} macro. The macros have the form |
| 253 |
% |\|\meta{name}|@|\meta{data} where \meta{name} is by default the filename |
| 254 |
% either with the file extension (general files) or without (packages and |
| 255 |
% classes). This default can be overwritten by the optional argument. |
| 256 |
% The \meta{data} stands for |version|, |rev| (revision), |date| and |info| |
| 257 |
% (the information part without the version number) |
| 258 |
% and, since v3,\marginpar{\it\raggedright Updated in v3. 2010/04/24} |
| 259 |
% file name |base| and |ext|(ension) as well as |today|, which prints |
| 260 |
% the |date| in the format of \cs{today}. |
| 261 |
% |
| 262 |
% \noindent |
| 263 |
% \textit{Example:} Applied to the |.dtx| file of this very package the |
| 264 |
% following macros are defined:\par\medskip |
| 265 |
% \begingroup |
| 266 |
% \makeatletter\centering |
| 267 |
% \begin{tabular}{ll} |
| 268 |
% \toprule |
| 269 |
% Macro & Definition \\ |
| 270 |
% \midrule |
| 271 |
% \cs{svn-prov.dtx@version} & \@nameuse{svn-prov.dtx@version} \\ |
| 272 |
% \cs{svn-prov.dtx@rev} & \@nameuse{svn-prov.dtx@rev} \\ |
| 273 |
% \cs{svn-prov.dtx@date} & \@nameuse{svn-prov.dtx@date} \\ |
| 274 |
% \cs{svn-prov.dtx@info} & \@nameuse{svn-prov.dtx@info} \\ |
| 275 |
% \cs{svn-prov.dtx@base} & \@nameuse{svn-prov.dtx@base} \\ |
| 276 |
% \cs{svn-prov.dtx@ext} & \@nameuse{svn-prov.dtx@ext} \\ |
| 277 |
% \cs{svn-prov.dtx@today} & \@nameuse{svn-prov.dtx@today} \\ |
| 278 |
% \bottomrule |
| 279 |
% \end{tabular} |
| 280 |
% \par\bigskip |
| 281 |
% The style file however would get macros like \cs{svn-prov@version}. |
| 282 |
% Because `|-|' is not a letter the macros can only be accessed using |\csname|. |
| 283 |
% Therefore the optional argument |[svnprov]| is used to name the macros |
| 284 |
% \cs{svnprov@version} etc.. |
| 285 |
% \endgroup |
| 286 |
% |
| 287 |
% |
| 288 |
% \section{Examples} |
| 289 |
% \begingroup |
| 290 |
% \def\{{\texttt{\char`\{}}% |
| 291 |
% \def\}{\texttt{\char`\}}}% |
| 292 |
% \def\ProvidesPackage#1[#2]{\texttt{\cs{ProvidesPackage}\{#1\}[#2]}\\}% |
| 293 |
% \def\ProvidesClass#1[#2]{\texttt{\cs{ProvidesClass}\{#1\}[#2]}\\}% |
| 294 |
% \def\ProvidesFile#1[#2]{\texttt{\cs{ProvidesFile}\{#1\}[#2]}\\}% |
| 295 |
% |
| 296 |
% The following examples illustrate the usage of the provided macros and how |
| 297 |
% they call the equivalent standard macros internally. The example |
| 298 |
% \emph{results} are produced by expanding the corresponding example \emph{code} |
| 299 |
% while the standard provide macros are locally redefined to typeset their own |
| 300 |
% name and arguments in verbatim style. This does not only simplifies the |
| 301 |
% generation of this document but makes this examples also test cases which |
| 302 |
% allow the package author to test the result of the defined macros. |
| 303 |
% |
| 304 |
% While mostly the package macro is used here the usage is identical to the |
| 305 |
% class and file macros. Of course before this macros are used it must be made |
| 306 |
% sure that the \texttt{svn-prov} package is loaded which is done by using the |
| 307 |
% following code direct before them:\\[\smallskipamount] |
| 308 |
% |\RequirePackage{svn-prov}|\\ |
| 309 |
% |
| 310 |
% \frenchspacing |
| 311 |
% \subsubsection*{Minimal usage} |
| 312 |
% \begin{example} |
| 313 |
% \ProvidesPackageSVN |
| 314 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 315 |
% \end{example} |
| 316 |
% \begin{example} |
| 317 |
% \ProvidesClassSVN |
| 318 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 319 |
% \end{example} |
| 320 |
% \begin{example} |
| 321 |
% \ProvidesFileSVN |
| 322 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 323 |
% \end{example} |
| 324 |
% |
| 325 |
% \subsubsection*{Normal Usage} |
| 326 |
% \begin{example} |
| 327 |
% \ProvidesPackageSVN |
| 328 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 329 |
% [v1.0 Example Description] |
| 330 |
% \end{example} |
| 331 |
% \begin{example} |
| 332 |
% \ProvidesClassSVN |
| 333 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 334 |
% [v1.0 Example Description] |
| 335 |
% \end{example} |
| 336 |
% \begin{example} |
| 337 |
% \ProvidesFileSVN |
| 338 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 339 |
% [v1.0 Example Description] |
| 340 |
% \end{example} |
| 341 |
% |
| 342 |
% \subsubsection*{Normal Usage with only Description} |
| 343 |
% \begin{example} |
| 344 |
% \ProvidesFileSVN |
| 345 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 346 |
% [Example Description] |
| 347 |
% \end{example} |
| 348 |
% |
| 349 |
% \subsubsection*{Normal Usage with separate Version and Description} |
| 350 |
% \begin{example} |
| 351 |
% \ProvidesFileSVN |
| 352 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 353 |
% [v1.0][Example Description] |
| 354 |
% \end{example} |
| 355 |
% |
| 356 |
% \subsubsection*{Overwriting Name} |
| 357 |
% \begin{example} |
| 358 |
% \ProvidesPackageSVN[othername] |
| 359 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 360 |
% [v1.0 Example Description] |
| 361 |
% \end{example} |
| 362 |
% |
| 363 |
% \subsubsection*{Overwriting Name including unneeded Extension} |
| 364 |
% \begin{example} |
| 365 |
% \ProvidesPackageSVN[othername.sty] |
| 366 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 367 |
% [v1.0 Example Description] |
| 368 |
% \end{example} |
| 369 |
% |
| 370 |
% \subsubsection*{Overwriting Name using Macros} |
| 371 |
% \begin{example} |
| 372 |
% \ProvidesFileSVN[\filebase.cfg] |
| 373 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 374 |
% [v1.0 Example Description] |
| 375 |
% \end{example} |
| 376 |
% |
| 377 |
% \subsubsection*{Using Macros in File Information String} |
| 378 |
% \begin{example} |
| 379 |
% \ProvidesPackageSVN |
| 380 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 381 |
% [v1.\Rev Example Description] |
| 382 |
% \end{example} |
| 383 |
% |
| 384 |
% \subsubsection*{Adding Text to Default Information} |
| 385 |
% \begin{example} |
| 386 |
% \ProvidesPackageSVN |
| 387 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 388 |
% [v1.\Rev Extra Text \revinfo] |
| 389 |
% \end{example} |
| 390 |
% |
| 391 |
% \subsection*{Getting the File Information} |
| 392 |
% \def\exampleaftertext{results in:} |
| 393 |
% \def\ProvidesPackage#1[#2]{}% |
| 394 |
% |
| 395 |
% \begin{example} |
| 396 |
% \ProvidesPackageSVN |
| 397 |
% {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $} |
| 398 |
% [v1.\Rev Extra Text \revinfo] |
| 399 |
% \GetFileInfoSVN* |
| 400 |
% % ... |
| 401 |
% \begin{tabular}{l@{\ :\ \ }l} |
| 402 |
% File Name & \filename \\ |
| 403 |
% File Base Name & \filebase \\ |
| 404 |
% File Extension & \fileext \\ |
| 405 |
% File Date & \filedate \\ |
| 406 |
% File Revision & \filerev \\ |
| 407 |
% File Version & \fileversion \\ |
| 408 |
% File Info & \fileinfo \\ |
| 409 |
% \end{tabular} |
| 410 |
% \end{example} |
| 411 |
% \noindent |
| 412 |
% The correct package file extension `|.sty|' for \cs{fileext} can be forced by |
| 413 |
% using |[\filebase.sty]| as a first optional argument. |
| 414 |
% |
| 415 |
% \endgroup |
| 416 |
% \StopEventually{} |
| 417 |
% \manualnewpage |
| 418 |
% \section{Implementation} |
| 419 |
% |
| 420 |
% \iffalse |
| 421 |
%<*package> |
| 422 |
% \fi |
| 423 |
% |
| 424 |
% \begin{macrocode} |
| 425 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 426 |
% \end{macrocode} |
| 427 |
% |
| 428 |
% \begin{macro}{\ProvidesClassSVN} |
| 429 |
% Calls the generic macro with the original LaTeX macro and the string to be |
| 430 |
% used as filename. |
| 431 |
% \begin{macrocode} |
| 432 |
\def\ProvidesClassSVN{% |
| 433 |
\svnprov@generic\ProvidesClass{\svnprov@filebase@}% |
| 434 |
} |
| 435 |
% \end{macrocode} |
| 436 |
% \end{macro} |
| 437 |
% |
| 438 |
% \begin{macro}{\ProvidesFileSVN} |
| 439 |
% Calls the generic macro with the original LaTeX macro and the string to be |
| 440 |
% used as filename. |
| 441 |
% \begin{macrocode} |
| 442 |
\def\ProvidesFileSVN{% |
| 443 |
\svnprov@generic\ProvidesFile{\svnprov@filebase@.\svnprov@fileext@}% |
| 444 |
} |
| 445 |
% \end{macrocode} |
| 446 |
% \end{macro} |
| 447 |
% |
| 448 |
% \begin{macro}{\ProvidesPackageSVN} |
| 449 |
% Calls the generic macro with the original LaTeX macro and the string to be |
| 450 |
% used as filename. |
| 451 |
% \begin{macrocode} |
| 452 |
\def\ProvidesPackageSVN{% |
| 453 |
\svnprov@generic\ProvidesPackage{\svnprov@filebase@}% |
| 454 |
} |
| 455 |
% \end{macrocode} |
| 456 |
% \end{macro} |
| 457 |
% |
| 458 |
% \begin{macro}{\svnprov@generic} |
| 459 |
% Stores the arguments (1: original macro, 2: file mask (full filename if only |
| 460 |
% base is used?)). Then tests if a explicit file name was given as optional |
| 461 |
% argument. If not the file name from the SVN Id string is used. |
| 462 |
% \begin{macrocode} |
| 463 |
\def\svnprov@generic#1#2{% |
| 464 |
\def\svnprov@ltxprov{#1}% |
| 465 |
\def\svnprov@filemask{#2}% |
| 466 |
\begingroup |
| 467 |
\svnprov@catcodes |
| 468 |
\@ifnextchar{[}% |
| 469 |
{\svnprov@getid}% |
| 470 |
{\svnprov@getid[\svnprov@svnfilename]}% |
| 471 |
} |
| 472 |
% \end{macrocode} |
| 473 |
% \end{macro} |
| 474 |
% |
| 475 |
% \begin{macro}{\svnprov@catcodes} |
| 476 |
% Sets the normal catcodes for all characters required by the |getid| macro. |
| 477 |
% \begin{macrocode} |
| 478 |
\def\svnprov@catcodes{% |
| 479 |
\catcode`\ =10% |
| 480 |
\catcode`\$=3% |
| 481 |
\@makeother\:% |
| 482 |
\@makeother\-% |
| 483 |
} |
| 484 |
% \end{macrocode} |
| 485 |
% \end{macro} |
| 486 |
% |
| 487 |
% Enforce normal catcodes for the definition of the |Id| scanning macros. |
| 488 |
% This makes sure that all scan patterns have the same catcodes during definition and execution. |
| 489 |
% \begin{macrocode} |
| 490 |
\begingroup |
| 491 |
\svnprov@catcodes |
| 492 |
% \end{macrocode} |
| 493 |
% |
| 494 |
% \begin{macro}{\svnprov@getid} |
| 495 |
% Saves first argument as filename and calls the scan macro with the second. |
| 496 |
% A fall-back string is provided to avoid \TeX\ parsing errors. |
| 497 |
% \begin{macrocode} |
| 498 |
\gdef\svnprov@getid[#1]#2{% |
| 499 |
\endgroup |
| 500 |
\def\svnprov@filename{#1}% |
| 501 |
\svnprov@scanid #2\relax $% |
| 502 |
Id: unknown.xxx 0 0000-00-00 00:00:00Z user $\empty\svnprov@endmarker |
| 503 |
} |
| 504 |
% \end{macrocode} |
| 505 |
% \end{macro} |
| 506 |
% |
| 507 |
% \begin{macro}{\svnprov@scanid} |
| 508 |
% Parses the Id string and tests if it is correct (\#1=empty, \#8=\cs{relax}). |
| 509 |
% If correct the values are stored in macros and the next macro is called. |
| 510 |
% Otherwise a warning message is printed. In both cases any remaining text of |
| 511 |
% the parsing procedure is gobbled before the next step. |
| 512 |
% \begin{macrocode} |
| 513 |
\gdef\svnprov@scanid#1$% |
| 514 |
Id: #2 #3 #4-#5-#6 #7 $#8{% |
| 515 |
\def\next{% |
| 516 |
\begingroup |
| 517 |
\PackageWarning{svn-prov}{Invalid SVN Id line found! File name might be |
| 518 |
'#2' or '\expandafter\strip@prefix\meaning\@filef@und'. This occured}{}{}{}% |
| 519 |
\endgroup |
| 520 |
\svnprov@gobbleopt |
| 521 |
}% |
| 522 |
\ifx\relax#1\relax |
| 523 |
\ifx\relax#8\empty |
| 524 |
\def\svnprov@svnfilename{#2}% |
| 525 |
\svnprov@splitfilename{#2}% |
| 526 |
\def\svnprov@filerev@{#3}% |
| 527 |
\def\svnprov@filedate@{#4/#5/#6}% |
| 528 |
\def\svnprov@filetoday@{\svnprov@@today{#4}{#5}{#6}}% |
| 529 |
\def\next{\begingroup\svnprov@catcodes\svnprov@buildstring}% |
| 530 |
\fi |
| 531 |
\fi |
| 532 |
\expandafter\next\svnprov@gobblerest |
| 533 |
}% $ |
| 534 |
% \end{macrocode} |
| 535 |
% \end{macro} |
| 536 |
% |
| 537 |
% End of area with enforced catcodes. |
| 538 |
% \begin{macrocode} |
| 539 |
\endgroup |
| 540 |
% \end{macrocode} |
| 541 |
% |
| 542 |
% \begin{macro}{\svnprov@@today} |
| 543 |
% Prints \cs{today} with the given date. |
| 544 |
% \begin{macrocode} |
| 545 |
\def\svnprov@@today#1#2#3{% |
| 546 |
{\year#1\month#2\day#3\relax\today}% |
| 547 |
} |
| 548 |
% \end{macrocode} |
| 549 |
% \end{macro} |
| 550 |
% |
| 551 |
% \begin{macro}{\svnprov@splitfilename} |
| 552 |
% Expands the argument and initialises the file base macro before it calls the |
| 553 |
% next macro with the expanded argument and a dot to protect for \TeX\ parsing |
| 554 |
% errors. The \cs{relax} is used as end marker. |
| 555 |
% \begin{macrocode} |
| 556 |
\def\svnprov@splitfilename#1{% |
| 557 |
\edef\g@tempa{#1}% |
| 558 |
\let\svnprov@filebase@\@gobble |
| 559 |
\expandafter |
| 560 |
\svnprov@splitfilename@\g@tempa.\relax |
| 561 |
} |
| 562 |
% \end{macrocode} |
| 563 |
% \end{macro} |
| 564 |
% |
| 565 |
% \begin{macro}{\svnprov@splitfilename@} |
| 566 |
% The second argument is tested if it is empty (end of file name reached). If |
| 567 |
% not empty the first argument is concatenated to the file base macro and the |
| 568 |
% macro calls itself on the second argument. This ensures correct handling of |
| 569 |
% file name which contain multiple dots. |
| 570 |
% |
| 571 |
% If the second argument was empty it is tested if the file base name is still |
| 572 |
% in its initialised state which means that there is no file extension. Then the |
| 573 |
% file base is defined to the first argument and the extension as empty. |
| 574 |
% Otherwise the file extension is defined to the first argument and the file |
| 575 |
% base macro is unchanged because it is already correct. |
| 576 |
% \begin{macrocode} |
| 577 |
\def\svnprov@splitfilename@#1.#2\relax{% |
| 578 |
\if& |
| 579 |
\ifx\svnprov@filebase@\@gobble |
| 580 |
\gdef\svnprov@filebase@{#1}% |
| 581 |
\gdef\svnprov@fileext@{}% |
| 582 |
\else |
| 583 |
\gdef\svnprov@fileext@{#1}% |
| 584 |
\fi |
| 585 |
\let\next\relax |
| 586 |
\else |
| 587 |
\xdef\svnprov@filebase@{\svnprov@filebase@.#1}% |
| 588 |
\def\next{\svnprov@splitfilename@#2\relax}% |
| 589 |
\fi |
| 590 |
\next |
| 591 |
} |
| 592 |
% \end{macrocode} |
| 593 |
% \end{macro} |
| 594 |
% |
| 595 |
% \begin{macro}{\svnprov@gobblerest} |
| 596 |
% Simply gobbles everything up to the next endmarker. |
| 597 |
% \begin{macrocode} |
| 598 |
\def\svnprov@gobblerest#1\svnprov@endmarker{} |
| 599 |
% \end{macrocode} |
| 600 |
% \end{macro} |
| 601 |
% |
| 602 |
% \begin{macro}{\svnprov@endmarker} |
| 603 |
% This is the end marker which should never be expanded. However it gets defined |
| 604 |
% and set to an unique definition which will gobble itself if ever expanded. |
| 605 |
% \begin{macrocode} |
| 606 |
\def\svnprov@endmarker{\@gobble{svn-prov endmarker}} |
| 607 |
% \end{macrocode} |
| 608 |
% \end{macro} |
| 609 |
% |
| 610 |
% \begin{macro}{\svnprov@gobbleopt} |
| 611 |
% Gobbles an optional argument if present. |
| 612 |
% \begin{macrocode} |
| 613 |
\newcommand*\svnprov@gobbleopt[1][]{} |
| 614 |
% \end{macrocode} |
| 615 |
% \end{macro} |
| 616 |
% |
| 617 |
% \begin{macro}{\svnprov@defaultdesc} |
| 618 |
% Default description text to be used. Does not include the file date which is |
| 619 |
% prepended later. |
| 620 |
% \begin{macrocode} |
| 621 |
\def\svnprov@defaultdesc{% |
| 622 |
(SVN Rev:\space\svnprov@filerev@)% |
| 623 |
} |
| 624 |
% \end{macrocode} |
| 625 |
% \end{macro} |
| 626 |
% |
| 627 |
% \begin{macro}{\svnprov@buildstring} |
| 628 |
% First aliases the internal macro to user-friendly names and then builds the |
| 629 |
% info string. Finally the stored original LaTeX macro is called with the |
| 630 |
% filename and information. |
| 631 |
% \begin{macrocode} |
| 632 |
\newcommand*\svnprov@buildstring[1][\svnprov@defaultdesc]{% |
| 633 |
\@ifnextchar{[}% |
| 634 |
{\svnprov@buildstring@{#1}}% |
| 635 |
{\svnprov@buildstring@{#1}[\relax]}% |
| 636 |
} |
| 637 |
\def\svnprov@buildstring@#1[#2]{% |
| 638 |
\endgroup |
| 639 |
\begingroup |
| 640 |
\let\rev\svnprov@filerev@ |
| 641 |
\let\filerev\svnprov@filerev@ |
| 642 |
\def\Rev{\rev\space}% |
| 643 |
\let\revinfo\svnprov@defaultdesc |
| 644 |
\let\filebase\svnprov@filebase@ |
| 645 |
\let\fileext\svnprov@fileext@ |
| 646 |
\ifx\fileversion\@undefined |
| 647 |
\def\fileversion{v0.0}% |
| 648 |
\fi |
| 649 |
\edef\filename{\filebase.\fileext}% |
| 650 |
\xdef\svnprov@filename{\svnprov@filename}% |
| 651 |
\ifx\svnprov@filename\filename\else |
| 652 |
\svnprov@splitfilename{\svnprov@filename}% |
| 653 |
\fi |
| 654 |
\let\filename\svnprov@filename |
| 655 |
\ifx\relax#2\empty |
| 656 |
\xdef\svnprov@fileinfo@{#1}% |
| 657 |
\svnprov@getversion{#1}% |
| 658 |
\global\let\svnprov@filedesc@\svnprov@filedesc@ |
| 659 |
\global\let\svnprov@fileinfo@\svnprov@fileinfo@ |
| 660 |
\else |
| 661 |
\xdef\svnprov@fileversion@{#1}% |
| 662 |
\xdef\svnprov@filedesc@{#2}% |
| 663 |
\xdef\svnprov@fileinfo@{#1 #2}% |
| 664 |
\fi |
| 665 |
\endgroup |
| 666 |
\svnprov@ltxprov{\svnprov@filemask}% |
| 667 |
[\svnprov@filedate@ |
| 668 |
\ifx\svnprov@fileinfo@\empty\else |
| 669 |
\space |
| 670 |
\svnprov@fileinfo@ |
| 671 |
\fi |
| 672 |
]% |
| 673 |
} |
| 674 |
% \end{macrocode} |
| 675 |
% \end{macro} |
| 676 |
% |
| 677 |
% \begin{macro}{\GetFileInfoSVN} |
| 678 |
% \changes{v3.}{2010/04/01}{Added non-star version.} |
| 679 |
% The macro provides the file information of the given file, or (the star version) the last file which called one of the above \cs{Provides\ldots} macros. |
| 680 |
% For this the internal macros are simply copied to user-friendly names. |
| 681 |
% |
| 682 |
% This macro is inspired by the macro \cs{GetFileInfo}\marg{file name} from the |
| 683 |
% \texttt{doc} package. |
| 684 |
% \begin{macrocode} |
| 685 |
\def\GetFileInfoSVN#1{% |
| 686 |
\ifx*#1\relax |
| 687 |
\let\filebase\svnprov@filebase@ |
| 688 |
\let\fileext\svnprov@fileext@ |
| 689 |
\let\filename\svnprov@filename |
| 690 |
\let\filedate\svnprov@filedate@ |
| 691 |
\let\filerev\svnprov@filerev@ |
| 692 |
\let\fileversion\svnprov@fileversion@ |
| 693 |
\let\fileinfo\svnprov@filedesc@ |
| 694 |
\let\filetoday\svnprov@filetoday@ |
| 695 |
\else |
| 696 |
% \end{macrocode} |
| 697 |
% Given argument could be filename or short name. |
| 698 |
% If a short name exists for the argument it was a filename is is defined as such, |
| 699 |
% otherwise the filename is read from the |\|\meta{short name}|@long| macro. |
| 700 |
% \begin{macrocode} |
| 701 |
\expandafter\let\expandafter\@gtempa\csname#1@short\endcsname% |
| 702 |
\ifx\@gtempa\relax |
| 703 |
\def\@gtempa{#1}% |
| 704 |
\expandafter\let\expandafter\filename\csname#1@long\endcsname |
| 705 |
\else |
| 706 |
\edef\filename{#1}% |
| 707 |
\fi |
| 708 |
\expandafter\let\expandafter\filebase\csname\@gtempa @base\endcsname |
| 709 |
\expandafter\let\expandafter\fileext \csname\@gtempa @ext\endcsname |
| 710 |
\expandafter\let\expandafter\filedate\csname\@gtempa @date\endcsname |
| 711 |
\expandafter\let\expandafter\filerev \csname\@gtempa @rev\endcsname |
| 712 |
\expandafter\let\expandafter\fileversion\csname\@gtempa @version\endcsname |
| 713 |
\expandafter\let\expandafter\fileinfo\csname\@gtempa @info\endcsname |
| 714 |
\expandafter\let\expandafter\filetoday\csname\@gtempa @today\endcsname |
| 715 |
\fi |
| 716 |
} |
| 717 |
% \end{macrocode} |
| 718 |
% \end{macro} |
| 719 |
% |
| 720 |
% \begin{macro}{\DefineFileInfoSVN} |
| 721 |
% Defines macros in the form |\|\meta{filename}|@|\meta{xxx}, where \meta{xxx} is |date|, |version|, |rev|(ision), |info|, (file name)|base| and |ext|(ension). |
| 722 |
% \changes{v3.}{2010/04/01}{Added file name `base' and 'ext'(ension).} |
| 723 |
% \begin{macrocode} |
| 724 |
\newcommand*\DefineFileInfoSVN[1][\svnprov@filemask]{% |
| 725 |
\expandafter |
| 726 |
\edef\csname\svnprov@filemask @short\endcsname{#1}% |
| 727 |
\expandafter |
| 728 |
\edef\csname#1@long\endcsname{\svnprov@filemask}% |
| 729 |
\expandafter |
| 730 |
\let\csname#1@base\endcsname\svnprov@filebase@ |
| 731 |
\expandafter |
| 732 |
\let\csname#1@ext\endcsname\svnprov@fileext@ |
| 733 |
\expandafter |
| 734 |
\let\csname#1@date\endcsname\svnprov@filedate@ |
| 735 |
\expandafter |
| 736 |
\let\csname#1@version\endcsname\svnprov@fileversion@ |
| 737 |
\expandafter |
| 738 |
\let\csname#1@rev\endcsname\svnprov@filerev@ |
| 739 |
\expandafter |
| 740 |
\let\csname#1@info\endcsname\svnprov@filedesc@ |
| 741 |
\expandafter |
| 742 |
\let\csname#1@today\endcsname\svnprov@filetoday@ |
| 743 |
} |
| 744 |
% \end{macrocode} |
| 745 |
% \end{macro} |
| 746 |
% |
| 747 |
% \begin{macro}{\svnprov@getversion} |
| 748 |
% Checks if the argument (a file description) starts with `|v|'. If so |
| 749 |
% everything until the first space is taken as version number. Otherwise |
| 750 |
% the whole text is taken as description without version. |
| 751 |
% Special care is taken to avoid a parser error if there is no space included. |
| 752 |
% \changes{v3.}{2010/04/01}{Changed to look for leading `v' not just everything up to the first space.} |
| 753 |
% \begin{macrocode} |
| 754 |
\def\svnprov@getversion#1{% |
| 755 |
\edef\@tempa{#1\space}% |
| 756 |
\expandafter\svnprov@@getversion\@tempa\svnprov@endmarker |
| 757 |
} |
| 758 |
\def\svnprov@@getversion{% |
| 759 |
\@ifnextchar{v}% |
| 760 |
{\svnprov@getversion@}% |
| 761 |
{\svnprov@getversion@@}% |
| 762 |
} |
| 763 |
\def\svnprov@getversion@#1 #2\svnprov@endmarker{% |
| 764 |
\gdef\svnprov@fileversion@{#1}% |
| 765 |
\ifx&% |
| 766 |
\gdef\svnprov@filedesc@{}% |
| 767 |
\else |
| 768 |
\xdef\svnprov@filedesc@{\svnprov@zapspace#2\svnprov@endmarker}% |
| 769 |
\fi |
| 770 |
} |
| 771 |
\def\svnprov@getversion@@#1 \svnprov@endmarker{% |
| 772 |
\gdef\svnprov@fileversion@{}% |
| 773 |
\gdef\svnprov@filedesc@{#1}% |
| 774 |
} |
| 775 |
\def\svnprov@zapspace#1 \svnprov@endmarker{#1} |
| 776 |
% \end{macrocode} |
| 777 |
% \end{macro} |
| 778 |
% |
| 779 |
% Finally, call the macros for this package itself. |
| 780 |
% \begin{macrocode} |
| 781 |
\ProvidesPackageSVN{$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}% |
| 782 |
[\svnprov@version\space Package Date/Version from SVN Keywords] |
| 783 |
\DefineFileInfoSVN[svnprov] |
| 784 |
% \end{macrocode} |
| 785 |
% |
| 786 |
% \iffalse |
| 787 |
%</package> |
| 788 |
% \fi |
| 789 |
% |
| 790 |
% \Finale |
| 791 |
|