Tcl Library Source Code

Documentation
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

doctools::idx::import - Importing keyword indices

Table Of Contents

SYNOPSIS

package require doctools::idx::import ?0.2.1?
package require Tcl 8.4
package require struct::map
package require doctools::idx::structure
package require snit
package require pluginmgr

::doctools::idx::import objectName
objectName method ?arg arg ...?
objectName destroy
objectName import text text ?format?
objectName import file path ?format?
objectName import object text object text ?format?
objectName import object file object path ?format?
objectName config names
objectName config get
objectName config set name ?value?
objectName config unset pattern...
objectName includes
objectName include add path
objectName include remove path
objectName include clear
IncludeFile currentfile path
import text configuration

DESCRIPTION

This package provides a class to manage the plugins for the import of keyword indices from other formats, i.e. their conversion from, for example docidx, json, etc.

This is one of the three public pillars the management of keyword indices resides on. The other two pillars are

  1. Exporting keyword indices, and

  2. Holding keyword indices

For information about the Concepts of keyword indices, and their parts, see the same-named section. For information about the data structure which is the major output of the manager objects provided by this package see the section Keyword index serialization format.

The plugin system of our class is based on the package pluginmgr, and configured to look for plugins using

  1. the environment variable DOCTOOLS_IDX_IMPORT_PLUGINS,

  2. the environment variable DOCTOOLS_IDX_PLUGINS,

  3. the environment variable DOCTOOLS_PLUGINS,

  4. the path "~/.doctools/idx/import/plugin"

  5. the path "~/.doctools/idx/plugin"

  6. the path "~/.doctools/plugin"

  7. the path "~/.doctools/idx/import/plugins"

  8. the path "~/.doctools/idx/plugins"

  9. the path "~/.doctools/plugins"

  10. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\IMPORT\PLUGINS"

  11. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\PLUGINS"

  12. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"

The last three are used only when the package is run on a machine using Windows(tm) operating system.

The whole system is delivered with two predefined import plugins, namely

Readers wishing to write their own import plugin for some format, i.e. plugin writers reading and understanding the section containing the Import plugin API v2 reference is an absolute necessity, as it specifies the interaction between this package and its plugins in detail.

Concepts

  1. A keyword index consists of a (possibly empty) set of keywords.

  2. Each keyword in the set is identified by its name.

  3. Each keyword has a (possibly empty) set of references.

  4. A reference can be associated with more than one keyword.

  5. A reference not associated with at least one keyword is not possible however.

  6. Each reference is identified by its target, specified as either an url or symbolic filename, depending on the type of reference (url, or manpage).

  7. The type of a reference (url, or manpage) depends only on the reference itself, and not the keywords it is associated with.

  8. In addition to a type each reference has a descriptive label as well. This label depends only on the reference itself, and not the keywords it is associated with.

A few notes

  1. Manpage references are intended to be used for references to the documents the index is made for. Their target is a symbolic file name identifying the document, and export plugins may replace symbolic with actual file names, if specified.

  2. Url references are intended on the othre hand are inteded to be used for links to anything else, like websites. Their target is an url.

  3. While url and manpage references share a namespace for their identifiers, this should be no problem, given that manpage identifiers are symbolic filenames and as such they should never look like urls, the identifiers for url references.

API

Package commands

Object command

All objects created by the ::doctools::idx::import command have the following general form:

Object methods

Import plugin API v2 reference

Plugins are what this package uses to manage the support for any input format beyond the Keyword index serialization format. Here we specify the API the objects created by this package use to interact with their plugins.

A plugin for this package has to follow the rules listed below:

  1. A plugin is a package.

  2. The name of a plugin package has the form doctools::idx::import::FOO, where FOO is the name of the format the plugin will generate output for. This name is also the argument to provide to the various import methods of import manager objects to get a string encoding a keyword index in that format.

  3. The plugin can expect that the package doctools::idx::export::plugin is present, as indicator that it was invoked from a genuine plugin manager.

  4. The plugin can expect that a command named IncludeFile is present, with the signature

    • IncludeFile currentfile path

      This command has to be invoked by the plugin when it has to process an included file, if the format has the concept of such. An example of such a format would be docidx.

      The plugin has to supply the following arguments

      • string currentfile

        The path of the file it is currently processing. This may be the empty string if no such is known.

      • string path

        The path of the include file as specified in the include directive being processed.

      The result of the command will be a 5-element list containing 1) A boolean flag indicating the success (True) or failure (False) of the operation. 1) In case of success the contents of the included file, and the empty string otherwise. 1) The resolved, i.e. absolute path of the included file, if possible, or the unchanged path argument. This is for display in an error message, or as the currentfile argument of another call to IncludeFile should this file contain more files. 1) In case of success an empty string, and for failure a code indicating the reason for it, one of

          * notfound
      
            The specified file could not be found\.
      
          * notread
      
            The specified file was found, but not be read into memory\.
      
      1. An empty string in case of success of a notfound failure, and an additional error message describing the reason for a notread error in more detail.
  5. A plugin has to provide one command, with the signature shown below.

    • import text configuration

      Whenever an import manager of doctools::idx has to parse input for an index it will invoke this command.

      • string text

        This argument will contain the text encoding the index per the format the plugin is for.

      • dictionary configuration

        This argument will contain the current configuration to apply to the parsing, as a dictionary mapping from variable names to values.

        The following configuration variables have a predefined meaning all plugins have to obey, although they can ignore this information at their discretion. Any other other configuration variables recognized by a plugin will be described in the manpage for that plugin.

        • user

          This variable is expected to contain the name of the user owning the process invoking the plugin.

        • format

          This variable is expected to contain the name of the format whose plugin is invoked.

  6. A single usage cycle of a plugin consists of the invokations of the command import. This call has to leave the plugin in a state where another usage cycle can be run without problems.

Keyword index serialization format

Here 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. While a keyword index may have more than one regular serialization only exactly one of them will be canonical.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category doctools of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

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.

KEYWORDS

conversion, docidx, documentation, import, index, json, keyword index, manpage, markup, parsing, plugin, reference, url

CATEGORY

Documentation tools

COPYRIGHT

Copyright © 2009-2019 Andreas Kupries