-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedocrel.g
272 lines (225 loc) · 9.64 KB
/
makedocrel.g
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
## this creates the documentation, needs: GAPDoc package, latex, pdflatex,
## mkindex, dvips
##
SetInfoLevel( InfoGAPDoc, 2 );
SetGapDocLaTeXOptions( "nocolor", "utf8" );
pathtodoc:= "doc";;
main:= "main.xml";;
pkgname:= "SingerAlg";;
# Extract the book name from the 'main' file.
str:= StringFile( Concatenation( pathtodoc, "/", main ) );;
pos:= PositionSublist( str, "<Book" );;
pos:= PositionSublist( str, "Name=\"", pos );;
pos:= Position( str, '\"', pos );;
pos2:= Position( str, '\"', pos );;
bookname:= str{ [ pos + 1 .. pos2 - 1 ] };;
pathtoroot:= "../../..";;
pathtotst:= "tst";;
authors:= [ "Thomas Breuer" ];;
files:= [
"../gap/access.g",
"../gap/browse.g",
"../gap/display.g",
"../gap/invar.g",
"../gap/loewy.gd",
"../gap/loewy.gi",
"../gap/mindeg.gd",
"../gap/permiso.g",
];;
AddHandlerBuildRecBibXMLEntry( "Wrap:Package", "BibTeX",
function( entry, r, restype, strings, options )
return Concatenation( "\\textsf{", ContentBuildRecBibXMLEntry(
entry, r, restype, strings, options ), "}" );
end );
AddHandlerBuildRecBibXMLEntry( "Wrap:Package", "HTML",
function( entry, r, restype, strings, options )
return Concatenation( "<strong class='pkg'>", ContentBuildRecBibXMLEntry(
entry, r, restype, strings, options ), "</strong>" );
end );
# Fetch GAP's current 'manualbib.xml'.
# This way, we avoid creating 'xml.bib' files in other paths.
bibfile:= Filename( DirectoriesLibrary( "doc" ), "manualbib.xml" );
if bibfile = fail then
Error( "cannot access GAP's current 'manualbib.xml'" );
fi;
Exec( Concatenation( "cp ", bibfile, " ", pathtodoc, "/gapmanualbib.xml" ) );
Exec( Concatenation( "chmod 644 ", pathtodoc, "/gapmanualbib.xml" ) );
MakeGAPDocDoc( pathtodoc, main, files, bookname, pathtoroot, "MathJax" );;
# Remove GAP's current 'manualbib.xml', and the automatically generated.
# 'manualbib.xml.bib'.
Exec( Concatenation( "rm ", pathtodoc, "/", "gapmanualbib.xml" ) );
Exec( Concatenation( "rm ", pathtodoc, "/", "gapmanualbib.xml.bib" ) );
CopyHTMLStyleFiles( pathtodoc );
GAPDocManualLabFromSixFile( bookname,
Concatenation( pathtodoc, "/manual.six" ) );
#############################################################################
# Check the consistency of version numbers in 'PackageInfo.g' and the manual.
CheckVersionNumber:= function( pkgname, pathtodoc, main )
local str, pos, pos2, version1, version2;
# definition in the manual
str:= StringFile( Concatenation( pathtodoc, "/", main ) );
pos:= PositionSublist( str, "<!ENTITY VERSIONNUMBER \"" );
pos:= Position( str, '\"', pos );
pos2:= Position( str, '\"', pos );
version1:= str{ [ pos + 1 .. pos2 - 1 ] };
# definition in 'PackageInfo.g'
version2:= PackageInfo( pkgname )[1].Version;
if version1 <> version2 then
Error( "version numbers <version1> (from ", main,
") and <version2> (from PackageInfo.g) differ" );
fi;
end;
CheckVersionNumber( pkgname, pathtodoc, main );
#############################################################################
tstfilename:= "docxpl.tst";
tstheadertext_with:= "\
This file contains the GAP code of examples in the package\n\
documentation files.\n\n\
In order to run the tests, one starts GAP from the 'tst' subdirectory\n\
of the 'pkg/PKGNAME' directory, and calls 'Test( \"FILENAME\" );'.\n\
";
tstheadertext_without:= "\
This file contains the GAP code of those examples in the package\n\
documentation files that do not involve the visual mode used by the\n\
Browse package.\n\n\
In order to run the tests, one starts GAP from the 'tst' subdirectory\n\
of the 'pkg/PKGNAME' directory, and calls 'Test( \"FILENAME\" );'.\n\
";
ExampleFileHeader:= function( filename, pkgname, authors, text, linelen,
pathtodoc, main, withbrowse )
local str, pos, pos2, releaseyear, free1, free2, i;
# definition in the manual
str:= StringFile( Concatenation( pathtodoc, "/", main ) );
pos:= PositionSublist( str, "<!ENTITY RELEASEYEAR \"" );
pos:= Position( str, '\"', pos );
pos2:= Position( str, '\"', pos );
releaseyear:= str{ [ pos + 1 .. pos2 - 1 ] };
free1:= Int( ( linelen - Length( pkgname ) - 14 ) / 2 );
free2:= linelen - free1 - 14 - Length( pkgname ) - Length( authors[1] );
text:= ReplacedString( text, "PKGNAME", LowercaseString( pkgname ) );
text:= ReplacedString( text, "FILENAME", filename );
text:= ReplacedString( text, "\n", "\n## " );
str:= RepeatedString( "#", linelen );
Append( str, "\n##\n#W " );
Append( str, filename );
Append( str, RepeatedString( " ", free1 - Length( filename ) - 4 ) );
Append( str, "GAP 4 package " );
Append( str, pkgname );
Append( str, RepeatedString( " ", free2 ) );
Append( str, authors[1] );
for i in [ 2 .. Length( authors ) ] do
Append( str, "\n#W" );
Append( str, RepeatedString( " ", linelen - Length( authors[i] ) - 4 ) );
Append( str, authors[i] );
od;
Append( str, "\n##\n#Y Copyright (C) " );
Append( str, releaseyear );
Append( str, ", Lehrstuhl D für Mathematik, RWTH Aachen, Germany" );
Append( str, "\n##\n## " );
Append( str, text );
Append( str, "\n\ngap> LoadPackage( \"" );
Append( str, pkgname );
Append( str, "\", false );\ntrue" );
Append( str, "\ngap> save:= SizeScreen();;" );
Append( str, "\ngap> SizeScreen( [ 72 ] );;" );
Append( str, "\ngap> START_TEST( \"" );
Append( str, filename );
Append( str, "\" );\n" );
if withbrowse then
Append( str, "\n##\ngap> if IsBound( BrowseData ) then\n" );
Append( str, "> data:= BrowseData.defaults.dynamic.replayDefaults;\n" );
Append( str, "> oldinterval:= data.replayInterval;\n" );
Append( str, "> data.replayInterval:= 1;\n" );
Append( str, "> fi;\n" );
fi;
return str;
end;
ExampleFileFooter:= function( filename, linelen, withbrowse )
local str;
if withbrowse then
str:= "\n##\ngap> if IsBound( BrowseData ) then\n";
Append( str, "> data:= BrowseData.defaults.dynamic.replayDefaults;\n" );
Append( str, "> data.replayInterval:= oldinterval;\n" );
Append( str, "> fi;\n" );
else
str:= "";
fi;
Append( str, "\n##\ngap> STOP_TEST( \"" );
Append( str, filename );
Append( str, "\" );\n" );
Append( str, "gap> SizeScreen( save );;\n\n" );
Append( str, RepeatedString( "#", linelen ) );
Append( str, "\n##\n#E\n" );
return str;
end;
## Create the test file(s) with examples.
## If 'tstfilename' equals "chapter-wise" then one file is created for each
## chapter, with filename <srcname>'.tst' if the contents of the chapter is
## in <srcname>'.xml'.
## Otherwise, all examples are collected in the file with name 'tstfilename'.
##
CreateManualExamplesFiles:= function( pkgname, authors, text, path, main,
files, tstpath, tstfilename, withbrowse )
local linelen, xpls, str, pos, pos2, tstfilenames, i, r, l,
tstfilenameold;
linelen:= 77;
xpls:= ExtractExamples( path, main, files, "Chapter" );
# Distinguish chapter-wise or book-wise test files.
if tstfilename = "chapter-wise" then
str:= StringFile( Concatenation( pathtodoc, "/", main ) );
pos:= PositionSublist( str, "<Body>" );
pos2:= PositionSublist( str, "</Body>", pos );
str:= str{ [ pos .. pos2 ] };
tstfilenames:= [];
pos:= PositionSublist( str, "<#Include SYSTEM \"" );
while pos <> fail do
pos:= pos + 18;
pos2:= PositionSublist( str, "\"", pos );
Add( tstfilenames,
ReplacedString( str{ [ pos .. pos2-1 ] }, ".xml", ".tst" ) );
pos:= PositionSublist( str, "<#Include SYSTEM \"", pos2 );
od;
if Length( xpls ) <> Length( tstfilenames ) then
Error( "wrong number of chapters?" );
fi;
else
tstfilenames:= [ tstfilename ];
xpls:= [ Concatenation( xpls ) ];
fi;
if not withbrowse then
xpls:= List( xpls,
l -> Filtered( l,
x -> PositionSublist( x[1], "Browse" ) = fail ) );
fi;
for i in [ 1 .. Length( xpls ) ] do
str:= "# This file was created automatically, do not edit!\n";
Append( str, ExampleFileHeader( tstfilenames[i], pkgname, authors,
text, linelen, path, main, withbrowse ) );
for l in xpls[i] do
Append( str, Concatenation( "\n## ", l[2][1],
" (", String( l[2][2] ), "-", String( l[2][3] ), ")" ) );
Append( str, l[1] );
od;
Append( str, ExampleFileFooter( tstfilenames[i], linelen, withbrowse ) );
tstfilename:= Concatenation( tstpath, "/", tstfilenames[i] );
tstfilenameold:= Concatenation( tstfilename, "~" );
if IsExistingFile( tstfilename ) then
Exec( Concatenation( "rm -f ", tstfilenameold ) );
Exec( Concatenation( "mv ", tstfilename, " ", tstfilenameold ) );
fi;
FileString( tstfilename, str );
if IsExistingFile( tstfilenameold ) then
Print( "#I differences in `", tstfilename, "':\n" );
Exec( Concatenation( "diff ", tstfilenameold, " ", tstfilename ) );
fi;
Exec( Concatenation( "chmod 444 ", tstfilename ) );
od;
end;
# include examples involving 'Browse'
CreateManualExamplesFiles( pkgname, authors, tstheadertext_with, pathtodoc,
main, files, pathtotst,
tstfilename, true );
# omit examples involving 'Browse'
CreateManualExamplesFiles( pkgname, authors, tstheadertext_without, pathtodoc,
main, files, pathtotst,
ReplacedString( tstfilename, ".", "2." ), false );