Module:Quotations/documentation

This module is used by Template:Q.

Coding
The intent of this module was to make a quotations library which can be built and used asynchronously. An editor can reference a work or author which is not yet coded, and the display will still look fine, and if the information is later coded, the template will make use of it at that time.

Language modules
Each language needs its own module, such as that found at Module:Quotations/grc, which can be used as a starting point in creating a language module which does not yet exist. This module takes the information and does the lookups in its data module (in this case Module:Quotations/grc/data), and returns the results to be formatted by the main module.

The data module should be a table, with entries for each author. Each author table should include information about the author, such as years active and the title of the Wikipedia article for the author, as well as tables for each of its works, with information such as the year the work was written, the title of its Wikipedia article, and the title of its Wiksource article. Alias tables can be used for convergence, such as when a work might have two common titles, as well as abbreviations.

Note that the module is designed to work with whatever data is available, and it should not be considered necessary to add all possible data; some is better than none.

Note: In order for a language module to be recognized, the corresponding language code must be added to the  table in this module.

Reference link
One of the more complex aspects of coding the data set lies in the reference link, which is meant to be a fairly dynamic link which formats itself to account for information given. It is formatted in the author's data table as a table of strings and tables. Strings not prefixed by a period are inserted as is. Strings prefixed with a period indicate variable references. Tables which begin with a function run that function with the table's following elements as parameters. Tables not beginning with a function are nested variable addresses. Take the reference link format table lua, which is used solely by Plato's Republic:

lua

The first element, lua, is a simple string, and will be inserted as-is into the link target; it is the prefix for the Greek Wikisource, where a native language version of The Republic is found.

The second element, lua, begins with a period, indicating that it should be replaced by the variable lua, which is given in The Republic’s data table as lua.

The third element, lua, is a standard string, and will be inserted into the link as-is.

The fourth element is a function call, using the function, which is called with two parameters. The second parameter is the variable, which is the chapter given by the user. The first parameter is formatted as a nested reference, it will be the variable, which is found within.

There is no getting around the fact that it is not the easiest format in the world, but it does make for a powerful and flexible engine to interpret data and create the proper link.

External Reference link
If the source is not wikilinkable, then you'll need an external reference link instead of a reference link. You can use the same method as reference links, except use lua instead of lua, and the URL to link to is the lua parameter for the work. For example: