doctools:...port::json(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ¦‹ 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 the string and parses it as JSON markup encoding a keyword index, in the context of the specified configuration (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 references dictionary β€” see the next item for its definition. no skipping, bestie.
    • 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 keywords dictionary β€” see the previous item for its definition.
  • [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 (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