Content deleted Content added
→Class documentation: add Category class |
Added the page to Category:Module documentation pages |
||
(12 intermediate revisions by 8 users not shown) | |||
Line 1:
{{Module rating|protected}}
{{High-use}}
{{Lua|Module:Article history/config|Module:Article history/Category|Module:Yesno|Module:Arguments}}
{{Uses TemplateStyles|Module:Message box/tmbox.css|Module:Article history/styles.css}}
This module implements {{lt|Article history}}. Please see the template page for documentation of how to use it.
== Technical details ==
This module has a configuration module at [[Module:Article history/config]], which can be used to translate/modify the template for use on other wikis. See the config module for instructions on how to modify it. The configuration for the English Wikipedia is very complicated, but it is also possible to use it much more simply. If you want to use the more advanced features provided by the module, you can consult the class documentation below.
There is also a Category class at [[Module:Article history/Category]], which is used by both the main module and the config module.
== Class documentation ==
Line 9 ⟶ 19:
The Category class is used to generate all of the module's categories. It is loaded in both [[Module:Article history]] and [[Module:Article history/config]]. You can create a category with Category.new:
<
The <var>cat</var> variable is the category text, and <var>sort</var> is its sort key.
Line 21 ⟶ 31:
=== Message ===
The Message mixin contains common message-related methods which
* <code>Message:message(key, ...)</code> - fetches a message with the key <var>key</var> from the config's msg table, and substitutes parameters $1, $2 etc. with the subsequent values it is passed.
Line 35 ⟶ 45:
* <code>currentTitle</code> - the [[mw:Extension:Scribunto/Lua reference manual|title object]] for the current page.
* <code>cfg</code> - the module config table. This is taken from the config module at [[Module:Article history/config]], but is structured slightly differently due to preprocessing by the main module. Any table with an "aliases" subtable has this table removed, and the aliases are added as keys that the table can be accessed from. Conceptually, the config table {{code|1={ foo = {"a value", aliases = {"bar", "baz"} } }|2=lua}} would become {{code|1={foo = {"a value"}, bar = {"a value"}, baz = {"a value"} }|2=lua}}. (Although "bar" and "baz" would actually be references to the "foo" table, rather than completely new tables.)
* <code>prefixArgs</code> - a table of the arguments passed to the module by the user, sorted by their prefix and then their number. Non-string keys and keys that don't contain a number are ignored. (This means that positional parameters are ignored, as they are numbers, not strings.) The parameter numbers are stored in the first positional parameter of the subtables, and any gaps are removed so that the tables can be iterated over with ipairs. For example, the arguments {{code|1={a1x = 'eggs', a1y = 'spam', a2x = 'chips', b1z = 'beans', b3x = 'bacon'}|2=lua}} would translate into the prefixArgs table {{code|1={a = { {1, x = 'eggs', y = 'spam'}, {2, x = 'chips'} }, b = { {1, z = 'beans'}, {3, x = 'bacon'} } }|2=lua}}.
Line 61 ⟶ 70:
* <code>currentTitle</code> - the same as ArticleHistory.currentTitle.
* <code>cfg</code> - the same as ArticleHistory.cfg.
Row objects have the following public methods:
* <code>Row:getData(articleHistoryObj)</code> - get memoized data for the object that has been created with a makeData function in the module config page. This mechanism is used to stop config page functions from having to do the same data processing more than once. It must be passed an ArticleHistory object to find the data from. This returns nil if no data was generated or an error was encountered while generating the data.
* <code>Row:setIconValues(icon, caption, size
* <code>Row:getIcon(articleHistoryObj)</code> - get the icon filename. It must be passed an ArticleHistory object. Returns nil if no icon was set.
* <code>Row:getIconCaption(articleHistoryObj)</code> - get the icon caption. It must be passed an ArticleHistory object. Returns nil if no caption was set.
Line 127 ⟶ 135:
}}</includeonly>
<noinclude>
[[Category:Module documentation pages]]
</noinclude>
|