doctools:...port::json(3tcl)
π¦ NAME π¦
okay so this page β from tcllib, manual section 3tcl β is all about doctools::idx::import::json, aka the JSON import plugin β¨
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require doctools::idx::import::json ?0.2.1?
package require doctools::idx::structure
package require json
import string configuration
π DESCRIPTION π
so this package? it implements the doctools keyword index import plugin for parsing JSON markup. that's the whole gig. π
ngl, this one is an internal package of doctools β it's meant for the higher level management packages that handle keyword indices, especially doctools::idx::import, the import manager. so if you're here thinking "ooh let me just call this directly", bestieβ¦ it is possible to use it from a regular interpreter, but only with contortions π and it is not recommended. the proper way to use this functionality is through the package doctools::idx::import and the import manager objects it provides. that's the vibe. π«Ά
π API π
the API this package hands you satisfies the specification of the docidx import plugin API version 2 β
import string configurationβ takes thestringand parses it as JSON markup encoding a keyword index, in the context of the specifiedconfiguration(a dictionary). and then β iconic part β the result of the command is the canonical serialization of that keyword index, in the form specified in the section Keyword index serialization format. no cap. π
π§ JSON NOTATION OF KEYWORD INDICES π§
so the JSON format used for keyword indices is a direct translation of the Keyword index serialization format, mapping Tcl dictionaries as JSON objects and Tcl lists as JSON arrays. yes, it's giving "one-to-one", and we love that for it. π
for example, this Tcl serialization π
doctools::idx {
label {Keyword Index}
keywords {
changelog {changelog.man cvs.man}
conversion {doctools.man docidx.man doctoc.man apps/dtplite.man mpexpand.man}
cvs cvs.man
}
references {
apps/dtplite.man {manpage dtplite}
changelog.man {manpage doctools::changelog}
cvs.man {manpage doctools::cvs}
docidx.man {manpage doctools::idx}
doctoc.man {manpage doctools::toc}
doctools.man {manpage doctools}
mpexpand.man {manpage mpexpand}
}
title {}
}
is equivalent to the JSON string π
{
"doctools::idx" : {
"label" : "Keyword Index",
"keywords" : {
"changelog" : ["changelog.man","cvs.man"],
"conversion" : ["doctools.man","docidx.man","doctoc.man","apps\/dtplite.man","mpexpand.man"],
"cvs" : ["cvs.man"],
},
"references" : {
"apps\/dtplite.man" : ["manpage","dtplite"],
"changelog.man" : ["manpage","doctools::changelog"],
"cvs.man" : ["manpage","doctools::cvs"],
"docidx.man" : ["manpage","doctools::idx"],
"doctoc.man" : ["manpage","doctools::toc"],
"doctools.man" : ["manpage","doctools"],
"mpexpand.man" : ["manpage","mpexpand"]
},
"title" : ""
}
}
π KEYWORD INDEX SERIALIZATION FORMAT π
here's where we specify the format used by the doctools v2 packages to serialize keyword indices as immutable values for transport, comparison, etc. β¨
we distinguish between regular and canonical serializations. a keyword index may have more than one regular serialization β but only exactly one of them will be canonical. main character energy, honestly. π
π regular serialization π
- [1] an index serialization is a nested Tcl dictionary.
- [2] this dictionary holds a single key,
doctools::idx, and its value. this value holds the contents of the index. - [3] the contents of the index are a Tcl dictionary holding the title of the index, a label, and the keywords and references. the relevant keys and their values are:
titleβ the value is a string containing the title of the index.labelβ the value is a string containing a label for the index.keywordsβ the value is a Tcl dictionary, using the keywords known to the index as keys. the associated values are lists containing the identifiers of the references associated with that particular keyword.- any reference identifier used in these lists has to exist as a key in the
referencesdictionary β see the next item for its definition. no skipping, bestie.
- any reference identifier used in these lists has to exist as a key in the
referencesβ the value is a Tcl dictionary, using the identifiers for the references known to the index as keys. the associated values are 2-element lists containing the type and label of the reference, in this order.- any key here has to be associated with at least one keyword, i.e. occur in at least one of the reference lists which are the values in the
keywordsdictionary β see the previous item for its definition.
- any key here has to be associated with at least one keyword, i.e. occur in at least one of the reference lists which are the values in the
- [4] the type of a reference can be one of two values:
manpageβ the identifier of the reference is interpreted as symbolic file name, referring to one of the documents the index was made for.urlβ the identifier of the reference is interpreted as an url, referring to some external location, like a website, etc.
β¨ canonical serialization β¨
the canonical serialization of a keyword index has the format as specified in the previous item, and then additionally satisfies the constraints below, which make it unique among all the possible serializations of the keyword index. it's the one true version. π«
- [1] the keys found in all the nested Tcl dictionaries are sorted in ascending dictionary order, as generated by Tcl's builtin command
lsort -increasing -dict. - [2] the references listed for each keyword of the index, if any, are listed in ascending dictionary order of their labels, as generated by Tcl's builtin command
lsort -increasing -dict.
π BUGS, IDEAS, FEEDBACK π
okay listen β this document, and the package it describes, will undoubtedly contain bugs and other problems. not me being shady, it's just what it says. π so please report such in the category doctools of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and please also report any ideas for enhancements you may have for either the package and/or the documentation. we love ideas. π«Ά
when proposing code changes, please provide unified diffs, i.e the output of diff -u.
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. yes, that specific button. the left-most one. π
π₯ KEYWORDS π₯
JSON, deserialization, doctools, import, index
π CATEGORY π
Text formatter plugin
π COPYRIGHT π
Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie π this was tcllib, version 0.2.1, page doctools:...port::json(3tcl) β go forth and import those keyword indices, periodt. ππ¦β¨
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms