Module:Sandbox/AbstractWikipedia/Renderers/doc

This is the documentation page for Module:Sandbox/AbstractWikipedia/Renderers

This module contains some generic renderer code of the template-renderer prototype.

The specific renderers for each language should live in a language-specific sub-module identified by the language code. Currently there are two such sub-modules:

General structure of renderers

edit

Renderers are tables, containing the templates needed for each constructor. They should be named after the _predicate field of the constructor type they serve to realize. For each constructor type we have a main template and possible sub-templates, which will become accessible for its realization.

However, each template identifier corresponds in fact to a list of templates, gated by various conditions. These different templates are conditioned on the validity field, which lists the arguments which must be present for it to realize.

Another type of condition is given by the roles field: this lists the possible grammatical roles (as given by dependency labels), which the given template variant can fulfill. If this list is given, the invocation of the template must use one of the given labels to trigger this variant. However, an empty role "" can be given to match for the absence of a label.

If none of the conditions holds, an empty template is returned.

In the future we may want to add a conditions field, which would allow template variants to be gated on more elaborate conditions.

Thus, the general structure of a renderer (in a language-specific sub-module) is the following:

p.RendererName = { main = { -- list of conditioned templates

{ -- template 1

validity = { ... }, -- list of mandatory arguments

         roles = { ... }, -- list of possible grammatical roles

template = "..." -- the actual template

},

{ -- template 2}, -- etc.

}

some_sub_template = { } -- list of conditioned templates

another_sub_template = { } -- etc.

}

Functions exposed by the module

edit

The current module exposes two functions:

1. selectMainTemplate: Given a collection of conditioned template-lists corresponding to a constructor, select the main one to be realized.

2. selectTemplate: Select from a list of conditioned templates the first template which fulfills its conditions.