Jump to content

Module:Sandbox/Mr. Stradivarius/sandbox3/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 14:55, 7 September 2013 (add some new methods and begin conversion to wikitext). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Helper functions

checkString

checkString( s )

Checks to see if s is a non-blank string. Returns s if true, and returns false if not.

Input type: string

addStringToArray

addStringToArray( t, s )

Adds the string s to the array t. Returns nil on an attempt to add a non-string value or a blank string, and raises an error on an attempt to add a string to a non-table value. If the array is not present, it is created.

checkObject

checkObject( obj, objType )

Checks to see if the object obj inherits from objType (a string value). Returns obj if true, and returns false if not.

Class definitions

All classes

All classes have a property class._type, which is a string specifying the class type. They also have a table property class._inherits, the keys of which are the names of the classes that the class inherits from (the class itself is included).

class:makeCheckSelfFunction

class:makeCheckSelfFunction()

This method generates a function that checks for mistaken use of the dot syntax with methods. It is used like this:

local newClass = class:new()
local checkSelfNewClass = newClass:makeCheckSelfFunction()

function newClass:method1()
    checkSelfNewClass( self, 'method1' )
    -- Method code
end

function newClass:method2()
    checkSelfNewClass( self, 'method2' )
    -- Method code
end

This function may fail in a small subset of cases: it only checks that an object inherits from newClass, not that it is the right object. This should account for most errors, however, and changing the code to check for 100% of cases would be non-trivial.

The main class for WikiProject banners. Defines the wikitext for the banner box, specifies the project name, the main image, and other things relevant to the banner as a whole.

Initiated with:

banner:new()

Methods:

banner:setProject

banner:setProject( s )

Sets the string s as the project value. The project value is the name of the project without any surrounding text. For example, the project value for WikiProject Tulips would be Tulips. The project value is required for the banner to be displayed.

banner:getProject

banner:getProject()

Gets the project value. If no project value is set, raises an error.

banner:setProjectLink( s )

Sets the string s as the project link. The project link is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be Wikipedia: WikiProject Tulips.

banner:getProjectLink()

Gets the project link. If no project link was specified with banner:setProjectLink, then it is generated using banner:getProject.

banner:setProjectName

banner:setProjectName( s )

Sets the string s as the project name. The project name is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be Wikipedia: WikiProject Tulips.

banner:getProjectName

banner:getProjectName()

Gets the project name. If no project name was specified with banner:setProjectName, then it is generated using banner:getProject.

banner:setBannerName

banner:setBannerName( s )

Sets the string s as the banner name. The banner name is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be Wikipedia: WikiProject Tulips.

banner:getBannerName

banner:getBannerName()

Gets the banner name. If no banner name was specified with banner:setBannerName, then it is generated using banner:getProject.

banner:setAssessmentCategory

banner:setAssessmentCategory( s )

Sets the string s as the assessment category. The assessment category is the name of the WikiProject's main page on Wikipedia. For example, the main page for WikiProject Tulips would be Wikipedia: WikiProject Tulips.

banner:getAssessmentCategory

banner:getAssessmentCategory()

Gets the assessment category. If no assessment category was specified with banner:setAssessmentCategory, then it is generated using banner:getProject.

banner:setImage

banner:setImage( s )

Sets the main image for the banner.

Input type: string

banner:getImage

banner:getImage()

Gets the main image for the banner.

banner:addCategory

banner:addCategory( s )

Adds one category to the banner object.

Input type: string (no double brackets and no "Category:" text)

banner:addCategories

banner:addCategories( t )

Adds multiple categories to the banner object.

Input type: array of strings

banner:getCategories

banner:getCategories()

Gets an array containing the category names for the banner object.

banner:exportCategories

banner:exportCategories()

Returns a string containing all the banner's categories ready for output on a wiki page.

banner:addRow

banner:addRow( rowObject )

Adds a row object to the banner.

Input type: Row object.

banner:addRows

banner:addRows( t )

Adds an array of row objects to the banner object.

Input type: array of row objects.

banner:export

banner:export()

Exports the banner to wikitext ready for display on wiki pages.

row class

The row class defines one row to add to the banner object. Rows can be things like task forces, notes, assessments, etc.

Initiated with:

row:new()

Methods:

row:addCategory

row:addCategory( s )

Adds a category to the row object.

Input type: string (no double brackets and no "Category:" text)

row:addCategories

row:addCategories( t )

Adds multiple categories to the row object.

Input type: array of strings

row:getCategories

row:getCategories()

Gets an array containing the category names for the row object.

row:export

row:export()

Exports the row object to wikitext to be passed to the banner object's export method.

qualityRow class

The qualityRow class defines the banner row displaying quality scale information.

Initiated with:

qualityRow:new()

Methods:

qualityRow:setQualityScale

qualityRow:setQualityScale( obj )

Sets the quality scale for the quality row.

Input type: qualityScale object

qualityRow:setStandardQualityScale

qualityRow:setStandardQualityScale()

Sets the standard quality scale with default settings.

qualityRow:setExtendedQualityScale

qualityRow:setExtendedQualityScale()

Sets the extended quality scale with default settings.

qualityRow:getQualityScale

qualityRow:getQualityScale()

Gets the quality scale object if it is set.

importanceRow class

The importanceRow class defines the banner row displaying importance scale information.

Initiated with:

importanceRow:new()

Methods:

importanceRow:setImportanceScale

importanceRow:setImportanceScale( obj )

Sets the importance scale for the importance row.

Input type: importanceScale object

importanceRow:setStandardImportanceScale

importanceRow:setStandardImportanceScale()

Sets the standard importance scale with default settings.

importanceRow:getImportanceScale

importanceRow:getImportanceScale()

Gets the importance scale object if it is set.

assessmentScale class

The assessmentScale class provides the infrastructure for quality scales and importance scales.

Initiated with:

assessmentScale:new()

Methods:

assessmentScale:setParamName

assessmentScale:setParamName( s )

Sets the name of the parameter that accepts trigger values from assessmentGrade objects. For example, if an article was rated as |class=start, the parameter name would be "class".

Input type: string

assessmentScale:getParamName

assessmentScale:getParamName()

Gets the parameter name.

assessmentScale:setCategoryFamily

assessmentScale:setCategoryFamily( s )

Sets the name of the category family. For example, for a quality scale with categories such as [[Category:C-class tulips articles]] and [[Category:List-class tulips articles]] the category family name would be "tulips articles".

Input type: string

assessmentScale:getCategoryFamily

assessmentScale:getCategoryFamily()

Gets the category family name.

assessmentScale:addGrade

assessmentScale:addGrade( assessmentGradeObject )

Adds an assessmentGrade object to the assessment scale (usually this will be a qualityGrade or an importanceGrade object). The assessmentGrade objects added to an assessmentScale object determine the grades on its assessment scale. If the assessmentGrade object is already present in the assessment scale, an error will be raised.

Input type: assessmentGrade object

assessmentScale:addGrades

assessmentScale:addGrades( t )

Adds an array of multiple assessmentGrade objects to the assessmentScale object.

Input type: array of assessmentGrade objects

assessmentScale:removeGrade

assessmentScale:removeGrade( s )

Removes one grade from the assessment scale.

Input type: string

assessmentScale:removeGrades

assessmentScale:removeGrades( t )

Removes multiple grades from the assessment scale.

Input type: array of strings

assessmentScale:getGrades

assessmentScale:getGrades()

Returns the table containing the assessmentGrade objects.

assessmentScale:getGrade

assessmentScale:getGrade( s )

Returns the specified grade object if it is set in the assessment scale.

assessmentScale:editGrade

assessmentScale:editGrade( gradeName, method, ... )

Edits the assessment grade object named "gradeName", using the assessment grade object's method "method". The third and subsequent arguments are passed as arguments to "method". This is a convenience function, to avoid having to remove a whole assessment grade object from the assessment scale, edit it, and then add it again. gradeName input type: string method input type: string

assessmentScale:checkForDuplicateTriggers

assessmentScale:checkForDuplicateTriggers()

Checks for duplicate triggers in the grade objects added to the assessment scale. If any are found, displays an error.

qualityScale class

This class defines a quality scale.

Initiated with:

qualityScale:new()

Methods:

qualityScale:setFaGrade

qualityScale:setFaGrade()

Sets an FA (Featured Article) grade with the default settings. The grade name is set to "fa", there is one trigger of "fa", the color is "#6699ff", and the icon is "Featured article star.svg".

qualityScale:setAGrade

qualityScale:setAGrade()

Sets an A grade with the default settings. The grade name is set to "a", there is one trigger of "a", the color is "#66ffff", and the icon is "Symbol a class.svg.svg".

qualityScale:setGaGrade

qualityScale:setGaGrade()

Sets a GA (Good Article) grade with the default settings. The grade name is set to "ga", there is one trigger of "ga", the color is "#66ff66", and the icon is "Symbol support vote.svg".

qualityScale:setBGrade

qualityScale:setBGrade()

Sets a B grade with the default settings. The grade name is set to "b", there is one trigger of "b", and the color is "#b2ff66".

qualityScale:setCGrade

qualityScale:setCGrade()

Sets a C grade with the default settings. The grade name is set to "c", there is one trigger of "c", and the color is "#ffff66".

qualityScale:setStartGrade

qualityScale:setStartGrade()

Sets a Start grade with the default settings. The grade name is set to "start", there is one trigger of "start", and the color is "#ffaa66".

qualityScale:setStubGrade

qualityScale:setStubGrade()

Sets a Stub grade with the default settings. The grade name is set to "stub", there is one trigger of "stub", and the color is "#ff6666".

qualityScale:setFlGrade

qualityScale:setFlGrade()

Sets an FL (Featured List) grade with the default settings. The grade name is set to "fl", there is one trigger of "fl", the color is "#6699ff", and the icon is "Featured article star.svg".

qualityScale:setListGrade

qualityScale:setListGrade()

Sets a List grade with the default settings. The grade name is set to "list", there is one trigger of "list", and the color is "#aa88ff".

qualityScale:setNaGrade

qualityScale:setNaGrade()

Sets a NA (not applicable) grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".

qualityScale:setCategoryGrade

qualityScale:setCategoryGrade()

Sets a Category grade with the default settings. The grade name is set to "category", there are three triggers of "category", "cat" and "categ", and the color is "#ffdb58".

qualityScale:setDisambigGrade

qualityScale:setDisambigGrade()

Sets a Disambig (disambiguation) grade with the default settings. The grade name is set to "disambig", there are four triggers of "disambiguation", "disambig", "disamb" and "dab", and the color is "#00fa9a".

qualityScale:setFileGrade

qualityScale:setFileGrade()

Sets a File grade with the default settings. The grade name is set to "file", there are three triggers of "file", "img" and "image", and the color is "#ddccff".

qualityScale:setPortalGrade

qualityScale:setPortalGrade()

Sets a Portal grade with the default settings. The grade name is set to "portal", there is one trigger of "portal", and the color is "#cc8899".

qualityScale:setProjectGrade

qualityScale:setProjectGrade()

Sets a Project grade with the default settings. The grade name is set to "project", there are three triggers of "project", "proj" and "prj", and the color is "#c0c090".

qualityScale:setTemplateGrade

qualityScale:setTemplateGrade()

Sets a Template grade with the default settings. The grade name is set to "template", there are five triggers of "template", "temp", "tpl", "tmp" and "templ", and the color is "#fbceb1".

qualityScale:setRedirectGrade

qualityScale:setRedirectGrade()

Sets a Redirect grade with the default settings. The grade name is set to "redirect", there are three triggers of "redirect", "red" and "redir", and the color is "#c0c0c0".

qualityScale:setFmGrade

qualityScale:setFmGrade()

Sets an FM (Featured Media) grade with the default settings. The grade name is set to "fm", there is one trigger of "fm", the color is "#6699ff", and the icon is "Featured article star.svg".

qualityScale:setStandardQualityScale

qualityScale:setStandardQualityScale()

Sets the standard quality scale, with grades of FA, A, GA, B, C, Start, Stub, FL, List and NA. All the grades have the default values.

qualityScale:setExtendedQualityScale

qualityScale:setExtendedQualityScale()

Sets the extended quality scale, with the grades in the standard quality scale plus grades of Category, Disambig, File, Portal, Project, and Template. All the grades have the default values.

importanceScale class

The importanceScale class defines an importance scale. It is populated with importanceGrade objects.

Initiated with:

importanceScale:new()

Methods:

importanceScale:setTopGrade

importanceScale:setTopGrade()

Sets a Top importance grade with the default settings. The grade name is set to "top", there is one trigger of "top", and the color is "#ff00ff".

importanceScale:setHighGrade

importanceScale:setHighGrade()

Sets a High importance grade with the default settings. The grade name is set to "high", there is one trigger of "high", and the color is "#ff88ff".

importanceScale:setMidGrade

importanceScale:setMidGrade()

Sets a Mid importance grade with the default settings. The grade name is set to "mid", there is one trigger of "mid", and the color is "#ffbbff".

importanceScale:setLowGrade

importanceScale:setLowGrade()

Sets a Low importance grade with the default settings. The grade name is set to "low", there is one trigger of "low", and the color is "#ffddff".

importanceScale:setBottomGrade

importanceScale:setBottomGrade()

Sets a Bottom importance grade with the default settings. The grade name is set to "bottom", there is one trigger of "bottom", and the color is "#ffeeff".

importanceScale:setNoGrade

importanceScale:setNoGrade()

Sets a No importance grade with the default settings. The grade name is set to "no", there is one trigger of "no", and the color is "#ffffff".

importanceScale:setNaGrade

importanceScale:setNaGrade()

Sets a NA importance grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".

importanceScale:setCoreGrade

importanceScale:setCoreGrade()

Sets a Core importance grade with the default settings. The grade name is set to "core", there is one trigger of "core", and the color is "#ff00ff".

importanceScale:setStandardImportanceScale

importanceScale:setStandardImportanceScale()

Sets the standard importance scale of Top, High, Mid, Low, and NA, with the default settings.

assessmentGrade class

The assessmentGrade class defines one grade on an assessment scale (e.g. an FA-class grade on a quality scale, or a top-importance grade on an importance scale).

Initiated with:

assessmentGrade:new()

Methods:

assessmentGrade:setGradeName

assessmentGrade:setGradeName( s )

Sets the name of the assessment grade. For example, for a C-class quality grade, the grade name would be "c".

Input type: string

assessmentGrade:getGradeName

assessmentGrade:getGradeName()

Gets the name of the assessment grade.

assessmentGrade:addTrigger

assessmentGrade:addTrigger( s )

Adds a trigger for the assessment grade. For example, if you want the grade to be triggered by the code "|class=foo", then the trigger would be "foo".

Input type: string

assessmentGrade:addTriggers

assessmentGrade:addTriggers( t )

Adds multiple triggers for the assessment grade.

Input type: array of strings

assessmentGrade:getTriggers

assessmentGrade:getTriggers()

Gets the array of triggers for the assessment grade.

assessmentGrade:setCategory

assessmentGrade:setCategory( s )

Sets the category used by the assessment grade. This should only be used if the category does not follow the default naming system. Normally categories are set by assessmentScale objects or banner objects.

assessmentGrade:getCategory

assessmentGrade:getCategory()

Gets the category for the assessment grade, if one was set with assessmentGrade:setCategory.

assessmentGrade:setColor

assessmentGrade:setColor( s )

Sets the color used for icon boxes etc. used by the assessment grade.

Input type: string (should be a valid css color value, e.g. '#gg99ff')

assessmentGrade:getColor

assessmentGrade:getColor()

Gets the assessment grade color.

assessmentGrade:setIcon

assessmentGrade:setIcon( s )

Sets the icon for the assessment grade, e.g. the featured article star for featured articles. This is optional - not every assessmentGrade object needs an icon. If specified, it should be a valid file name, without the "File:" prefix.

Input type: string

assessmentGrade:getIcon

assessmentGrade:getIcon()

Gets the icon file name.

qualityGrade class

The quality grade class defines quality grades on a quality scale. It inherits methods from the assessmentGrade class.

Methods:

All methods from the assessmentGrade class

importanceGrade class

The importanceGrade class defines importance grades on an importance scale. It inherits methods from the assessmentGrade class.

Methods:

All methods from the assessmentGrade class