-
Notifications
You must be signed in to change notification settings - Fork 3
/
buildDocumentation.cmd
364 lines (323 loc) · 14 KB
/
buildDocumentation.cmd
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION&::(Don't pollute the global environment with the following)
::**********************************************************************
SET $NAME=%~n0
SET $DESCRIPTION=Unit test processing
SET $SOURCE=%~f0
::@(#)NAME
::@(-) The name of the command or function, followed by a one-line description of what it does.
::@(#) %$NAME% -- %$DESCRIPTION%
::@(#)
::@(#)SYNOPSIS
::@(-) In the case of a command, a formal description of how to run it and what command line options it takes.
::@(-) For program functions, a list of the parameters the function takes and which header file contains its definition.
::@(-)
::@(#) %$NAME% [VAR]
::@(#) %$Name%
::@(#)
::@(#)OPTIONS
::@(-) Flags, parameters, arguments (NOT the Monty Python way)
::@(#) -h Help page
::@(#)
::@ (#)
::@(#)DESCRIPTION
::@(-) A textual description of the functioning of the command or function.
::@(#) Loops through scripts in current directory and executes
::@(#) any matching unit test in the unit test directory.
::@(#) For each script a status of "OK", "Not available" or "FAIL"
::@(#) is displayed.
::@(#) Log files with respectively failing and missing unit tests
::@(#) are produced and displayed after running the tests.
::@(#)
::@(#)EXAMPLES
::@(-) Some examples of common usage.
::@(#) buildDocumentation.cmd
::@(#) buildDocumentation -- Unit test processing
::@(#) v. 2015-10-08 r. 11:20:00
::@(#)
::@(#) Clean up [Done ]
::@(#) Documentation directory [Found ]
::@(#) Html index [Opened ]
::@(#) Documentation JavaScript [Done ]
::@(#) Build Script list [Build and sorted ]
::@(#) No of scripts to process [88 ]
::@(#)
::@(#) - 0template.cmd [Done ]
::@(#) - banner.cmd [Done ]
::@(#) - BatchSubstitude.bat [Done ]
::@(#) *** skip ***
::@(#) - _UTC.cmd [Done ]
::@(#) - _utf2ansi.cmd [Done ]
::@(#) - _utf2oem.cmd [Done ]
::@(#)
::@(#) Html index [Closed ]
::@(#) Total scripts [88 ]
::@(#) buildDocumentation [Done ]
::@(#)
::@ (#)EXIT STATUS
::@(-) Exit status / errorlevel is 0 if OK, otherwise 1+.
::@ (#)
::@ (#)ENVIRONMENT
::@(-) Variables affected
::@ (#)
::@ (#)
::@ (#)FILES,
::@(-) Files used, required, affected
::@ (#)
::@ (#)
::@ (#)BUGS / KNOWN PROBLEMS
::@(-) If any known
::@ (#)
::@ (#)
::@(#)REQUIRES
::@(-) Dependecies
::@(#) _Debug.cmd Setting up debug environment for batch scripts
::@(#) _GetOpt.cmd Parse command line options and create environment vars
::@(#)
::@ (#)SEE ALSO
::@(-) A list of related commands or functions.
::@ (#)
::@ (#)
::@ (#)REFERENCE
::@(-) References to inspiration, clips and other documentation
::@ (#) Author:
::@ (#) URL:
::@ (#)
::@(#)
::@(#)SOURCE
::@(-) Where to find this source
::@(#) %$Source%
::@(#)
::@ (#)AUTHOR
::@(-) Who did what
::@ (#) %$AUTHOR%
::*** HISTORY **********************************************************
::SET $VERSION=YYYY-MM-DD&SET $REVISION=hh:mm:ss&SET $COMMENT=Init Description [xx.xxx]
::SET $VERSION=2010-10-20&SET $REVISION=00:00:00&SET $COMMENT=Initial [01.000]
::SET $VERSION=2010-11-12&SET $REVISION=16:23:00&SET $COMMENT=Adding exact path to _prescript/ErikBachmann [01.010]
::SET $VERSION=2015-02-18&SET $REVISION=23:33.00&SET $COMMENT=Status on missing/failing scripts/ErikBachmann
::SET $VERSION=2015-02-19&SET $REVISION=03:14:08&SET $COMMENT=Autoupdate / ErikBachmann
::SET $VERSION=2015-10-08&SET $REVISION=11:20:00&SET $COMMENT=GetOpt: Calling usage on -h and exit on error / ErikBachmann
SET $VERSION=2016-03-14&SET $REVISION=10:00:00&SET $COMMENT=Set "%~dp0\ prefix on function calls / ErikBachmann
::**********************************************************************
::@(#)(c)%$Version:~0,4% %$Author%
::**********************************************************************
CALL "%~dp0\_DEBUG"
CALL "%~dp0\_Getopt" %*&IF ERRORLEVEL 1 EXIT /B 1
::ENDLOCAL
:MAIN
CALL :UnitTest.init
CALL :UnitTest.process
CALL :UnitTest.finalize
GOTO :EOF :Main
::----------------------------------------------------------------------
:UnitTest.init
CALL "%~dp0\_debug"
FOR %%a IN (CON: "%$TraceFile%" "%$LogFile%") DO (
ECHO:%$NAME% -- %$DESCRIPTION%
ECHO:v. %$VERSION% r. %$REVISION%
ECHO:
)>>%%a
SET _ScriptTypes=cmd bat vbs
SET _ScriptList=%Tmp%\%~n0.ScriptList.txt
SET _TestMissingList=%Tmp%\%~n0.TestMissing.txt
SET _TestFailingList=%Tmp%\%~n0.TestFailing.txt
SET _UnitTestsTotalCount=0
SET _UnitTestFailCount=0
SET _UnitTestMissingCount=0
SET _DocDir=%~dp0\Documentation\
%_TRACE_% %0 Done
GOTO :EOF :UnitTest.init
::----------------------------------------------------------------------
:UnitTest.Process
CALL "%~dp0\_Action" "Clean up"
PUSHD "%~dp0"
IF EXIST "%Tmp%\%~n0.*" DEL "%Tmp%\%~n0.*"
CALL "%~dp0\_Status" "Done"
CALL "%~dp0\_Action" "Documentation directory"
IF NOT EXIST "%_DocDir%" (
MKDIR "%_DocDir%"
IF ERRORLEVEL 1 (
CALL "%~dp0\_Status" "ERROR Cannot create [%_DocDir%]"
) ELSE (
CALL "%~dp0\_Status" "Created"
)
) ELSE (
CALL "%~dp0\_Status" "Found"
)
CALL "%~dp0\_Action" "Html index"
( REM Main index file = frameset
ECHO:^<frameset cols="20%%,*"^>
ECHO: ^<frame src="index.frame.html"^>
ECHO: ^<frame src="../readme.html" name="main"^>
ECHO:^</frameset^>
)>Documentation\index.html
( REM Index in left frame
ECHO:^<a href="../readme.html" target="main"^>
ECHO:^<H1^>Documentation index^</H1^>^</a^>^<ul^>
ECHO:^<link rel="stylesheet" href="../underscore.css" type="text/css" /^>
ECHO:^<script language="JavaScript" src="../underscore.js" type="text/javascript"^>^</script^>
)>Documentation\index.frame.html
( REM Index in left frame
ECHO:
ECHO:^<a href="../readme.html" target="main"^>^<H1^>Documentation index^</H1^>^</a^>
ECHO:^<link rel="stylesheet" href="../underscore.css" type="text/css" /^>
ECHO:^<script language="JavaScript" src="what.js" type="text/javascript"^>^</script^>
ECHO:^<ol^>
::ECHO:^<li^>^<a href="../readme.html#_" target="main"^>_^</a^>
ECHO:^<li^>^<a href="../readme.html#WhatsItAllAbout" target="main"^>WhatsItAllAbout^</a^>
ECHO:^<li^>^<a href="../readme.html#Structure" target="main"^>Structure^</a^>
ECHO:^<ol^>
ECHO: ^<li^>^<a href="../readme.html#DirectoryStructure" target="main"^>DirectoryStructure^</a^>
ECHO: ^<li^>^<a href="../readme.html#ScriptStructure" target="main"^>ScriptStructure^</a^>
ECHO:^</ol^>
ECHO:^<li^>^<a href="../readme.html#UnitTests" target="main"^>UnitTests^</a^>
ECHO:^<ol^>
ECHO: ^<li^>^<a href="../readme.html#WrittingAUnitTest" target="main"^>WrittingAUnitTest^</a^>
ECHO: ^<li^>^<a href="../readme.html#SimpleComparison" target="main"^>SimpleComparison^</a^>
ECHO: ^<li^>^<a href="../readme.html#HexDump" target="main"^>HexDump^</a^>
ECHO: ^<li^>^<a href="../readme.html#PatternMatching" target="main"^>PatternMatching^</a^>
ECHO: ^<li^>^<a href="../readme.html#SkippingTest" target="main"^>SkippingTest^</a^>
ECHO:^</ol^>
ECHO:
ECHO:^<li^>^<a href="../readme.html#LogDebugTraceAndTemporaryFiles" target="main"^>LogDebugTraceAndTemporaryFiles^</a^>
ECHO:^<li^>^<a href="../readme.html#Installation" target="main"^>Installation^</a^>
ECHO:^<ol^>
ECHO: ^<li^>^<a href="../readme.html#FirstTimeInstallation" target="main"^>FirstTimeInstallation^</a^>
ECHO: ^<li^>^<a href="../readme.html#Updating" target="main"^>Updating^</a^>
ECHO:^</ol^>
ECHO:^<li^>^<a href="../readme.html#How-To" target="main"^>How-To^</a^>
ECHO:^<li^>^<a href="../readme.html#BugFixes" target="main"^>BugFixes^</a^>
ECHO:^</ol^>
ECHO: )>Documentation\index.frame.html
CALL "%~dp0\_Status" "Opened"
CALL "%~dp0\_Action" "Documentation JavaScript"
( REM Java script
ECHO:function linkMe^(link^) {
ECHO: url = link.replace ^(/\.[^\.]*$/, ''^)
ECHO: url += '.html'
ECHO: document.write^("<a href='" + url + "' title='Jump to HELP on [" + link + "]'>" + link + "</a>"^)
ECHO:}
)>Documentation\underscore.js
CALL "%~dp0\_Status" "Done"
REM CALL "%~dp0\_Action" "Documentation Style Sheet"
REM IF NOT EXIST "Documentation\what.css" (
REM ( REM CSS Style Sheet
REM ECHO:body { Background: #F5FFFF; /* Light cyan */ }
REM ECHO:h2 {
REM ECHO: Background: #BDEDFF; /* Light blue */
REM ECHO: Background: #B8E6E6;
REM ECHO: color: Red;
REM ECHO: margin: 0px;
REM ECHO:}
REM ECHO:h3 {
REM ECHO: Background: #BDEDFF; /* Light blue */
REM ECHO: Background: #CCFFFF;
REM ECHO: color: Blue;
REM ECHO: margin: 5px;
REM ECHO:}
REM ECHO:h4 {
REM ECHO: Background: #BDEDFF; /* Light blue */
REM ECHO: Background: #CCFFFF;
REM ECHO: color: Green;
REM ECHO:}
REM ECHO:tt {
REM ECHO: color: purple;
REM ECHO: color: #001A4C;
REM ECHO:}
REM ECHO:hr { width: 10% }
REM )>Documentation\what.css
REM CALL "%~dp0\_Status" "Done"
REM ) ELSE (
REM CALL "%~dp0\_Status" "Found"
REM )
CALL "%~dp0\_Action" "Build Script list"
FOR %%a IN (%_ScriptTypes%) DO DIR /B *.%%a >>"%_ScriptList%.tmp" 2>>"%$TraceFile%"
SORT < "%_ScriptList%.tmp"|FIND /v /I "%~nx0" >>"%_ScriptList%"
CALL "%~dp0\_STATUS" "Build and sorted"
IF NOT "0"=="%DEBUG%" (
ECHO:- Check the list of scripts in [%_ScriptList%]
ECHO:pause
)
CALL "%~dp0\_ACTION" "No of scripts to process"
FOR /F %%a IN ('FIND /c "." ^<"%_ScriptList%"') DO SET _ScriptsTotalCount=%%a
CALL "%~dp0\_Status" "%_ScriptsTotalCount%"
ECHO:
:: FOR /F %%a IN (%_ScriptList%) DO CALL :UnitTest.ProcessScript "%%a"
(
ECHO:Functions
ECHO:^<ul^>
)>>Documentation\index.frame.html
FOR /F %%a IN ('TYPE %_ScriptList%^|findstr -v "^_"') DO CALL :UnitTest.ProcessScript "%%a"
(
ECHO:^</ul^>
ECHO:Subfunctions
)>>Documentation\index.frame.html
FOR /F %%a IN ('TYPE %_ScriptList%^|findstr "^_"') DO CALL :UnitTest.ProcessScript "%%a"
GOTO :EOF :UnitTest.Process
::----------------------------------------------------------------------
:UnitTest.finalize
ECHO:
CALL "%~dp0\_Action" "Html index"
ECHO ^</ul^>^<HR^> >>Documentation\index.frame.html
CALL "%~dp0\_Status" "Closed"
CALL "%~dp0\_Action" "Total scripts"
CALL "%~dp0\_Status" "%_ScriptsTotalCount%"
REM CALL "%~dp0\_Action" "Total unit tests"
REM CALL "%~dp0\_Status" "%_UnitTestsTotalCount%"
REM CALL "%~dp0\_Action" "Tests failing"
REM CALL "%~dp0\_Status" "%_UnitTestFailCount%"
REM CALL "%~dp0\_Action" "Tests not available"
REM CALL "%~dp0\_Status" "%_UnitTestMissingCount%"
REM CALL "%~dp0\_Action" "Missing scripts list"
REM IF EXIST "%_TestMissingList%" (
REM CALL "%~dp0\_Status" "Opening"
REM START "Missing scripts" /B notepad "%_TestMissingList%"
REM ) ELSE (
REM CALL "%~dp0\_Status" "Skip"
REM )
::ECHO ---------------------------------------------------
REM CALL "%~dp0\_Action" "Failing scripts list"
REM IF EXIST "%_TestFailingList%" (
REM CALL "%~dp0\_Status" "Opening"
REM START "Failing tests" /B notepad "%_TestFailingList%"
REM ) ELSE (
REM CALL "%~dp0\_Status" "Skip"
REM )
CALL "%~dp0\_Action" "%$NAME%"
CALL "%~dp0\_Status" "Done"
GOTO :EOF :UnitTest.finalize
::----------------------------------------------------------------------
:UnitTest.ProcessScript
SET _Script=%~1
SET _UnitTest=UnitTest\%~n1.UnitTest%~x1
TITLE %_Script% - documentation
CALL "%~dp0\_Action" "- %_Script%"
REM IF EXIST "%_UnitTest%" (
REM CALL :UnitTest.TestScript
REM ) ELSE (
REM CALL "%~dp0\_Status" "Not available"
REM CALL SET /A _UnitTestMissingCount+=1
REM ECHO %_Script% >>"%_TestMissingList%"
REM )
CALL "%~dp0\_state" "*** building ***"
CALL what.cmd "%~1" >Documentation\%~n1.txt
CALL what.cmd "%~1" -html >Documentation\%~n1.html
ECHO ^<li^>^<a href="%~n1.html" target="main"^>%~n1^</a^> >>Documentation\index.frame.html
CALL "%~dp0\_status" "Done"
GOTO :EOF :UnitTest.ProcessScript
::----------------------------------------------------------------------
REM :UnitTest.TestScript
REM CALL SET /A _UnitTestsTotalCount+=1
REM CALL "%~dp0\_State" "Test found - running.."
REM SET ErrorLevel=
REM CALL "%_UnitTest%" >> "%$LogFile%" 2>>"%$TraceFile%"
REM IF ErrorLevel 1 (
REM CALL "%~dp0\_Status" "FAIL [%ErrorLevel%]"
REM CALL SET /A _UnitTestFailCount+=1
REM ECHO:%_UnitTest%>>"%_TestFailingList%"
REM ) ELSE (
REM CALL "%~dp0\_Status" "OK"
REM )
REM GOTO :EOF :UnitTest.TestScript
::*** End Of Line *****************************************************