File: conv.xml

package info (click to toggle)
gap-gapdoc 1.6.7-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,596 kB
  • sloc: xml: 3,502; makefile: 244; javascript: 155; sh: 3
file content (285 lines) | stat: -rw-r--r-- 11,185 bytes parent folder | download | duplicates (2)
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

<Chapter Label="ch:conv">
<Heading>The Converters and an XML Parser</Heading>

The &GAPDoc; package contains a set of programs which allow us to  convert a
&GAPDoc; book  into several output  versions and  to make them  available to
&GAP;'s online help.<P/>

Currently  the following  output  formats are  provided:  text for  browsing
inside a  terminal running  &GAP;, &LaTeX; with  <C>hyperref</C>-package for
cross references via hyperlinks and HTML for reading with a Web-browser.<P/>



<Section Label="MakeDoc">
<Heading>Producing Documentation from Source Files</Heading>

Here   we    explain   how    to   use    the   functions    which   are
described  in  more   detail  in  the  following   sections.  We  assume
that   we   have   the   main   file   <F>MyBook.xml</F>   of   a   book
<C>"MyBook"</C>  in the  directory  <F>/my/book/path</F>. This  contains
<C>&lt;#Include    ...></C>-statements    as   explained    in
Chapter&nbsp;<Ref Sect="Distributing"/>. These refer to some other files
as well as pieces of text which  are found in the comments of some &GAP;
source files <F>../lib/a.gd</F> and  <F>../lib/b.gi</F> (relative to the
path above). A &BibTeX; database  <F>MyBook.bib</F> for the citations is
also  in  the  directory  given  above. We  want  to  produce  a  text-,
<C>pdf-</C> and HTML-version of the  document. (A &LaTeX; version of the
manual  is produced,  so it  is also  easy to  compile <C>dvi</C>-,  and
postscript-versions.)<P/>

All the commands shown in this  Section are collected in the single function
<Ref Func="MakeGAPDocDoc"/>.<P/>

First   we  construct   the   complete  XML-document   as   a  string   with
<Ref   Func="ComposedDocument"/>.     This   interprets    recursively   the
<C>&lt;#Include ...></C>-statements.

<Listing Type="Example">
gap> path := Directory("/my/book/path");;
gap> main := "MyBook.xml";;
gap> files := ["../lib/a.gd", "../lib/b.gi"];;
gap> bookname := "MyBook";;
gap> doc := ComposedDocument("GAPDoc", path, main, files, true);;
</Listing>

Now  <C>doc</C> is  a  list with  two  entries, the  first  is a  string
containing  the XML-document,  the second  gives information  from which
files and  locations which part of  the document was collected.  This is
useful in the next step, if there are any errors in the document. <P/>

Next  we parse  the document  and store  its structure  in a  tree-like data
structure. The  commands for  this are <Ref  Func="ParseTreeXMLString"/> and
<Ref Func="CheckAndCleanGapDocTree"/>. 

<Listing Type="Example">
gap> r := ParseTreeXMLString(doc[1], doc[2]);;
gap> CheckAndCleanGapDocTree(r);
true
</Listing>

We start  to produce  a text version  of the manual,  which can  be read
in  a  terminal  (window).  The command  is  <Ref  Func="GAPDoc2Text"/>.
This  produces  a  record  with  the actual  text  and  some  additional
information.  The text  can  be  written  chapter-wise  into files  with
<Ref Func="GAPDoc2TextPrintTextFiles"/>.  The names  of these  files are
<F>chap0.txt</F>,  <F>chap1.txt</F> and  so on.  The text  contains some
markup using  ANSI escape sequences.  This markup is substituted  by the
&GAP;  help system  (user configurable)  to  show the  text with  colors
and  other  attributes.  For  the  bibliography we  have  to  tell  <Ref
Func="GAPDoc2Text"/> the location of the &BibTeX; database by specifying
a <C>path</C> as second argument.

<Listing Type="Example">
gap> t := GAPDoc2Text(r, path);;
gap> GAPDoc2TextPrintTextFiles(t, path);
</Listing>

This   command  constructs   all   parts  of   the  document   including
table  of   contents,  bibliography   and  index.  The   functions  <Ref
Func="FormatParagraph"/>  for   formatting  text  paragraphs   and  <Ref
Func="ParseBibFiles"/> for reading  &BibTeX; files with &GAP;  may be of
independent interest.<P/>

With the  text version we  have also  produced the information  which is
used for searching  with &GAP;'s online help. Also,  labels are produced
which can be  used by links in the HTML-  and <C>pdf</C>-versions of the
manual. <P/>

Next   we   produce   a   &LaTeX;  version   of   the   document.   <Ref
Func="GAPDoc2LaTeX"/> returns  a string  containing the  &LaTeX; source.
The utility  function <Ref Func="FileString"/>  writes the content  of a
string to a file, we choose <F>MyBook.tex</F>.

<Listing Type="Example">
gap> l := GAPDoc2LaTeX(r);;
gap> FileString(Filename(path, Concatenation(bookname, ".tex")), l);
</Listing>

Assuming  that  you  have  a sufficiently  good  installation  of  &TeX;
available  (see  <Ref Func="GAPDoc2LaTeX"/>  for  details)  this can  be
processed with a series of commands like in the following example.

<Listing Type="Example">
cd /my/book/path
pdflatex MyBook
bibtex MyBook
pdflatex MyBook
makeindex MyBook
pdflatex MyBook
mv MyBook.pdf manual.pdf
</Listing>

After this  we have  a <C>pdf</C>-version  of the  document in  the file
<F>manual.pdf</F>. It  contains hyperlink information which  can be used
with  appropriate browsers  for convenient  reading of  the document  on
screen  (e.g., <C>xpdf</C>  is nice  because it  allows remote  calls to
display named locations  of the document). Of course, we  could also use
other commands like <C>latex</C> or  <C>dvips</C> to process the &LaTeX;
source file.

Furthermore  we   have  produced  a  file   <F>MyBook.pnr</F>  which  is
&GAP;-readable  and  contains  the  page  number  information  for  each
(sub-)section of the document. <P/>

We  can add  this page  number information  to the  indexing information
collected by the text converter  and then print a <F>manual.six</F> file
which is read by &GAP; when the manual is loaded. This is done with <Ref
Func="AddPageNumbersToSix"/> and <Ref Func="PrintSixFile"/>.

<Listing Type="Example">
gap> AddPageNumbersToSix(r, Filename(path, "MyBook.pnr"));
gap> PrintSixFile(Filename(path, "manual.six"), r, bookname);
</Listing>

Finally  we  produce  an  HTML-version  of the  document  and  write  it
(chapter-wise)  into  files   <F>chap0.html</F>,  <F>chap1.html</F>  and
so  on.  They  can  be  read with  any  Web-browser.  The  commands  are
<Ref  Func="GAPDoc2HTML"/> and  <Ref Func="GAPDoc2HTMLPrintHTMLFiles"/>.
We  also  add  a  link  from  <F>manual.html</F>  to  <F>chap0.html</F>.
You  probably   want  to  copy stylesheet   files into the same directory,
see  <Ref Subsect="StyleSheets"/>  for   more  details.   The  argument
<C>path</C>  of   <Ref  Func="GAPDoc2HTML"/>  specifies   the  directory
containing the &BibTeX; database files.

<Listing Type="Example">
gap> h := GAPDoc2HTML(r, path);;
gap> GAPDoc2HTMLPrintHTMLFiles(h, path);
</Listing>

<ManSection >
<Func Arg="path, main, files, bookname[, gaproot][, ...]" Name="MakeGAPDocDoc" />

<Description>
This  function  collects  all  the   commands  for  producing  a  text-,
<C>pdf</C>-  and HTML-version  of a  &GAPDoc; document  as described  in
Section&nbsp;<Ref Sect="MakeDoc"/>. It checks the <C>.log</C> file from
the call of <C>pdflatex</C> and reports if there are errors, warnings or
overfull boxes.<P/>

<Emph>Note:</Emph> If this function works for you depends on your
operating system and installed software. It will probably work on most
<C>UNIX</C> systems with a standard &LaTeX; installation. If the
function doesn't work for you look at the source code and adjust it to
your system. <P/>

Here <A>path</A> must  be the directory (as string  or directory object)
containing  the main  file <A>main</A>  of the  document (given  with or
without the <C>.xml</C>  extension. The argument <A>files</A>  is a list
of (probably  source code) files  relative to <A>path</A>  which contain
pieces  of documentation  which must  be included  in the  document, see
Chapter&nbsp;<Ref Chap="Distributing"/>. And <A>bookname</A> is the name
of  the  book  used  by  &GAP;'s  online  help.  The  optional  argument
<A>gaproot</A>  must be  a string  which  gives the  relative path  from
<A>path</A> to the main &GAP; root directory. If this is given, the HTML
files are produced with relative paths to external books.<P/>

If the  string <C>"nopdf"</C>  is given as  optional argument  then <Ref
Func="MakeGAPDocDoc"/> will not produce a <C>pdf</C>-version of the help
book  (the  source  <C>.tex</C>-file is  generated).  Consequently,  the
index  for  the help  system  will  not  contain  page numbers  for  the
<C>pdf</C>-version. This  variant of <Ref  Func="MakeGAPDocDoc"/> should
work independently of the operating  system because no external programs
are  called. It  is  recommended that  distributed  manuals contain  the
<C>pdf</C>-version. <P/>

<Index Key="MathJax" Subkey="in MakeGAPDocDoc"><Package>MathJax</Package> 
<Subkey>in <C>MakeGAPDocDoc</C></Subkey></Index>
<Ref  Func="MakeGAPDocDoc"/> can  be  called  with additional  arguments
<C>"MathJax"</C>,  <C>"Tth"</C>  and/or  <C>"MathML"</C>. If  these  are
given additional  variants of the  HTML conversion are called,  see <Ref
Func="GAPDoc2HTML"/> for details.<P/>

It is possible to use &GAPDoc; with other languages than English, see
<Ref Func="SetGapDocLanguage"/> for more details.<P/>
</Description>
</ManSection>
</Section>

<Section Label="ParseXML">
<Heading>Parsing XML Documents</Heading>
Arbitrary well-formed  XML documents  can be parsed  and browsed  by the
following functions.  A proper validation  can be done with  an external
program, see <Ref Func="XMLValidate"/> below.

<#Include Label="ParseTreeXMLString">

<#Include Label="StringXMLElement">

<#Include Label="EntitySubstitution">

<#Include Label="DisplayXMLStructure">

<#Include Label="ApplyToNodesParseTree">

Here are two more utilities which use <Ref
Func="ApplyToNodesParseTree"/>.

<#Include Label="GetTextXMLTree">

<#Include Label="XMLElements">

And here are utilities for processing &GAPDoc; XML documents.

<#Include Label="CheckAndCleanGapDocTree">

<#Include Label="AddParagraphNumbersGapDocTree">

<#Include Label="InfoXMLParser">

<#Include Label="XMLValidate">

<#Include Label="ValidateGAPDoc">

</Section>

<Section Label="Converters">
<Heading>The Converters</Heading>
Here  are  more details  about  the  conversion  programs for  &GAPDoc;  XML
documents.

<#Include Label="GAPDoc2LaTeX">

<#Include Label="GAPDoc2Text">

<#Include Label="GAPDoc2TextPrintTextFiles">

<#Include Label="AddPageNumbersToSix">

<#Include Label="PrintSixFile">

<#Include Label="SetGAPDocTextTheme">

<#Include Label="GAPDoc2HTML">

<#Include Label="GAPDoc2HTMLPrintHTMLFiles">

<#Include Label="HTMLStyleSheets">

<#Include Label="SetGAPDocHTMLStyle">

<#Include Label="InfoGAPDoc">

<#Include Label="SetGapDocLanguage">

</Section>

<Section Label="Sec:TestExample">
<Index><C>ManualExamples</C></Index>
<Index><C>TestManualExamples</C></Index>
<Heading>Testing Manual Examples</Heading>
We also provide some tools to check and adjust the examples given in
<C>&lt;Example></C>-elements. <P/>
Former versions of &GAPDoc; provided functions <C>ManualExamples</C>
and <C>TestManualExamples</C>. These functions are still available,
but no longer documented. Their use is deprecated.

<#Include Label="ExtractExamples">

<#Include Label="RunExamples">

</Section>

</Chapter>