Jump to content

Module:Article history/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 11:55, 10 December 2014 (add some more). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This module implements Template:Article history (edit | talk | history | links | watch | logs). It has a configuration module at Module:Article history/config (edit | talk | history | links | watch | logs), and a Category class at Module:Article history/Category (edit | talk | history | links | watch | logs).

Object documentation

ArticleHistory

ArticleHistory objects have the following public properties:

  • args - a table of the arguments passed to the module by the user.
  • currentTitle - the title object for the current page.
  • cfg - 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 { foo = {"a value", aliases = {"bar", "baz"} } } would become {foo = {"a value"}, bar = {"a value"}, baz = {"a value"} }. (Although "bar" and "baz" would actually be references to the "foo" table, rather than completely new tables.)
  • isSmall - a boolean showing whether the module is outputting a small banner or not.
  • prefixArgs - 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 {a1x = 'eggs', a1y = 'spam', a2x = 'chips', b1z = 'beans', b3x = 'bacon'} would translate into the prefixArgs table {a = { {1, x = 'eggs', y = 'spam'}, {2, x = 'chips'} }, b = { {1, z = 'beans'}, {3, x = 'bacon'} } }.

They have the following methods:

  • ArticleHistory:try(func, ...) - calls the function func with the arguments passed, and returns the first value produced by it. If any errors are encountered, they are caught and added to the object's internal errors table for later rendering by ArticleHistory:getErrorMessages.
  • ArticleHistory:getActionObjects() - returns an array containing the Action objects for any actions specified by the user.