-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassversion-alpha.sty
More file actions
215 lines (183 loc) · 7.35 KB
/
Copy pathclassversion-alpha.sty
File metadata and controls
215 lines (183 loc) · 7.35 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{classversion-alpha}[2022/02/03 v0.1.0 Used for
versioning classes]
\RequirePackage{xparse}
\RequirePackage{pgf}
\RequirePackage{readprov}
\RequirePackage{alphalph}
\RequirePackage{ifthen}
% Typesetting commands
\providecommand*{\file}[1]{\texttt {#1}}
\providecommand*{\Lpack}[1]{\textsf {#1}}
\def\classname#1{\gdef\@classname{#1} \title{Installation check and
release information for
\Lpack{\@classname} up to release \classversion@currentRelease}}
%Counts number of releases
\newcounter{classversion@release}
\setcounter{classversion@release}{0}
%Counts number of files - reset by new release
\newcounter{classversion@file}
\setcounter{classversion@file}{0}
%Scratch counters
\newcounter{classversion@int}
\newcounter{classversion@iint}
%This preamble command signifies the beginning of a new release
\ExplSyntaxOn
\NewDocumentCommand{\NewRelease}{m m O{\relax}}{
\gdef\classversion@currentRelease{#1} %This provides the current
%release version number
\stepcounter{classversion@release}
%We define a command to return the release version number given a
%lower case letter representing the release number
\cs_new:cpx
{release\alphalph{\theclassversion@release}} {#1}
%And the release date
\cs_new:cpx
{date\alphalph{\theclassversion@release}} {#2}
%And the change summary
\cs_new:cpx
{summary\alphalph{\theclassversion@release}} {#3}
%We reset this counter to zero
\setcounter{classversion@file}{0}
%We define a counter for this release to count its files and set it
%to zero
\newcounter{classversion@filesinrelease
\alphalph{\theclassversion@release}}
\setcounter{classversion@filesinrelease
\alphalph{\theclassversion@release}}{0}
}
%This converts a release number to a release version number
\NewDocumentCommand{\classversion@thisreleasenumber}{m}
{\csname release\alphalph{#1}\endcsname}
%This converts a release number to a release date
\NewDocumentCommand{\classversion@thisreleasedate}{m}
{\csname date\alphalph{#1}\endcsname}
%This converts a release number to a change summary
\NewDocumentCommand{\classversion@thisreleasesummary}{m}
{\csname summary\alphalph{#1}\endcsname}
%This returns the number of files in a release given the release number
\NewDocumentCommand{\classversion@filesinthisrelease}{m}{
\csname theclassversion@filesinrelease\alphalph{#1} \endcsname}
%This preamble command follows \NewRelease and signifies a file that is
%part of that release
\NewDocumentCommand{\IncludeFileInRelease}{m m}{
\stepcounter{classversion@file}
\cs_new:cpx
{file\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{#1}
\cs_new:cpx
{eversion\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{\ignorespaces#2\ignorespaces}
\bool_new:c
{exists\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
\IfFileExists{#1}{
\ReadFileInfos{#1}
\cs_new:cpx
{version\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{\ignorespaces\UseVersionOf{#1}\ignorespaces}
\cs_new:cpx
{date\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{\UseDateOf{#1}}
\bool_set_true:c
{exists\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
}{
\cs_new:cpn
{version\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{\textcolor{red}{version\space missing}}
\cs_new:cpn
{date\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
{\textcolor{red}{date\space missing}}
\bool_set_false:c
{exists\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@file}}
}
\stepcounter{classversion@filesinrelease\alphalph{\theclassversion@release}}
}
\ExplSyntaxOff
%This prints a section to check the installation compared to the latest
%release
\NewDocumentCommand{\installation}{O{Installation check}}{
\section*{#1}
This installation of \textsf{\@classname}
consists of the following
\classversion@filesinthisrelease{\theclassversion@release}\space
files:
\begingroup
\setcounter{classversion@int}{0}
\begin{enumerate}
\loop
\item
\stepcounter{classversion@int}
\file{\csname
file\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@int}\endcsname}~
\csname
version\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@int}\endcsname,
dated
\csname
date\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@int}\endcsname
{\color{red}(expecting \csname
eversion\AlphAlph{\theclassversion@release}\alphalph{\theclassversion@int}\endcsname)}
\ifnum\theclassversion@int<\classversion@filesinthisrelease{\theclassversion@release}
\repeat
\end{enumerate}
\endgroup
}
%This prints a section to show latest release
\NewDocumentCommand{\latestrelease}{O{Release manifest}}{
\section*{#1}
This release (\classversion@currentRelease) of \Lpack{\@classname}
consists of the following
\classversion@filesinthisrelease{\theclassversion@release}\space
files:
\begingroup
\setcounter{classversion@int}{0}
\begin{enumerate}
\loop
\item
\stepcounter{classversion@int}
\file{\csname file\AlphAlph{\theclassversion@release}
\alphalph{\theclassversion@int}\endcsname}~
\csname eversion\AlphAlph{\theclassversion@release}
\alphalph{\theclassversion@int}\endcsname
\ifnum\theclassversion@int<\classversion@filesinthisrelease{\theclassversion@release}
\repeat
\end{enumerate}
\endgroup
}
%This prints a section to show a specific release
\NewDocumentCommand{\thisrelease}{O{Release
\classversion@thisreleasenumber{#2}, dated
\classversion@thisreleasedate{#2}} m}{
\section*{#1}
\paragraph{Change summary}
\classversion@thisreleasesummary{#2}
\paragraph*{Manifest}
This release consists of the following
\ifnum\classversion@filesinthisrelease{#2}>1
\classversion@filesinthisrelease{#2}\space files\else file\fi:
\begingroup
\setcounter{classversion@int}{0}
\begin{enumerate}
\loop
\item
\stepcounter{classversion@int}
\file{\csname
file\AlphAlph{#2}\alphalph{\theclassversion@int}\endcsname}~\csname
eversion\AlphAlph{#2}\alphalph{\theclassversion@int}\endcsname
\ifnum\theclassversion@int<
\classversion@filesinthisrelease{#2}
\repeat
\end{enumerate}
\endgroup
}
%This prints a section to show each release, starting with the most
%recent
\NewDocumentCommand{\releasehistory}{}{
\begingroup
\setcounter{classversion@iint}{\theclassversion@release}
\loop
\thisrelease{\theclassversion@iint}
\addtocounter{classversion@iint}{-1}
\ifnum\theclassversion@iint>0
\repeat
\endgroup
}