imported>Oetterer |
Aktuelle Version vom 10. April 2022, 06:20 Uhr
This is a documentation subpage for Modul:Classgenerator/class. It contains usage information, categories and other content that is not part of the original modul page. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This is a Class Module. It implements a class in Lua using Module:Middleclass and the template class Module:Foundationclass. This class provides methods for PURPOSE.
Usage[Quelltext bearbeiten]
local name = args[1] or args.name or mw.title.getCurrentTitle().rootText
local Class = require('Module:Name/class')
local me = Class:new(name)
me:initDataFromArgs(args)
me:storeData()
me:addInfobox()
me:addPageBody()
return me:render()
Methods[Quelltext bearbeiten]
Constructor[Quelltext bearbeiten]
new(uid)[Quelltext bearbeiten]
Creates a new Object for the class.
- uid
- variable, optional
- used to identify the object
- return
- object, of the class
public methods[Quelltext bearbeiten]
addInfobox()[Quelltext bearbeiten]
If no errors and data is present, adds an infobox to the object's output.
- return
- boolean, whether adding was successful or not
addPageBody()[Quelltext bearbeiten]
Adds a page body (all content besides the infobox) to the object's output: Errors and Warnings, sample configuration, statistics, ... Of course, only if there is data.
- return
- boolean, whether adding was successful or not
myArgumentProcessing(coreData)[Quelltext bearbeiten]
Performs the individual argument processing in initDataFromArgs(args) right before inititializing it.
- coreData
- table, mandatory
- the core data of the object. the one to process individually before initialization
- return
- table, the new core data array to be used
myPlausibilityTest(args)[Quelltext bearbeiten]
Performs the individual plausibility tests in initDataFromArgs(args) before entering the initialization part. NOTE: The return value will be ignored. If this finds errors, it must add them to the list of errors via addError(errortext).
- args
- table, mandatory
- arguments passed to the template to be checked
- return
- boolean, whether the object is plausible or not.
myStashAdjustments(self, stash)[Quelltext bearbeiten]
Performs the adjusts the stash in storeData() right before storing it.
- stash
- table, mandatory
- the array of data to be saved (in the form fieldname: value)
- return
- boolean, the new stash
static methods[Quelltext bearbeiten]
ClassClassgenerator:mySfDynamicFieldAttribute(fieldname, attribute, value)[Quelltext bearbeiten]
For some semantic form fields there are attribute values, that are not static, thus can not be provided at forehand in the configuration file. This method does the trick to adapt them at runtime shortly before the field is rendered. Essentially: the method checks, if it has a special rule for the pair fieldname:attribute and if so, calculates the new value. if not, the old value is returned.
- fieldname
- string, mandatory
- the form field's name, needed to match current paring to an existing special treatment rule
- attribute
- string, mandatory
- the form field's attribute, needed to match current paring to an existing special treatment rule
- value
- variable, mandatory
- the value, that is already provided in the configuration file. this will be adapted by the method, if there is a special rule for the pair fieldname:attribute.
- return
- string, the value to be used forthwith (which can be the old one or a freshly calculated)
private methods[Quelltext bearbeiten]
_debug(self, level, text)[Quelltext bearbeiten]
Adds output to the internal debug log.
- self
- object, me
- level
- int; mandatory
- debug level for the message
- text
- string; mandatory
- debug message text
- return
- void
_namespaceName (self, namespaceId)[Quelltext bearbeiten]
Takes the id of a namespace and converts it to the human readable name. Normally returns mw.site.namespaces[id].canonicalName...
- self
- object, me
- namespaceId
- int; mandatory
- for which namespace id the name should be returned
- return
- string, name of namespace
_processAttribute(self, attr, indent, name)[Quelltext bearbeiten]
Takes an attribute and builds from that (and self:getCoreData()) one entry in the class's config file.
- self
- object, me
- attr
- string; mandatory
- for which attribute should the entry be build
- indent
- string; mandatory
- indentation of line
- name
- string; optional
- normally the parameter name will be constructed out of attr. if you have special needs as a name, you can supply them via this parameter. name takes precedence, if provided.
- return
- string, the entry that can directly be added to the config file/string
Properties[Quelltext bearbeiten]
static[Quelltext bearbeiten]
See also Static Properties
- ClassName.myConfiguration
- this is your configuration. It is devided in several section, each a
- table, holds configuration data found in Module:Name/config
- WARNING: This is a read only table and besides functions pairs() and ipairs() nothing else will work on it, especially not the functions of the table library!
- form, table, holds data used to create the form. here are some of them:
- formButtons, table, which buttons should be printed at the bottom
- fieldOrder, table, in which order the form fields should appear (note: only fields listed here will be added to the form)
- global, table, holds some global configuration data
- parameter, table, holds all data about all parameter used in the module (be they form only, data store only or normal). The table has the form paramname = { table of paramdata }. The tables for the parameter have data as follows:
- cardinality, string, mandatory, one of singe or list
- cargo_type, string, optional, if the parameter is to be stored in cargo, add the field type here (one of Page, Text, Integer, Float, Date, Datetime, Boolean (which should be provided as 1 or 0), Coordinates, Wikitext, File, String, URL, or Email)
- description, string, mandatory, a description of this parameter
- label, string, mandatory, the label used in the form and the template documentation
- severity, string, optional, if provided one of mandatory, suggested
- sf, table, optional, used to add more attributes to the semantic forms field. ref Module:SFfield/config for all possible attributes. Note that the table is of type attribute_name : value. Value can be of type string, integer, boolean, and (in case of 'show on select') a table. Please note, that the attribute name cannot contain a " " (space). Use the underscore instead.
- td_default, string, optional, if you want a default value to be indicated in the template data section on the documentation page, add it here
- td_type, string, optional, if the parameter should be present in the template documentation page, fill this field. all possible values are listed here
- values, table, optional, if you want the possible values to be restricted to a specific set, fill this table
- template, table, holds some data used only in the template
- className.publicStaticProperty
- type, explanation
- _privateStaticProperty
- type, explanation
private[Quelltext bearbeiten]
Note: all private properties are stored in table _private[self]. _private is a static array that is indexed by self, so the table _private[self] holds all properties for instance self.
- dbg
- object, my instance of Module:Debug/class for debugging purposes. only present afer first call of _debug(self, level, text)
Configuration Data[Quelltext bearbeiten]
This class holds its control data in Module:Classgenerator/class/config.
Inheritance[Quelltext bearbeiten]
Methods[Quelltext bearbeiten]
Note: You still reference those either by self:publicMethod() or Classgenerator:staticMethod() and Classgenerator.staticProperty respectively! MediaWiki:Classengine-content-documentation-methods
Static Properties[Quelltext bearbeiten]
MediaWiki:Classengine-content-documentation-properties
Dependecies[Quelltext bearbeiten]
Apart from the obvious (being all pages in Category:Class engine), we also need:
- {{((}}
- {{))}}
- Extension:Header Tabs
Nice to have:
Please check also Foundationclass's dependencies.
Interface messages[Quelltext bearbeiten]
To generate your project's meta categories, Classgenerator makes use of the following interface messages:
- MediaWiki:Classengine-content-project-form-category
- MediaWiki:Classengine-content-project-gardening-supercategory
- MediaWiki:Classengine-content-project-module-category
- MediaWiki:Classengine-content-project-property-category
- MediaWiki:Classengine-content-project-supercategory
- MediaWiki:Classengine-content-project-template-category
You may edit them freely for your convenience to suit your needs.