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 365 366 367 368 369 370
|
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin doctools::toc n 2]
[keywords conversion]
[keywords {doctoc markup}]
[keywords documentation]
[keywords formatting]
[keywords generation]
[keywords HTML]
[keywords json]
[keywords latex]
[keywords markup]
[keywords nroff]
[keywords parsing]
[keywords plugin]
[keywords reference]
[keywords table]
[keywords {table of contents}]
[keywords {tcler's wiki}]
[keywords text]
[keywords TMML]
[keywords wiki]
[copyright {2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>}]
[moddesc {Documentation tools}]
[titledesc {Holding tables of contents}]
[category {Documentation tools}]
[require doctools::toc [opt 2]]
[require Tcl 8.4]
[require doctools::toc::structure]
[require struct::tree]
[require snit]
[description]
This package provides a class to contain and programmatically
manipulate tables of contents.
[para]
This is one of the three public pillars the management of tables of
contents resides on. The other two pillars are
[list_begin enum]
[enum] [manpage {Exporting tables of contents}], and
[enum] [manpage {Importing tables of contents}]
[list_end]
[para]
For information about the [sectref Concepts] of tables of contents, and
their parts, see the same-named section.
For information about the data structure which is used to encode
tables of contents as values see the section
[sectref {ToC serialization format}].
This is the only format directly known to this class. Conversions from
and to any other format are handled by export and import manager
objects. These may be attached to a container, but do not have to be,
it is merely a convenience.
[section Concepts] [include include/concept.inc]
[section API]
[subsection {Package commands}]
[list_begin definitions]
[call [cmd ::doctools::toc] [arg objectName]]
This command creates a new container object with an associated Tcl
command whose name is [arg objectName]. This [term object] command is
explained in full detail in the sections [sectref {Object command}]
and [sectref {Object methods}]. The object command will be created
under the current namespace if the [arg objectName] is not fully
qualified, and in the specified namespace otherwise.
[list_end]
[subsection {Object command}]
All objects created by the [cmd ::doctools::toc] command have the
following general form:
[list_begin definitions]
[call [cmd objectName] [method method] [opt [arg "arg arg ..."]]]
The method [method method] and its [arg arg]'uments determine the
exact behavior of the command.
See section [sectref {Object methods}] for the detailed
specifications.
[list_end]
[subsection {Object methods}]
[list_begin definitions]
[call [arg objectName] [method destroy]]
This method destroys the object it is invoked for.
[call [arg objectName] [method {+ reference}] [arg id] [arg label] [arg docid] [arg desc]]
This method adds a new reference element to the table of contents,
under the element specified via its handle [arg id]. This parent
element has to be a division element, or the root. An error is thrown
otherwise.
The new element will be externally identified by its [arg label],
which has to be be unique within the parent element. An error is
thrown otherwise.
[para]
As a reference element it will refer to a document identified by the
symbolic [arg docid]. This reference must not be the empty string, an
error is thrown otherwise.
Beyond the label the element also has a longer descriptive string,
supplied via [arg desc].
[para]
The result of the method is the handle (id) of the new element.
[call [arg objectName] [method {+ division}] [arg id] [arg label] [opt [arg docid]]]
This method adds a new division element to the table of contents,
under the element specified via its handle [arg id]. This parent
element has to be a division element, or the root. An error is thrown
otherwise.
The new element will be externally identified by its [arg label],
which has to be be unique within the parent element. An error is
thrown otherwise.
[para]
As a division element it is can refer to a document, identified by the
symbolic [arg docid], but may choose not to.
[para]
The result of the method is the handle (id) of the new element.
[call [arg objectName] [method remove] [arg id]]
This method removes the element identified by the handle [arg id] from
the table of contents.
If the element is a division all of its children, if any, are removed
as well. The root element/division of the table of contents cannot be
removed however, only its children.
[para]
The result of the method is the empty string.
[call [arg objectName] [method up] [arg id]]
This method returns the handle of the parent for the element
identified by its handle [arg id], or the empty string if [arg id]
referred to the root element.
[call [arg objectName] [method next] [arg id]]
This method returns the handle of the right sibling for the element
identified by its handle [arg id], or the handle of the parent if the
element has no right sibling, or the empty string if [arg id] referred
to the root element.
[call [arg objectName] [method prev] [arg id]]
This method returns the handle of the left sibling for the element
identified by its handle [arg id], or the handle of the parent if the
element has no left sibling, or the empty string if [arg id] referred
to the root element.
[call [arg objectName] [method child] [arg id] [arg label] [opt [arg ...]]]
This method returns the handle of a child of the element identified by
its handle [arg id]. The child itself is identified by a series of
labels.
[call [arg objectName] [method element] [opt [arg ...]]]
This method returns the handle of the element identified by a series
of labels, starting from the root of the table of contents. The series
of labels is allowed to be empty, in which case the handle of the root
element is returned.
[call [arg objectName] [method children] [arg id]]
This method returns a list containing the handles of all children of
the element identified by the handle [arg id], from first to last, in
that order.
[call [arg objectName] [method type] [arg id]]
This method returns the type of the element, either [const reference],
or [const division].
[call [arg objectName] [method full-label] [arg id]]
This method is the complement of the method [method element],
converting the handle [arg id] of an element into a list of labels
full identifying the element within the whole table of contents.
[call [arg objectName] [method elabel] [arg id] [opt [arg newlabel]]]
This method queries and/or changes the label of the element identified
by the handle [arg id]. If the argument [arg newlabel] is present then
the label is changed to that value. Regardless of this, the result of
the method is the current value of the label.
[para]
If the label is changed the new label has to be unique within the
containing division, or an error is thrown.
[para]
Further, of the [arg id] refers to the root element of the table of
contents, then using this method is equivalent to using the method
[arg label], i.e. it is accessing the global label for the whole
table.
[call [arg objectName] [method description] [arg id] [opt [arg newdesc]]]
This method queries and/or changes the description of the element
identified by the handle [arg id]. If the argument [arg newdesc] is
present then the description is changed to that value. Regardless of
this, the result of the method is the current value of the description.
[para]
The element this method operates on has to be a reference element, or
an error will be thrown.
[call [arg objectName] [method document] [arg id] [opt [arg newdocid]]]
This method queries and/or changes the document reference of the
element identified by the handle [arg id].
If the argument [arg newdocid] is present then the description is
changed to that value. Regardless of this, the result of the method is
the current value of the document reference.
[para]
Setting the reference to the empty string means unsetting it, and is
allowed only for division elements. Conversely, if the result is the
empty string then the element has no document reference, and this can
happen only for division elements.
[call [arg objectName] [method title]]
Returns the currently defined title of the table of contents.
[call [arg objectName] [method title] [arg text]]
Sets the title of the table of contents to [arg text], and returns it as
the result of the command.
[call [arg objectName] [method label]]
Returns the currently defined label of the table of contents.
[call [arg objectName] [method label] [arg text]]
Sets the label of the table of contents to [arg text], and returns it as
the result of the command.
[call [arg objectName] [method importer]]
Returns the import manager object currently attached to the container,
if any.
[call [arg objectName] [method importer] [arg object]]
Attaches the [arg object] as import manager to the container, and
returns it as the result of the command.
Note that the [arg object] is [emph not] put into ownership of the
container. I.e., destruction of the container will [emph not] destroy
the [arg object].
[para]
It is expected that [arg object] provides a method named
[method {import text}] which takes a text and a format name, and
returns the canonical serialization of the table of contents contained in
the text, assuming the given format.
[call [arg objectName] [method exporter]]
Returns the export manager object currently attached to the container,
if any.
[call [arg objectName] [method exporter] [arg object]]
Attaches the [arg object] as export manager to the container, and
returns it as the result of the command.
Note that the [arg object] is [emph not] put into ownership of the
container. I.e., destruction of the container will [emph not] destroy
the [arg object].
[para]
It is expected that [arg object] provides a method named
[method {export object}] which takes the container and a format name,
and returns a text encoding table of contents stored in the container, in
the given format. It is further expected that the [arg object] will
use the container's method [method serialize] to obtain the
serialization of the table of contents from which to generate the text.
[call [arg objectName] [method {deserialize =}] [arg data] [opt [arg format]]]
This method replaces the contents of the table object with the table
contained in the [arg data]. If no [arg format] was specified it is
assumed to be the regular serialization of a table of contents.
[para]
Otherwise the object will use the attached import manager to convert
the data from the specified format to a serialization it can handle.
In that case an error will be thrown if the container has no import
manager attached to it.
[para]
The result of the method is the empty string.
[call [arg objectName] [method {deserialize +=}] [arg data] [opt [arg format]]]
This method behaves like [method {deserialize =}] in its essentials,
except that it merges the table of contents in the [arg data] to its
contents instead of replacing it.
The method will throw an error if merging is not possible, i.e. would
produce an invalid table. The existing content is left unchanged in
that case.
[para]
The result of the method is the empty string.
[call [arg objectName] [method serialize] [opt [arg format]]]
This method returns the table of contents contained in the object. If no
[arg format] is not specified the returned result is the canonical
serialization of its contents.
[para]
Otherwise the object will use the attached export manager to convert
the data to the specified format.
In that case an error will be thrown if the container has no export
manager attached to it.
[list_end]
[include include/serialization.inc]
[vset CATEGORY doctools]
[include ../common-text/feedback.inc]
[manpage_end]
|