dev

This module implements {{Documentation}}.

Installation

Dependencies

Documentation

Package items

documentation.message(cfgKey, valArray, expectType) (function)
Gets a message from the cfg table and formats it if appropriate. The function raises an error if the value from the cfg table is not of the type expectType. The default type for expectType is 'string'. If the table valArray is present, strings such as $1, $2 etc. in the message are substituted with values from the table keys [1], [2] etc. For example, if the message "foo-message" had the value 'Foo $2 bar $1.', message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."
Parameters:
Returns: (string|number|boolean|table|nil)
documentation.resolveNamespace(subjectSpace) (function)
Parameter: subjectSpace (number)
Returns: (string)
documentation.main(args) (function)
This function defines logic flow for the module. ; Messages:
'main-div-id' --> 'template-documentation'
'main-div-classes' --> 'template-documentation iezoomfix'
Parameter: args - table of arguments passed by the user (table|Frame)
Returns: (string)
documentation.getEnvironment(args) (function)
Returns a table with information about the environment, including title objects and other namespace- or path-related data.
Parameter: args - table of arguments passed by the user (table)
Returns: (Environment)
documentation.sandboxNotice(args, env) (function)
Generates a sandbox notice for display above sandbox pages. ; Messages:
'sandbox-notice-image' --> 'File:Sandbox.svg'
'sandbox-notice-blurb' --> 'This is the $1 for $2.'
'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
'sandbox-notice-pagetype-template' --> 'template sandbox page'
'sandbox-notice-pagetype-module' --> 'module sandbox page'
'sandbox-notice-pagetype-other' --> 'sandbox page'
'sandbox-notice-compare-link-display' --> 'diff'
'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
'sandbox-notice-testcases-link-display' --> 'test cases'
'sandbox-category' --> 'Template sandboxes'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.protectionTemplate(env) (function)
Generates the padlock icon in the top right. ; Messages:
'protection-template' --> 'pp-template'
'protection-template-args' --> {docusage = 'yes'}
Parameter: env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.startBox(args, env) (function)
This function generates the start box. The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox which generate the box HTML.
Parameters:
  • args - a table of arguments passed by the user (table|Frame)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment; optional)
Returns: (string|nil)
documentation.makeStartBoxLinksData(args, env) (function)
Does initial processing of data to make the [view] [edit] [history] [purge] links. ; Messages:
'file-docpage-preload' --> 'Template:Documentation/preload-filespace'
'module-preload' --> 'Template:Documentation/preload-module-doc'
'docpage-preload' --> 'Template:Documentation/preload'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (table|nil)
documentation.renderStartBoxLinks(data) (function)
Generates the [view][edit][history][purge] or [create] links from the data table.
Parameter: data - a table of data generated by p.makeStartBoxLinksData (table)
Returns: (string)
documentation.makeStartBoxData(args, env, links) (function)
Does initial processing of data to pass to the start-box render function, p. renderStartBox.
Messages
'documentation-icon-wikitext' --> 'Documentation icon'
'documentation-icon' --> 'Template-info.svg'
'documentation-icon-nodoc' --> 'Template-noinfo.svg'
'documentation-icon-baddoc' --> 'Template-badinfo.svg'
'start-box-linkclasses' --> 'mw-editsection-like plainlinks'
'start-box-link-id' --> 'doc_editlinks'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
  • links - a string containing the view [edit][history][purge] links - could be nil if there's an error. (string|nil; optional)
Returns: (table)
documentation.renderStartBox(data) (function)
Renders the start box html. ; Messages
'start-box-div-classes' --> 'template-documentation-header'
Parameter: data - a table of data generated by p.makeStartBoxData. (table)
Returns: (string)
documentation.content(args, env) (function)
Displays the documentation contents  ; Messages
'content-box-div-classes' --> 'template-documentation-content'
Parameters:
  • args - a table of arguments passed by the user (table|Frame)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment; optional)
Returns: (string)
documentation.contentTitle(args, env) (function)
Gets the content title
Parameters:
  • args - a table of arguments passed by the user (table|Frame)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment; optional)
Returns: (string)
documentation.endBox(args, env) (function)
This function generates the end box (also known as the link box). The HTML is generated by the {​{fmbox}} template, courtesy of Module:Message box.
Messages
'fmbox-id' --> 'documentation-meta-data'
'fmbox-style' --> 'background-color: #ecfcf4'
'fmbox-textstyle' --> 'font-style: italic'
Parameters:
  • args - a table of arguments passed by the user (table|Frame)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment; optional)
Returns: (string)
documentation.makeExperimentBlurb(args, env) (function)
Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. "
Messages
'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'
'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
'mirror-link-preload' --> 'Template:Documentation/mirror'
'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
'template-testcases-preload' --> 'Template:Documentation/preload-testcases'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.makeCategoriesBlurb(args, env) (function)
Generates the text "Please add categories to the /doc subpage. "
Messages
'doc-link-display' --> '/doc'
'add-categories-blurb' --> 'Please add categories to the $1 subpage.'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.makeSubpagesBlurb(args, env) (function)
Generates the "Subpages of this template" link. ; Messages:
'template-pagetype' --> 'template'
'module-pagetype' --> 'module'
'default-pagetype' --> 'page'
'subpages-link-display' --> 'Subpages of this $1'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.makePrintBlurb(args, env) (function)
Generates the blurb displayed when there is a print version of the template available. ; Messages:
'print-link-display' --> '/Print'
'print-blurb' --> 'A print version' .. ' of this template exists at $1.' .. ' If you make a change to this template, please update the print version as well.'
'display-print-category' --> true
'print-category' --> 'Templates with print versions'
Parameters:
  • args - a table of arguments passed by the user (table)
  • env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)
documentation.addTrackingCategories(env) (function)
Check if {{documentation}} is transcluded on a /doc or /testcases page. ; Messages:
'display-strange-usage-category' --> true
'doc-subpage' --> 'doc'
'testcases-subpage' --> 'testcases'
'strange-usage-category' --> 'Pages with strange ((documentation)) usage'
'nodoc-category-template' --> 'Templates with no documentation'
'nodoc-category-module' --> 'Modules with no documentation'
'nodoc-category-file' --> 'Files with no summary'
'nodoc-category-other' --> 'Pages with no documentation'
'baddoc-category-template' --> 'Templates with bad documentation'
'baddoc-category-module' --> 'Modules with bad documentation'
'baddoc-category-file' --> 'Files with bad summary'
'baddoc-category-other' --> 'Pages with bad documentation'
/testcases pages in the module namespace are not categorised, as they may have {{documentation}} transcluded automatically.
Parameter: env - environment table containing title objects, etc., generated with p.getEnvironment (Environment)
Returns: (string|nil)

Other items

Environment.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. (member • string|nil)
()
cssText('background-color:#EEE') :css('background-color', 'var(--theme-page-background-color--secondary,#EEE)') :css('border-color', 'var(--theme-border-color,#CCC)') --]]

See also