-
Notifications
You must be signed in to change notification settings - Fork 0
/
fancyreqs.sty
300 lines (246 loc) · 10.2 KB
/
fancyreqs.sty
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{core/fancyreqs}[2020/06/11 Fancy Requirements Document Framework]
% Note: Requires nameref package
% No, I don't remember why.
\PackageInfo{fancydoc}{Loading Framework for Requirement Specifications Document}
\RequirePackage{core/fancydoc} % not sure how i feel about this
\RequirePackage{marginnote}
\RequirePackage{booktabs}
\RequirePackage{xcolor}
% We don't really use this package, but we need cleveref, and it has to be loaded after amsmath if it's used, so we are going to preemptively atteck!
\RequirePackage{amsmath}
\RequirePackage[nameinlink]{cleveref}
\RequirePackage{tocloft}
% ==============================================
% ==============================================
% Initialize Framework
% If run before, there will be things to remember
\InputIfFileExists{reqsData.tex}{
\PackageInfo{fancyreqs}{Reading in previous requirement definitions.}
} {
\PackageInfo{fancyreqs}{No previous requirement definitions.}
}
% Processing files
% Create a few files necessary for great magick
% Entry for each requirement created in the document. For giggles.
% After compilation, for information.
\newwrite\fancyreq@defs
\immediate\openout\fancyreq@defs=reqsUsed.tex
% Create a custom table to display verification methods for each requirement
\newwrite\fancyreq@table
\immediate\openout\fancyreq@table=reqsTable.tex
% Record references for use anywhere in the document.
\newwrite\fancyreq@data
\immediate\openout\fancyreq@data=reqsData.tex
\newcommand{\placeReqTable}{
% Can't read without closing it first
\immediate\closeout\fancyreq@table
% renew document reference commands for better formatting
% \renewcommand{\rd}[1]{$[\text{LLNL-RD}]_{##1}$}
% \renewcommand{\icd}[1]{[LLNL-ICD] \textit{##1}}
% \renewcommand{\fuzestd}[1]{[1316F] \S~##1}
% \renewcommand{\mcd}{[LLNL-DWG]}
% \renewcommand{\tdone}[1]{[CPS-TD-001B] \S~##1}
% \renewcommand{\tdtwo}[1]{[CPS-TD-002B] \S~##1}
\def\arraystretch{1.3}
\begin{landscape}
\centering
\begin{longtable}{lp{2.25in} llcl}
\caption[Verification Matrix]{Verification Cross-Reference
Matrix\label{vcrm}} \\
\toprule
& & & & & \\
\textbf{Designated} &
\textbf{Origination} &
\textbf{Requirement Name} &
\textbf{Critical Value} &
\textbf{Verify By} &
\textbf{Defined In} \\
& & & & & \\
\midrule
& & & & & \\
\endfirsthead
\caption{Verification Cross-Reference Matrix (continued...)} \\
\toprule
& & & & & \\
\textbf{Designatedn} &
\textbf{Origination} &
\textbf{Requirement Name} &
\textbf{Critical Value} &
\textbf{Verify By} &
\textbf{Defined In} \\
& & & & & \\
\midrule
& & & & & \\
\endhead
% \midrule
& & & & & \\
\hline
& & continued next page... & & & \\
\endfoot
& & & & & \\
\hline
& & This concludes the requirements listing. & & & \\
\endlastfoot
\input{reqsTable.tex}
% \bottomrule
\end{longtable}
% \end{table}
\end{landscape}
}
% ==============================================
% Setup parameters for other packages
% currently unused, but will complain if not defined
\crefname{requirement}{Req. \#}{Reqs. \#}
\crefformat{requirement}{#2\unexpanded{[ESAD\_}#1\unexpanded{]}#3}
% Table of Contents for Requirements
\newcommand{\listreqs}{List of Requirements}
% Declare new type of item (requirements) to track
\newlistof{requirement}{req}{\listreqs}
\addtocontents{req}{~\hfill{\large{}Page}\par}
% \renewcommand{\cftreqfont}{} %
% \renewcommand{\cftreqitemleader}{\bfseries\cftdotfill{\cftreqitemdotsep}}
\renewcommand{\cftreqtitlefont}{\vspace{1cm}\bfseries\scshape\Large\fontfamily{qhv}\selectfont}
\renewcommand{\cftrequirementleader}{}
\renewcommand{\cftrequirementpagefont}{}
\renewcommand{\cftrequirementpresnum}{\bfseries [ESAD\_}
\renewcommand{\cftrequirementaftersnum}{]}
\renewcommand{\cftrequirementaftersnumb}{ \qquad}
\newlength{\mylen} % a "scratch" length
% \settowidth{\mylen}{longtextislong} % extra space
\setlength{\mylen}{0.6in}
% \addtolength{\cftrequirementnumwidth}{\mylen} % add the extra space
\setlength{\cftrequirementnumwidth}{\mylen} % add the extra space
% \renewcommand{\cftreqitemaftersnumb}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For Reference
% Settings for listing all requirements ToC style
% Reference:
% {\cftXfont {\cftXpresnum SNUM\cftXaftersnum\hfil} \cftXaftersnumb TITLE}%
% {\cftXleader}{\cftXpagefont PAGE}\cftXafterpnum\par
% where SNUM is the section number, TITLE is the title text and PAGE is the page number. In the numbered entry the pseudo-code
% {\cftXpresnum SNUM\cftaftersnum\hfil}
% is typeset within a box of width \cftXnumwidth.
% Configure with \setlength
% \setlength{\cftbeforeXskip}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ==============================================
% Somm look and feel
% Marking in right margin annotating ID number and verification method
\newlength{\margunder}
\settowidth{\margunder}{[ESADXX]}
\definecolor{marginmark}{rgb}{0, 0.175, 0.459}
% ==============================================
% Define framework functions
% Constants
% frakking hell i need to figure out this shit vvvvv
\newcommand{\vmethodA}{Analysis}
\newcommand{\vmethodT}{Test}
\newcommand{\vmethodD}{Demonstration}
\newcommand{\vmethodI}{Inspection}
\newcommand{\vmethodS}{Simulation}
% \newcommand{\vmethoda}{Analysis}
% \newcommand{\vmethodt}{Test}
% \newcommand{\vmethodd}{Demonstration}
% \newcommand{\vmethodi}{Inspection}
% \newcommand{\vmethods}{Simulation}
\newcommand{\ngt}{\textbf{NGT}}
\newcommand{\nlt}{\textbf{NLT}}
\newcommand{\@fancy@getFullMethod}[1]{
\newcommand{\methodLetter}{\uppercase{#1}}
\expandafter{\csname vmethod\methodLetter\endcsname}
% \undef is a thing if you need it
}
\newcommand{\@fancy@reqs@recordReq}[4]{%
% Takes keyword, critical value (if any), method of verification, and source (if any)
\PackageInfo{fancyreq}{Creating new requirement with alias [#1].}%
% \immediate\write\fancyreq@defs{oh hai, i'm over at \inputlineno. or is it \whereami.... bah. i dunno. but the keyword is #1}%
% Write definitions for the next time the doc is read in. Existing definitions will be overwritten.
% \unexpanded{\global\@namedef}{fancy@pinDef@aliasToNum@#3}{#1}%
\immediate\write\fancyreq@data{\unexpanded{\global\@namedef{fancy@reqs@aliasNumber@#1@}}{\therequirement}}%
\immediate\write\fancyreq@data{\unexpanded{\global\@namedef{fancy@reqs@aliasValue@#1@}{#2}}}%
\immediate\write\fancyreq@data{\unexpanded{\global\@namedef{fancy@reqs@aliasMethod@#1@}{#3}}}%
\immediate\write\fancyreq@data{\unexpanded{\global\@namedef{fancy@reqs@aliasUpstream@#1@}{#4}}}%
\immediate\write\fancyreq@data{\unexpanded{\global\@namedef{fancy@reqs@aliasLoc@#1@}}{\whereami}}%
% Mark this alias as defined to prevent it from being used elsewhere
% for something else by mistake
\global\@namedef{fancy@reqs@definedAliases@#1}{}%
}
% Enter requirement into list
\newcommand{\newreq}[4]{%
% Check for collision
\ifcsname fancy@reqs@definedAliases@#1\endcsname
\PackageError{fancyreqs}{ Requirement alias '#1' is taken. Please select a different alias.}{Requirements are defined with a unique alias for cross-referencing. Two requirements cannot have the same alias.}%
\else% Do some journalling
\refstepcounter{requirement}%
\label{#1}% Lean on existing reference facilities
\@fancy@reqs@recordReq{#1}{#2}{#3}{#4}%
\normalmarginpar%
\marginnote{
\color{marginmark}
\centering
\textbf{[ESAD\_\therequirement]}\\
{
\vspace{-0.35\baselineskip}
\scriptsize
\expandafter{\csname vmethod#3\endcsname}
}
}%
\if\relax\detokenize{#4}\relax
\else
\footnote{Generated by #4}%
\fi%
% Enter into contents table
\phantomsection%
\addcontentsline{req}{requirement}{
\protect\numberline{\therequirement}
\ignorespaces\nameref{#1}\relax
\protect\Dotfill{0.8 em}\hfil}%
%
\immediate\write\fancyreq@table{
\string\hyperref[#1]{\noexpand\bfseries[ESAD\noexpand\_\therequirement]}
\unexpanded{& #4 &}
\noexpand\scshape\string\nameref*{#1} &
\unexpanded{\bfseries{#2} & #3 &}
\string\hyperref[#1]{\whereami}\noexpand\\}%
\fi}
% Macros to retrieve previously stored requirement information
\newcommand{\reqval}[1]{
\ifcsname fancy@reqs@aliasValue@#1@\endcsname%
\sloppy\textbf{\emph{\csname fancy@reqs@aliasValue@#1@\endcsname}}%
\else% Go get it
\PackageWarning{fancyreqs}{ Attempt to retrieve critical value of requirement
'#1' failed.}{}
{\tbd }
\fi%
}
\newcommand{\reqnum}[1]{
\ifcsname fancy@reqs@aliasNumber@#1@\endcsname%
\csname fancy@reqs@aliasNumber@#1@\endcsname
\else% Go get it
\PackageWarning{fancyreqs}{ Attempt to retrieve requirement number of
'#1' failed.}{}
{\tbd }
\fi%
}
% \newcommand{\reqnum}[1]{
% \ifcsname fancy@reqs@aliasNumber@#1@\endcsname%
% \textbf{\emph{\csname fancy@reqs@aliasNumber@#1@\endcsname}}
% \else% Go get it
% \PackageWarning{fancyreqs}{ Attempt to retrieve requirement number of
% '#1' failed.}{}
% {\tbd }
% \fi%
% }
\newcommand{\refreq}[1]{\hyperref[#1]{\textbf{[ESAD\_\reqnum{#1}]} (\nameref{#1})}}
%
% \newlistentry[reqitem]{subreqitem}{rqs}{1}
% \cftsetindents{subreqitem}{1.5em}{3.0em}
% \renewcommand{\thesubreqitem}{\thereqitem.\alph{subreqitem}}
% \newcommand{\subreqitem}[2]{%
% \refstepcounter{subreqitem}
% % \par\textbf{\thesubreqitem) #1}
% % \addcontentsline{rqs}{subreqitem}{\protect\numberline{\thesubreqitem}#1}
% \subrecsdrl{\Alph{subreqitem}}{#1}{#2}
% }
% \setcounter{rqsdepth}{2}