Debian Codegraph @

texmf-dist/source/latex/counttexruns/counttexruns.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2012 by Robin Schneider <[email protected]>
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Robin Schneider.
16 %
17 % This work consists of the files counttexruns.dtx and counttexruns.ins
18 % and the derived filebase counttexruns.sty.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{counttexruns.dtx}
25 %</driver>
26 %<package>%% See file 'counttexruns.dtx' for copyright and licence.
27 %<package>\NeedsTeXFormat{LaTeX2e}[1998/12/01]
28 %<package>\ProvidesPackage{counttexruns}
29 %<*package>
30 [2012/08/31 v1.00a Count compilations of a document]
31 %</package>
32 %
33 %<*driver>
34 \documentclass[english]{ltxdoc}
35 \newcommand{\PackageURL}{https://github.com/ypid/latex-packages/tree/master/counttexruns}
36 \newcommand{\PackageCTANURL}{http://www.ctan.org/pkg/counttexruns}
37 \newcommand{\PackageAuthor}{Robin Schneider}
38 \newcommand{\PackageAuthorEmail}{[email protected]}
39 \newcommand{\PackageName}{\PrintPackage{count\TeX runs}}
40 \newcommand{\PrintPackage}[1]{\textsf{#1}}
41 \usepackage{counttexruns}
42 \usepackage{
43 babel,
44 csquotes,
45 xcolor,
46 url,
47 hypdoc,
48 ifthen,
49 }
50 \GetFileInfo{counttexruns.dtx}
51 \hypersetup{
52 pdftitle={A manual for \PackageName},
53 pdfauthor={\PackageAuthor{} <\PackageAuthorEmail>},
54 pdfsubject={\fileinfo},
55 baseurl={\PackageURL},
56 pdfkeywords={This document corresponds to \PackageName~\fileversion,
57 dated \filedate}
58 }
59
60 \title{The \PackageName{} package\thanks{This document
61 corresponds to \PackageName~\fileversion, dated \filedate.}}
62 \author{\PackageAuthor \\
63 \texttt{\href{mailto:\PackageAuthorEmail?subject=LaTeX package counttexruns}%
64 {\PackageAuthorEmail}%
65 }%
66 }
67
68 \EnableCrossrefs
69 \CodelineIndex
70 \RecordChanges
71 \begin{document}
72 \DocInput{counttexruns.dtx}
73 \PrintChanges
74 \PrintIndex
75 \end{document}
76 %</driver>
77 % \fi
78 %
79 % \CheckSum{52}
80 %
81 % \CharacterTable
82 % {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
83 % 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
84 % Digits \0\1\2\3\4\5\6\7\8\9
85 % Exclamation \! Double quote \" Hash (number) \#
86 % Dollar \$ Percent \% Ampersand \&
87 % Acute accent \' Left paren \( Right paren \)
88 % Asterisk \* Plus \+ Comma \,
89 % Minus \- Point \. Solidus \/
90 % Colon \: Semicolon \; Less than \<
91 % Equals \= Greater than \> Question mark \?
92 % Commercial at \@ Left bracket \[ Backslash \\
93 % Right bracket \] Circumflex \^ Underscore \_
94 % Grave accent \` Left brace \{ Vertical bar \|
95 % Right brace \} Tilde \~}
96 %
97 % \changes{1.00}{2012/08/27}{Initial version}
98 % \changes{1.00a}{2012/08/31}{Minor details fixed}
99 %
100 % \DoNotIndex{\RequirePackage, \DeclareOption, \ProcessOptions}
101 % \DoNotIndex{\PackageWarning, \MessageBreak}
102 % \DoNotIndex{\DeclareStringOption, \ProcessLocalKeyvalOptions}
103 % \DoNotIndex{\DeclareRobustCommand, \newcommand, \renewcommand}
104 % \DoNotIndex{\newenvironment}
105 % \DoNotIndex{\if, \else, \fi, \ifcase, \or, \ifthenelse, \AND, \value, \relax}
106 % \DoNotIndex{\%, \IfFileExists, \immediate, \arabic}
107 %% ^^A \% is ignored ...
108 % \DoNotIndex{\@currname, \newcounter, \setcounter}
109 % \DoNotIndex{\endinput}
110 %
111 % \maketitle
112 %
113 % \phantomsection
114 % \addcontentsline{toc}{section}{\abstractname}
115 % \begin{abstract}
116 % The \PackageName{} package counts how often a \LaTeX{} document is
117 % compiled.\\
118 % Location on CTAN: \url{\PackageCTANURL} \\
119 % Fork me on GitHub: \url{\PackageURL} \end{abstract}
120 %
121 % \tableofcontents
122 %
123 % \section{Introduction}
124 % From a statistical perspective you maybe want to know how often you compiled
125 % a document. This is exactly the task I wrote this package for. For a few
126 % years I used a bash script and -shell-escape to do this but I decided to
127 % write this small package to do the trick a little nicer.
128 %
129 % \section{Usage}
130 % Just load the package placing
131 % \begin{quote}
132 % |\usepackage{counttexruns}|
133 % \end{quote}
134 % in the preamble of your \LaTeXe{} source file.
135 %
136 % The counter will be stored in a file with the same prefix as your document
137 % (|\jobname|) but with the file extension \enquote{.ctr}. You can change the
138 % default extension by setting it as package option like this:
139 % \begin{quote}
140 % |\usepackage[extension=ctr]{counttexruns}|
141 % \end{quote}
142 %
143 % \DescribeMacro{\thecounttexruns}
144 % To print the count you can use the macro |\thecounttexruns|. You can also use
145 % and even change the \LaTeX{} counter \enquote{counttexruns}. This will not disturb
146 % \PackageName.
147 %
148 % By the way this documentation was \thecounttexruns{}
149 % time\ifthenelse{\equal{\value{counttexruns}}{1}}{}{s} compiled during
150 % development.
151 %
152 % You can use the package \PrintPackage{ifthen} for checking if a counter is
153 % one: \\ |time\ifthenelse{\equal{\value{counttexruns}}{1}}{}{s}|
154 %
155 %
156 % \StopEventually{}
157 %
158 % \section{Implementation}
159 % \iffalse
160 %<*package>
161 % \fi
162 % \begin{macro}{\thecounttexruns}
163 % First a new counter and file handle is declared.
164 % The |\newcounter| will also declare the macro |\thecounttexruns|.
165 % \begin{macrocode}
166 \newcounter{counttexruns}
167 \newwrite\@counttexrunsfile
168 % \end{macrocode}
169 % Then the package options are processed.
170 % \begin{macrocode}
171 \RequirePackage{kvoptions}
172 \DeclareStringOption[ctr]{extension}
173 \ProcessLocalKeyvalOptions*
174 % \end{macrocode}
175 % \end{macro}
176 % Here it is checked if the file already exists and if that is the case the
177 % number of compile events will be stored in the \LaTeX{} counter
178 % \enquote{counttexruns}.
179 % \begin{macrocode}
180 \IfFileExists{\jobname.\counttexruns@extension}{
181 \immediate\openin\@counttexrunsfile=\jobname.\counttexruns@extension
182 \immediate\read\@counttexrunsfile to \@counttexruns
183 \immediate\read\@counttexrunsfile to \@counttexruns
184 \immediate\closein\@counttexrunsfile
185 \setcounter{counttexruns}{\@counttexruns}
186 }{}
187 % \end{macrocode}
188 % Here the counter \enquote{counttexruns} is increment by one.
189 % \begin{macrocode}
190 \stepcounter{counttexruns}
191 % \end{macrocode}
192 % At this point the new count is written back to the file.
193 % \begin{macrocode}
194 \immediate\openout\@counttexrunsfile=\jobname.\counttexruns@extension
195 \catcode`\%=11\relax
196 \immediate\write\@counttexrunsfile{%% This file
197 '\jobname.\counttexruns@extension' was generated by the package counttexruns}
198 \catcode`\%=14\relax
199 \immediate\write\@counttexrunsfile{\arabic{counttexruns}}
200 \immediate\closeout\@counttexrunsfile
201 % \end{macrocode}
202 % Well, thats is~\dots
203 % \begin{macrocode}
204 \endinput
205 % \end{macrocode}
206 %
207 % \iffalse
208 %</package>
209 % \fi
210 %
211 % \Finale
212 \endinput