Guidelines:Modules/Data

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
The following guidelines concern /Data subpages in the module namespace. These are not to be confused with the pages in Data namespace.

Some modules rely on configuration data to generate output. By convention, this data is placed on a /Data subpage of the module. Module:ItemsNav/Data is an example of such a page — it contains all the data for generating the item navigation templates. Category:Module Data provides the list of such pages.

/Data pages exist to separate module data from the programmed logic that operates on the data. It is a separation of concerns. /Data pages require less programming knowledge to edit and are meant to be changed more frequently by a wider range of contributors.

Editing

Visualization

Some /Data pages display a tabular view of the data using the Documentation module. See Module:Language/Data and Module:Scale/Data, for example.

Most /Data pages also provide a schema which describes the format and fields for the data page. Currently it may be easier to understand the general format by looking directly at the data, but the schema can at least help you understand in detail what fields exist and what they are for.

How it Works

Main article: Guidelines:Modules

/Data pages use a subset of regular Lua syntax. They each return one large Lua table which may contain nested tables, strings, numbers, or booleans. /Data pages resemble JSON files in that regard.

The data is loaded by the base module using mw.loadData. The data is read-only and is loaded only once per wiki page, as opposed to other module code which is loaded each time it is used on a page (usually via a template).

These pages do not necessarily need to be named with a /Data suffix — this is only a Zelda Wiki convention that is useful for documentation automation and building a common understanding of how the wiki's modules work.