1doctools::toc::export(n) Documentation tools doctools::toc::export(n)
2
3
4
5______________________________________________________________________________
6
8 doctools::toc::export - Exporting tables of contents
9
11 package require doctools::toc::export ?0.2.1?
12
13 package require Tcl 8.4
14
15 package require struct::map
16
17 package require doctools::toc::structure
18
19 package require snit
20
21 package require pluginmgr
22
23 ::doctools::toc::export objectName
24
25 objectName method ?arg arg ...?
26
27 objectName destroy
28
29 objectName export serial serial ?format?
30
31 objectName export object object ?format?
32
33 objectName config names
34
35 objectName config get
36
37 objectName config set name ?value?
38
39 objectName config unset pattern...
40
41 export serial configuration
42
43______________________________________________________________________________
44
46 This package provides a class to manage the plugins for the export of
47 tables of contents to other formats, i.e. their conversion to, for ex‐
48 ample doctoc, HTML, etc.
49
50 This is one of the three public pillars the management of tables of
51 contents resides on. The other two pillars are
52
53 [1] Importing tables of contents, and
54
55 [2] Holding tables of contents
56
57 For information about the Concepts of tables of contents, and their
58 parts, see the same-named section. For information about the data
59 structure which is the major input to the manager objects provided by
60 this package see the section ToC serialization format.
61
62 The plugin system of our class is based on the package pluginmgr, and
63 configured to look for plugins using
64
65 [1] the environment variable DOCTOOLS_TOC_EXPORT_PLUGINS,
66
67 [2] the environment variable DOCTOOLS_TOC_PLUGINS,
68
69 [3] the environment variable DOCTOOLS_PLUGINS,
70
71 [4] the path "~/.doctools/toc/export/plugin"
72
73 [5] the path "~/.doctools/toc/plugin"
74
75 [6] the path "~/.doctools/plugin"
76
77 [7] the path "~/.doctools/toc/export/plugins"
78
79 [8] the path "~/.doctools/toc/plugins"
80
81 [9] the path "~/.doctools/plugins"
82
83 [10] the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\EX‐
84 PORT\PLUGINS"
85
86 [11] the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOC‐
87 TOOLS\TOC\PLUGINS"
88
89 [12] the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"
90
91 The last three are used only when the package is run on a machine using
92 Windows(tm) operating system.
93
94 The whole system is delivered with six predefined export plugins,
95 namely
96
97 doctoc See doctoc export plugin for details.
98
99 html See html export plugin for details.
100
101 json See json export plugin for details.
102
103 nroff See nroff export plugin for details.
104
105 text See text export plugin for details.
106
107 wiki See wiki export plugin for details.
108
109 Readers wishing to write their own export plugin for some format, i.e.
110 plugin writers reading and understanding the section containing the Ex‐
111 port plugin API v2 reference is an absolute necessity, as it specifies
112 the interaction between this package and its plugins in detail.
113
115 [1] A table of contents consists of a (possibly empty) list of ele‐
116 ments.
117
118 [2] Each element in the list is identified by its label.
119
120 [3] Each element is either a reference, or a division.
121
122 [4] Each reference has an associated document, identified by a sym‐
123 bolic id, and a textual description.
124
125 [5] Each division may have an associated document, identified by a
126 symbolic id.
127
128 [6] Each division consists consists of a (possibly empty) list of
129 elements, with each element following the rules as specified in
130 item 2 and above.
131
132 A few notes
133
134 [1] The above rules span up a tree of elements, with references as
135 the leaf nodes, and divisions as the inner nodes, and each ele‐
136 ment representing an entry in the whole table of contents.
137
138 [2] The identifying labels of any element E are unique within their
139 division (or toc), and the full label of any element E is the
140 list of labels for all nodes on the unique path from the root of
141 the tree to E, including E.
142
144 PACKAGE COMMANDS
145 ::doctools::toc::export objectName
146 This command creates a new export manager object with an associ‐
147 ated Tcl command whose name is objectName. This object command
148 is explained in full detail in the sections Object command and
149 Object methods. The object command will be created under the
150 current namespace if the objectName is not fully qualified, and
151 in the specified namespace otherwise.
152
153 OBJECT COMMAND
154 All objects created by the ::doctools::toc::export command have the
155 following general form:
156
157 objectName method ?arg arg ...?
158 The method method and its arg'uments determine the exact behav‐
159 ior of the command. See section Object methods for the detailed
160 specifications.
161
162 OBJECT METHODS
163 objectName destroy
164 This method destroys the object it is invoked for.
165
166 objectName export serial serial ?format?
167 This method takes the canonical serialization of a table of con‐
168 tents stored in serial and converts it to the specified format,
169 using the export plugin for the format. An error is thrown if no
170 plugin could be found for the format. The string generated by
171 the conversion process is returned as the result of this method.
172
173 If no format is specified the method defaults to doctoc.
174
175 The specification of what a canonical serialization is can be
176 found in the section ToC serialization format.
177
178 The plugin has to conform to the interface specified in section
179 Export plugin API v2 reference.
180
181 objectName export object object ?format?
182 This method is a convenient wrapper around the export serial
183 method described by the previous item. It expects that object
184 is an object command supporting a serialize method returning the
185 canonical serialization of a table of contents. It invokes that
186 method, feeds the result into export serial and returns the re‐
187 sulting string as its own result.
188
189 objectName config names
190 This method returns a list containing the names of all configu‐
191 ration variables currently known to the object.
192
193 objectName config get
194 This method returns a dictionary containing the names and values
195 of all configuration variables currently known to the object.
196
197 objectName config set name ?value?
198 This method sets the configuration variable name to the speci‐
199 fied value and returns the new value of the variable.
200
201 If no value is specified it simply returns the current value,
202 without changing it.
203
204 Note that while the user can set the predefined configuration
205 variables user and format doing so will have no effect, these
206 values will be internally overridden when invoking an import
207 plugin.
208
209 objectName config unset pattern...
210 This method unsets all configuration variables matching the
211 specified glob patterns. If no pattern is specified it will un‐
212 set all currently defined configuration variables.
213
215 Plugins are what this package uses to manage the support for any output
216 format beyond the ToC serialization format. Here we specify the API the
217 objects created by this package use to interact with their plugins.
218
219 A plugin for this package has to follow the rules listed below:
220
221 [1] A plugin is a package.
222
223 [2] The name of a plugin package has the form doctools::toc::ex‐
224 port::FOO, where FOO is the name of the format the plugin will
225 generate output for. This name is also the argument to provide
226 to the various export methods of export manager objects to get a
227 string encoding a table of contents in that format.
228
229 [3] The plugin can expect that the package doctools::toc::ex‐
230 port::plugin is present, as indicator that it was invoked from a
231 genuine plugin manager.
232
233 [4] A plugin has to provide one command, with the signature shown
234 below.
235
236 export serial configuration
237 Whenever an export manager of doctools::toc has to gener‐
238 ate output for a table of contents it will invoke this
239 command.
240
241 string serial
242 This argument will contain the canonical serial‐
243 ization of the table of contents for which to gen‐
244 erate the output. The specification of what a
245 canonical serialization is can be found in the
246 section ToC serialization format.
247
248 dictionary configuration
249 This argument will contain the current configura‐
250 tion to apply to the generation, as a dictionary
251 mapping from variable names to values.
252
253 The following configuration variables have a pre‐
254 defined meaning all plugins have to obey, although
255 they can ignore this information at their discre‐
256 tion. Any other other configuration variables rec‐
257 ognized by a plugin will be described in the man‐
258 page for that plugin.
259
260 user This variable is expected to contain the
261 name of the user owning the process invok‐
262 ing the plugin.
263
264 format This variable is expected to contain the
265 name of the format whose plugin is invoked.
266
267 file This variable, if defined by the user of
268 the table object is expected to contain the
269 name of the input file for which the plugin
270 is generating its output for.
271
272 map This variable, if defined by the user of
273 the table object is expected to contain a
274 dictionary mapping from symbolic document
275 ids used in the table entries to actual
276 paths (or urls). A plugin has to be able to
277 handle the possibility that a document id
278 is without entry in this mapping.
279
280 [5] A single usage cycle of a plugin consists of the invokations of
281 the command export. This call has to leave the plugin in a state
282 where another usage cycle can be run without problems.
283
285 Here we specify the format used by the doctools v2 packages to serial‐
286 ize tables of contents as immutable values for transport, comparison,
287 etc.
288
289 We distinguish between regular and canonical serializations. While a
290 table of contents may have more than one regular serialization only ex‐
291 actly one of them will be canonical.
292
293 regular serialization
294
295 [1] The serialization of any table of contents is a nested
296 Tcl dictionary.
297
298 [2] This dictionary holds a single key, doctools::toc, and
299 its value. This value holds the contents of the table of
300 contents.
301
302 [3] The contents of the table of contents are a Tcl dictio‐
303 nary holding the title of the table of contents, a label,
304 and its elements. The relevant keys and their values are
305
306 title The value is a string containing the title of the
307 table of contents.
308
309 label The value is a string containing a label for the
310 table of contents.
311
312 items The value is a Tcl list holding the elements of
313 the table, in the order they are to be shown.
314
315 Each element is a Tcl list holding the type of the
316 item, and its description, in this order. An al‐
317 ternative description would be that it is a Tcl
318 dictionary holding a single key, the item type,
319 mapped to the item description.
320
321 The two legal item types and their descriptions
322 are
323
324 reference
325 This item describes a single entry in the
326 table of contents, referencing a single
327 document. To this end its value is a Tcl
328 dictionary containing an id for the refer‐
329 enced document, a label, and a longer tex‐
330 tual description which can be associated
331 with the entry. The relevant keys and
332 their values are
333
334 id The value is a string containing the
335 id of the document associated with
336 the entry.
337
338 label The value is a string containing a
339 label for this entry. This string
340 also identifies the entry, and no
341 two entries (references and divi‐
342 sions) in the containing list are
343 allowed to have the same label.
344
345 desc The value is a string containing a
346 longer description for this entry.
347
348 division
349 This item describes a group of entries in
350 the table of contents, inducing a hierarchy
351 of entries. To this end its value is a Tcl
352 dictionary containing a label for the
353 group, an optional id to a document for the
354 whole group, and the list of entries in the
355 group. The relevant keys and their values
356 are
357
358 id The value is a string containing the
359 id of the document associated with
360 the whole group. This key is op‐
361 tional.
362
363 label The value is a string containing a
364 label for the group. This string
365 also identifies the entry, and no
366 two entries (references and divi‐
367 sions) in the containing list are
368 allowed to have the same label.
369
370 items The value is a Tcl list holding the
371 elements of the group, in the order
372 they are to be shown. This list has
373 the same structure as the value for
374 the keyword items used to describe
375 the whole table of contents, see
376 above. This closes the recusrive
377 definition of the structure, with
378 divisions holding the same type of
379 elements as the whole table of con‐
380 tents, including other divisions.
381
382 canonical serialization
383 The canonical serialization of a table of contents has the for‐
384 mat as specified in the previous item, and then additionally
385 satisfies the constraints below, which make it unique among all
386 the possible serializations of this table of contents.
387
388 [1] The keys found in all the nested Tcl dictionaries are
389 sorted in ascending dictionary order, as generated by
390 Tcl's builtin command lsort -increasing -dict.
391
393 This document, and the package it describes, will undoubtedly contain
394 bugs and other problems. Please report such in the category doctools
395 of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
396 also report any ideas for enhancements you may have for either package
397 and/or documentation.
398
399 When proposing code changes, please provide unified diffs, i.e the out‐
400 put of diff -u.
401
402 Note further that attachments are strongly preferred over inlined
403 patches. Attachments can be made by going to the Edit form of the
404 ticket immediately after its creation, and then using the left-most
405 button in the secondary navigation bar.
406
408 HTML, conversion, doctoc, documentation, export, formatting, genera‐
409 tion, json, manpage, markup, nroff, plugin, reference, table, table of
410 contents, tcler's wiki, text, url, wiki
411
413 Documentation tools
414
416 Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>
417
418
419
420
421tcllib 0.2.1 doctools::toc::export(n)