Module:Article history/doc: Difference between revisions

Content deleted Content added
add some more
finish documenting ArticleHistory objects
Line 13:
* <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}}.
 
They 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.
* <code>ArticleHistory:getActionObjects()</code> - returns an array containing the Action objects for any actions specified by the user.
* <code>ArticleHistory:getStatusIdForCode(code)</code> - for the status code <var>code</var>, returns the canonical status ID.
* <code>ArticleHistory:getStatusObj()</code> - gets the status object for the template. This returns nil if no current status can be found.
* <code>ArticleHistory:getStatusId()</code> - returns the status ID for the template. This returns nil if no current status can be found.
* <code>ArticleHistory:getNoticeObjects()</code> - returns an array containing the template's Notice objects.
* <code>ArticleHistory:getCollapsibleNoticeObjects()</code> - returns an array containing the template's CollapsibleNotice objects.
* <code>ArticleHistory:getAllObjects(addSelf)</code> - returns an array containing all Status, Notice, Action and CollapsibleNotice objects. if <var>addSelf</var> is true, the ArticleHistory object is appended to the array as well.
* <code>ArticleHistory:getErrorMessages()</code> - returns an array containing all error and warning strings. Errors are typically raised with Message:raiseError and caught with ArticleHistory:try, and warnings are added to individual objects with Message:addWarning.
* <code>ArticleHistory:renderHtml()</code> - renders the HTML table comprising all the visible output of the template, including status, notices, actions, collapsible notices, error messages and warnings. The result is returned as a string.
* <code>ArticleHistory:renderCategories()</code> - renders all category links and returns them as a string.
 
Calling <code>tostring()</code> on an ArticleHistory object gives you the HTML table made with ArticleHistory:renderHtml concatenated with the category links made with ArticleHistory:renderCategories.
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||