Guidelines:Modules/Data: Difference between revisions
PhantomCaleb (talk | contribs) |
mNo edit summary |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ZW Nav|Guidelines}} | {{ZW Nav|Guidelines}} | ||
:''The following guidelines concern <code>/Data</code> subpages in the module namespace. These are not to be confused with the pages in <code>Data</code> namespace. | :''The following guidelines concern <code>/Data</code> subpages in the module namespace. These are not to be confused with the pages in <code>Data</code> namespace.'' | ||
Some modules rely on configuration data to generate output. By convention, this data is placed on a <code>/Data</code> subpage of the module. [[Module: | Some modules rely on configuration data to generate output. By convention, this data is placed on a <code>/Data</code> subpage of the module. [[Module:ItemsNav/Data]] is an example of such a page — it contains all the data for generating the [[:Category:Item navigation templates|item navigation templates]]. [[:Category:Module Data]] provides the list of such pages. | ||
<code>/Data</code> pages exist to separate module data from the programmed logic that operates on the data. It is a {{Wp|separation of concerns}}. <code>/Data</code> pages require less programming knowledge to edit and are meant to be changed more frequently by a wider range of contributors. | <code>/Data</code> pages exist to separate module data from the programmed logic that operates on the data. It is a {{Wp|separation of concerns}}. <code>/Data</code> pages require less programming knowledge to edit and are meant to be changed more frequently by a wider range of contributors. | ||
Line 16: | Line 16: | ||
==Visualization== | ==Visualization== | ||
Some <code>/Data</code> pages display a tabular view of the data using the [[Module:Documentation#Data|Documentation]] module. See [[Module: | Some <code>/Data</code> pages display a tabular view of the data using the [[Module:Documentation#Data|Documentation]] module. See [[Module:Language/Data]] and [[Module:Scale/Data]], for example. | ||
Most <code>/Data</code> pages also provide a [[Module: | Most <code>/Data</code> pages also provide a [[Module:Documentation#Schemas|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== | ==How it Works== | ||
Line 26: | Line 26: | ||
The data is loaded by the base module using {{Scribunto Manual|lib=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). | The data is loaded by the base module using {{Scribunto Manual|lib=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 <code>/Data</code> suffix — this is only a Zelda Wiki convention that is useful for [[Module:Documentation|documentation automation]] and building a common understanding of the wiki's modules work. | These pages do not necessarily need to be named with a <code>/Data</code> suffix — this is only a Zelda Wiki convention that is useful for [[Module:Documentation|documentation automation]] and building a common understanding of how the wiki's modules work. | ||
{{Guidelines Nav}} | {{Guidelines Nav}} |
Latest revision as of 13:02, 9 December 2023
- The following guidelines concern
/Data
subpages in the module namespace. These are not to be confused with the pages inData
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
-
On large
/Data
pages, collapse surrounding fragments to focus on a particular area. -
The code editor has its own find/replace tool. Click inside the editor and type Ctrl+F to use it.
-
Use the "preview page with this" functionality to preview changes to module data.
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
/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.