Module:Article history/doc: Difference between revisions

Content deleted Content added
finish the Row class docs
finish documenting all the classes
Line 5:
=== Message ===
 
Methods from theThe Message mixin arecontains availablecommon message-related methods which areavailable in all classes. TheyThese methods are:
 
* <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 14:
=== ArticleHistory ===
 
An ArticleHistory object does the main work of the module. It fetches the different Row objects, renders the box, renders the error messages, and renders category links. ArticleHistory objects can use all methods from the [[#Message|Message]] mixin. They also have the following public properties:
 
* <code>args</code> - a table of the arguments passed to the module by the user.
Line 22:
* <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}}.
 
TheyArticleHistory objects have the following public methods:
 
* <code>ArticleHistory:try(func, ...)</code> - calls the function <var>func</var> 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.
Line 61:
* <code>Row:setText(text)</code> - set the text for the object to output. This may be a string or a function that takes an ArticleHistory object as input and returns the text as output.
* <code>Row:getText(articleHistoryObject)</code> - gets the row text. This method must be passed an ArticleHistory object.
* <code>Row:exportHtml(articleHistoryObject)</code> - returns the rendered row. This method must be passed an ArticleHistory object.
* <code>Row:setCategories(val)</code> - sets the objects categories. <var>val</var> may be either an array of strings, or a function that takes an ArticleHistory object as input and returns an array of Category objects as output.
* <code>Row:getCategories(articleHistoryObj)</code> - returns an array containing the object's Category objects. This method must be passed an ArticleHistory object.
 
=== Status ===
 
Status objects generate the row detailing the current status of the article. They inherit all properties and methods from [[#Row|Row]] objects, including the [[#Message|Message]] mixin methods. They have the following additional properties:
 
* <code>id</code> - the status ID.
* <code>name</code> - the status name.
* <code>statusCfg</code> - the status config table for the object's status ID.
 
=== MultiStatus ===
 
MultiStatus objects are variations on [[#Status|Status]] objects for articles that can have multiple current statuses, e.g. Good Article and Former Featured Article. They can be used interchangeably with Status objects.
 
=== Notice ===
 
Notice objects generate rows containing notices about the article that aren't part of its current status, e.g. the date the article was featured on the Main Page. They inherit all the properties and methods from [[#Row|Row]] objects, including the [[#Message|Message]] mixin methods. They don't have any additional properties or methods.
 
=== Action ===
 
Action objects generate rows detailing a single action in the history of an article, e.g. a Featured Article candidacy. They inherit all properties and methods from [[#Row|Row]] objects, including the [[#Message|Message]] mixin methods. They have the following additional properties:
 
* <code>paramNum</code> - the parameter number for that action. Used to format error messages.
* <code>id</code> - the action ID. For example, featured article candidacies have an ID of "FAC". There is only one ID for each kind of action.
* <code>actionCfg</code> - the action config table for the object's action ID.
* <code>link</code> - the link set for the action, or the current talk page name if not set.
* <code>resultId</code> - the ID for the result of the action. For example, featured article candidates that were promoted have a resultId of "promoted". There is only one resultId for each possible result of an action.
* <code>date</code> - the date the action was carried out, or the 'action-date-missing' message if a date was not set.
* <code>oldid</code> - the oldid for the action. Nil if not set.
 
Action objects have the following additional methods:
 
* <code>Action:getParameter(key)</code> - finds the original parameter name for the key <var>key</var> that was passed to Action.new.
* <code>Action:getName(articleHistoryObject)</code> - gets the name of the action. This method must be passed an ArticleHistory object.
* <code>Action:getResult(articleHistoryObject)</code> - gets the result text of the action. This method must be passed an ArticleHistory object.
 
=== CollapsibleNotice ===
 
CollapsibleNotice objects generate rows containing notices that go in the collapsible part of the template, underneath the list of actions. They can also include a collapsible text field. This is used for notices that are not important enough to be displayed as a (more prominent) [[#Notice|Notice]] object, e.g. DYK notices. CollapsibleNotice objects inherit all the properties and methods from [[#Row|Row]] objects, including the [[#Message|Message]] mixin methods. They don't have any additional properties, but they have the following additional methods:
 
* <code>CollapsibleNotice:setCollapsibleText(s)</code> - set's <var>s</var> as the text to be displayed in the object's collapsible text field.
* <code>CollapsibleNotice:getCollapsibleText(s)</code> - returns the text to be displayed in the object's collapsible text field.
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||