-
Notifications
You must be signed in to change notification settings - Fork 46
/
makedoc.g
157 lines (131 loc) · 5.64 KB
/
makedoc.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
#############################################################################
##
## makedoc.g
## Copyright (C) 2024 James D. Mitchell
##
## Licensing information can be found in the README file of this package.
##
#############################################################################
##
LoadPackage("AutoDoc");
# Helper functions
RemovePrefixVersion := function(string)
if StartsWith(string, ">=") then
return string{[3 .. Length(string)]};
fi;
return string;
end;
UrlEntity := function(name, url)
return StringFormatted("""<Alt Not="Text"><URL Text="{1}">{2}</URL></Alt>
<Alt Only="Text"><Package>{1}</Package></Alt>""", name, url);
end;
PackageEntity := function(name)
if TestPackageAvailability(name) <> fail then
return UrlEntity(PackageInfo(name)[1].PackageName,
PackageInfo(name)[1].PackageWWWHome);
fi;
return StringFormatted("<Package>{1}</Package>", name);
end;
MathOrCode := function(string)
return StringFormatted("""<Alt Not="Text"><M>{1}</M></Alt>
<Alt Only="Text"><C>{1}</C></Alt>""", string);
end;
XMLEntities := rec();
# Programmatically determined entities
PkgInfo := PackageInfo("digraphs")[1];
XMLEntities.VERSION := PkgInfo.Version;
XMLEntities.GAPVERS := RemovePrefixVersion(PkgInfo.Dependencies.GAP);
for Pkg in Concatenation(PkgInfo.Dependencies.NeededOtherPackages,
PkgInfo.Dependencies.SuggestedOtherPackages) do
entity_name := Concatenation(UppercaseString(Pkg[1]), "VERS");
XMLEntities.(entity_name) := RemovePrefixVersion(Pkg[2]);
od;
ARCHIVENAME := SplitString(PkgInfo.ArchiveURL, "/");
ARCHIVENAME := Concatenation(Last(ARCHIVENAME), PkgInfo.ArchiveFormats);
XMLEntities.ARCHIVENAME := ARCHIVENAME;
XMLEntities.DIGRAPHS := PackageEntity("Digraphs");
for Pkg in Concatenation(PkgInfo.Dependencies.NeededOtherPackages,
PkgInfo.Dependencies.SuggestedOtherPackages) do
entity_name := UppercaseString(Pkg[1]);
XMLEntities.(entity_name) := PackageEntity(Pkg[1]);
od;
# The files containing the xml of the doc
DocDir := DirectoriesPackageLibrary("digraphs", "doc")[1];
Files := Filtered(DirectoryContents(DocDir),
x -> (not StartsWith(x, "."))
and (not StartsWith(x, "z-"))
and EndsWith(x, ".xml"));
Apply(Files, x -> Concatenation("doc/", x));
Add(Files, "PackageInfo.g");
Sort(Files);
# The scaffold files (chapters)
Includes := Filtered(DirectoryContents(DocDir),
x -> StartsWith(x, "z-") and EndsWith(x, ".xml") and not
StartsWith(x, "z-app"));
Sort(Includes);
# Hard coded entities
XMLEntities.BLISS := UrlEntity("bliss",
"http://www.tcs.tkk.fi/Software/bliss/");
XMLEntities.NAUTY := UrlEntity("nauty",
"https://pallini.di.uniroma1.it");
XMLEntities.NautyTracesInterface := UrlEntity("NautyTracesInterface",
"https://github.com/gap-packages/NautyTracesInterface");
XMLEntities.EDGE_PLANARITY_SUITE := UrlEntity("edge-addition-planarity-suite",
"https://github.com/graph-algorithms/edge-addition-planarity-suite");
XMLEntities.MUTABLE_RECOMPUTED_ATTR := """If the argument <A>digraph</A> is
mutable, then the return value of this attribute is recomputed every time it is
called.<P/>""";
XMLEntities.MUTABLE_RECOMPUTED_PROP := """If the argument <A>digraph</A> is
mutable, then the return value of this property is recomputed every time it is
called.<P/>""";
XMLEntities.STANDARD_FILT_TEXT := """If the optional first argument <A>filt</A>
is present, then this should specify the category or representation the digraph
being created will belong to. For example, if <A>filt</A> is <Ref
Filt="IsMutableDigraph"/>, then the digraph being created will be mutable, if
<A>filt</A> is <Ref Filt="IsImmutableDigraph"/>, then the digraph will be
immutable. If the optional first argument <A>filt</A> is not present, then
<Ref Filt="IsImmutableDigraph"/> is used by default.<P/>""";
XMLEntities.CHESSBOARD_LABELS := """The chosen correspondence between vertices
and chess squares is given by <Ref Oper="DigraphVertexLabels"/>. In more
detail, the vertices of the digraph are labelled by elements of the Cartesian
product <C>[1..<A>m</A>] x [1..<A>n</A>]</C>, where the first entry indexes the
column (file) of the square in the chessboard, and the second entry indexes the
row (rank) of the square. (Note that the files are traditionally indexed by
the lowercase letters of the alphabet). The vertices are sorted in ascending
order, first by row (second component) and then column (first component).""";
XMLEntities.CHESSBOARD_DEFN := """An <A>m</A> by <A>n</A> chessboard is a grid
of <A>m</A> columns ("files") and <A>n</A> rows ("ranks") that intersect in
squares. Orthogonally adjacent squares are alternately colored light and dark,
with the square in the first rank and file being dark.<P/>""";
# The actual call to AutoDoc
AutoDoc("digraphs", rec(
autodoc := rec(scan_dirs := []),
gapdoc := rec(
LaTeXOptions := rec(EarlyExtraPreamble := """
\usepackage{a4wide}
\newcommand{\bbZ}{\mathbb{Z}}
"""),
main := "main",
files := Files),
scaffold := rec(
includes := Includes,
appendix := ["z-appA.xml"],
bib := "digraphs.bib",
entities := XMLEntities)));
# HTML styling
main_css := "doc/manual.css";
custom_css := "doc/digraphs.css";
if IsReadableFile(custom_css) and IsWritableFile(main_css) then
AppendTo(main_css, StringFile(custom_css));
fi;
Unbind(RemovePrefixVersion);
Unbind(UrlEntity);
Unbind(PackageEntity);
Unbind(MathOrCode);
Unbind(XMLEntities);
Unbind(PkgInfo);
Unbind(Pkg);
Unbind(ARCHIVENAME);
Unbind(DocDir);
Unbind(Files);
Unbind(Includes);