Module:Article history/doc: Difference between revisions

Content deleted Content added
m change source to syntaxhighlight
 
(7 intermediate revisions by 4 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.
 
Line 42 ⟶ 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>isSmall</code> - a boolean showing whether the module is outputting a small banner or not.
* <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 68 ⟶ 70:
* <code>currentTitle</code> - the same as ArticleHistory.currentTitle.
* <code>cfg</code> - the same as ArticleHistory.cfg.
* <code>isSmall</code> - the same as ArticleHistory.isSmall.
 
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, smallSize)</code> - set icon values for the object. <var>icon</var> is the icon filename without any namespace prefix, <var>caption</var> is a caption to use with the icon, and <var>size</var> is the size of the icon when output with a large banner, and <var>smallSize</var> is the size of the icon when output with a small banner. <var>icon</var> and <var>caption</var> can be functions which take an ArticleHistory object as input and return the icon or caption value respectively. Sizes should include any suffixes, e.g. "30px".
* <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 134 ⟶ 135:
 
}}</includeonly>
<noinclude>
[[Category:Module documentation pages]]
</noinclude>