| Test suite status | |
|---|---|
| Scribunto test cases | |
| Code coverage |
Unit test report for Docbunto.
Execution time: 2.2 msTest cases failing:Test members missing:none
Scribunto test cases
| ||||
|---|---|---|---|---|
| Status | Code | Expected | Actual | Differs at |
{{docbunto|main|DEV/NULL}} | Lua source code not found in Module:DEV/NULL | Lua source code not found in Module:function | 37 " D" vs. "f" | |
{{docbunto|main|Codedoc}} | documentation markup for Docbunto not found in Module:Codedoc | Lua source code not found in Module:function | 1 " d" vs. "L" | |
{{docbunto|main|Entrypoint}} |
__NOEDITSECTION__[[:Template:Infobox Lua]]
<b>Entrypoint</b> templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations. | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto}} |
__NOEDITSECTION__[[:Template:Infobox Lua]]
<b>Docbunto</b> automatic documentation generator for Scribunto modules. The module is based on LuaDoc and LDoc. It produces documentation in the form of MediaWiki markup, using <code>'"`UNIQ--nowiki-00000004-QINU`"'</code>-prefixed comments embedded in the source code of a Scribunto module. The taglet parser & doclet renderer Docbunto uses are also publicly exposed to other modules. | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto/testcases/Factory|code = 1|ulist = 1}} |
==='"`UNIQ--h-6--QINU`"' Package items ===
;<code id="i18nf.loadMessages">i18nf.loadMessages(name, options)</code> ([[Lua reference manual#function|function]])
:Loads messages from JSON files in MediaWiki namespace. The messages are wrapped in a custom interface:
:* This function parses and caches messages in the module as a Lua data table.
:* These can be accessed using the <code>[[#I18n:msg|msg]]</code> method of the returned object.
:<b>Parameters</b>: 
:*<code>name</code> Name of <code>'"`UNIQ--nowiki-00000017-QINU`"'</code> root page. ([[Lua reference manual#string|string]])
:*<code>options</code> Configuration options. ([[Lua reference manual#table|table]])
:**<code>options.inline</code> Whether the JSON file uses inline comments instead of multiline comments. ([[Lua reference manual#boolean|boolean]]; optional)
:<b>Returns</b>: Instance of <code>[[#I18n|I18n]]</code> object. ([[#I18n|I18n]])
;<code id="i18nf._getMsg">i18nf._getMsg(name, key, i18n)</code> ([[Lua reference manual#function|function]])
:Fetch a message from the cache of parsed i18n data.
:<b>Parameters</b>: 
:*<code>name</code> Message source name. ([[Lua reference manual#string|string]])
:*<code>key</code> Message key. ([[Lua reference manual#string|string]])
:*<code>i18n</code> Instance of <code>[[#I18n|I18n]]</code> object. ([[#I18n|I18n]])
==='"`UNIQ--h-7--QINU`"' <code>Message</code> ===
Message object, providing getter methods for messages.
;<code id="Message:parse">Message:parse()</code> ([[Lua reference manual#function|function]])
:Parse wikitext links in the message and return the result.
:<b>Returns</b>: Message string with MediaWiki and Markdown rendered. ([[Lua reference manual#string|string]])
;<code id="Message:markdown">Message:markdown()</code> ([[Lua reference manual#function|function]])
:Parse markdown links in the message and return the result.
:<b>Returns</b>: Message string with Markdown rendered. ([[Lua reference manual#string|string]])
;<code id="Message:escape">Message:escape()</code> ([[Lua reference manual#function|function]])
:Escape the message wikitext and return the result.
:<b>Returns</b>: Escaped message string. ([[Lua reference manual#string|string]])
;<code id="Message:plain">Message:plain()</code> ([[Lua reference manual#function|function]])
:Return the message with no processing.
:<b>Returns</b>: Plain message string. ([[Lua reference manual#string|string]])
==='"`UNIQ--h-8--QINU`"' <code>I18n</code> ===
I18n object, providing message getter and language setters.
;<code id="I18n:msg">I18n:msg(...)</code> ([[Lua reference manual#function|function]] • factory • constructor)
:Factory returning <code>[[#Message|Message]]</code> instance.
:<b>Parameter</b>: <code>[[Lua reference manual#varargs|...]]</code> Message key, followed by optional arguments to substitute into. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Instance of <code>[[#Message|Message]]</code>. ([[#Message|Message]])
;<code id="I18n:useLang">I18n:useLang(code)</code> ([[Lua reference manual#function|function]])
:I18n language setter to specificed language.
:<b>Parameter</b>: <code>code</code> Language code to use. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:inLang">I18n:inLang(code)</code> ([[Lua reference manual#function|function]])
:Temporary datastore language setter to a specificed language. Only affects the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Parameter</b>: <code>code</code> Language code to use. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:useContentLang">I18n:useContentLang()</code> ([[Lua reference manual#function|function]])
:I18n language setter to <code>'"`UNIQ--nowiki-00000018-QINU`"'</code>.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:inContentLang">I18n:inContentLang()</code> ([[Lua reference manual#function|function]])
:Temporary language setter to <code>'"`UNIQ--nowiki-00000019-QINU`"'</code>. Only affects the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:useUserLang">I18n:useUserLang()</code> ([[Lua reference manual#function|function]])
:I18n language setter to <code>'"`UNIQ--nowiki-0000001A-QINU`"'</code>.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
:<b>Note</b>: Scribunto only registers <code>'"`UNIQ--nowiki-0000001B-QINU`"'</code> when an invocation is at the top of the call stack.
;<code id="I18n:inUserLang">I18n:inUserLang()</code> ([[Lua reference manual#function|function]])
:Temporary language setter to <code>'"`UNIQ--nowiki-0000001C-QINU`"'</code>. The message language reverts to the default language in the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]]) | Lua source code not found in Module:function | error | |
{{docbunto|main|Entrypoint|code = 1}} |
==='"`UNIQ--h-10--QINU`"' Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
==='"`UNIQ--h-11--QINU`"' Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]]) | Lua source code not found in Module:function | error | |
{{docbunto|main|Entrypoint|code = 1|all = 1}} |
==='"`UNIQ--h-13--QINU`"' Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
==='"`UNIQ--h-14--QINU`"' Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]])
==='"`UNIQ--h-15--QINU`"' Private items===
;<code id="inext">inext(t, i)</code> ([[Lua reference manual#function|function]] • local)
:Stateless, sequential Lua iterator.
:<b>Parameters</b>: 
::<code>t</code> Invariant state to loop over. ([[Lua reference manual#table|table]])
::<code>i</code> Control variable (current index). ([[Lua reference manual#number|number]])
:<b>Returns</b>: 
::Next index. ([[Lua reference manual#number|number]]; optional)
::Next value. ([[Lua reference manual#number|number]]|[[Lua reference manual#string|string]]|[[Lua reference manual#table|table]]|[[Lua reference manual#boolean|boolean]]; optional)
:<b>See also</b>: [[github:lua/lua/blob/v5.1.1/lbaselib.c#L247]]
;<code id="func_check">func_check</code> (variable; [[Lua reference manual#boolean|boolean]] • local)
:Check for MediaWiki version 1. 25. The concurrent Scribunto release adds a type check for package functions.
:<b>See also</b>: [[mw:MediaWiki 1.24/wmf7#Scribunto]]
;<code id="msg">msg(key<span style="opacity: 0.65;">, fn_name</span>)</code> ([[Lua reference manual#function|function]] • local)
:MediaWiki error message getter. Mimics Scribunto error formatting for script errors.
:<b>Parameters</b>: 
::<code>key</code> MediaWiki i18n message key. ([[Lua reference manual#string|string]])
::<code>fn_name</code> Name of package function. ([[Lua reference manual#string|string]]; optional)
:<b>Returns</b>: Formatted lowercase message. ([[Lua reference manual#string|string]]) | Lua source code not found in Module:function | error | |
{{docbunto|main|Unindent|boilerplate = 1}} |
__NOEDITSECTION__[[:Template:Infobox Lua]]
<b>Unindent</b> resets the indentation level of mulitline strings. It is useful for multiline strings inside functions and large tables. This module serves as a utility function for string parsing, [[Global Lua Modules/Testharness|Testharness]] test suites, [[Global Lua Modules/I18n|I18n]] datastores. | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto/testcases/LDoc|code = 1|colon = 1|ulist = 1}} |
==='"`UNIQ--h-19--QINU`"' Package items ===
;<code id="multiple.mul1">multiple.mul1()</code> ([[Lua reference manual#function|function]]) :Function with return groups. :<b>Returns</b>: Result. ([[Lua reference manual#string|string]]) ;<code id="multiple.mul2">multiple.mul2()</code> ([[Lua reference manual#function|function]]) :Function with return and error tag. :<b>Error</b>: 'message' :<b>Returns</b>: Result. ;<code id="multiple.mul3">multiple.mul3()</code> ([[Lua reference manual#function|function]]) :Function with multiple error tags. :<b>Errors</b>:  :*'not found' :** When <code>'"`UNIQ--nowiki-00000029-QINU`"'</code> is missing in the same directory. :*'bad format' :** When <code>'"`UNIQ--nowiki-0000002A-QINU`"'</code> contains invalid UTF-8 sequences. :<b>Returns</b>: Result. ;<code id="multiple.mul4">multiple.mul4()</code> ([[Lua reference manual#function|function]]) :Function with inline return and errors. :<b>Errors</b>:  :*'not a string' (line 31) :*'zero-length string' (line 34) :<b>Returns</b>: Name converted to uppercase. ([[Lua reference manual#string|string]]) ;<code id="multiple.mul5">multiple.mul5()</code> ([[Lua reference manual#function|function]]) :Function that raises an error. :<b>Error</b>: 'file not found' :<b>Returns</b>: Contents of file in UTF-8 charset. ([[Lua reference manual#string|string]]) ;<code id="multiple.mul6">multiple.mul6()</code> ([[Lua reference manual#function|function]]) :First useless function. Optional type specifiers are allowed in this format. Note how these types are rendered! :<b>Returns</b>:  ([[Lua reference manual#table|table]]|[[Lua reference manual#string|string]]|[[Lua reference manual#nil|nil]]) ;<code id="multiple.mul7">multiple.mul7(name)</code> ([[Lua reference manual#function|function]]) :A function with typed args. Note the the standard tparam aliases, and how the 'opt' and 'optchain' modifiers may also be used. If the Lua function has varargs, then you may document an indefinite number of extra arguments! :<b>Parameter</b>: <code>name</code> Person's name. ([[Lua reference manual#string|string]]|[[#Person|Person]]|[[Lua reference manual#nil|nil]]) :<b>Returns</b>: Birthday month in calendar (usually Gregorian). ([[Lua reference manual#string|string]]) ;<code id="multiple.mul8">multiple.mul8(one<span style="opacity: 0.65;">, two</span>, three<span style="opacity: 0.65;">, ...</span>)</code> ([[Lua reference manual#function|function]]) :Testing <code>'"`UNIQ--nowiki-0000002B-QINU`"'</code>. :<b>Parameters</b>:  :*<code>one</code> First parameter. :*<code>two</code> Second parameter. (optional) :*<code>three</code> Third parameter. :*<code>[[Lua reference manual#varargs|...]]</code> Other parameters after/including fourth parameter. (optional) ;<code id="multiple.mul9">multiple.mul9()</code> ([[Lua reference manual#function|function]]) :Third useless function. Can always put comments inline, may be multiple. ;<code id="multiple.mul10">multiple.mul10(<span style="opacity: 0.65;">three</span>)</code> ([[Lua reference manual#function|function]]) :Function with single optional argument. :<b>Parameter</b>: <code>three</code> Third parameter. Limitations: :* This parameter must be greater than two. :* This parameter must be less than four. :* Valve cannot count to this number. : (optional) ==='"`UNIQ--h-20--QINU`"' Other items === ;<code id="person2">person2</code> ([[Lua reference manual#table|table]]) :Implicit table can always use <code>'"`UNIQ--nowiki-0000002C-QINU`"'</code> notation. :<b>Fields</b>:  :*<code>gender</code> Has an official ID number. ([[Lua reference manual#boolean|boolean]]) :*<code>sex</code> One of <code>'"`UNIQ--nowiki-0000002D-QINU`"'</code> (male), <code>'"`UNIQ--nowiki-0000002E-QINU`"'</code> (female) or 'N' (N/A). ([[Lua reference manual#boolean|boolean]]) :*<code>spouse</code> Has a wife or husband. ([[Lua reference manual#boolean|boolean]]) ;<code id="person3">person3</code> ([[Lua reference manual#table|table]]) :Explicit table in <code>'"`UNIQ--nowiki-0000002F-QINU`"'</code> format. :<b>Fields</b>:  :*<code>surname</code> Person's surname. ([[Lua reference manual#string|string]]) :*<code>birthdate</code> Person's birthdate. ([[Lua reference manual#string|string]]) :*<code>options</code> List of options for person - <code>[[#person2|person2]]</code>. ([[Lua reference manual#table|table]]) ;<code id="person4">person4</code> ([[Lua reference manual#table|table]]) :An implicit table. :<b>Fields</b>:  :*<code>name</code> Name of person. ([[Lua reference manual#string|string]]) :*<code>age</code> Age of person. ([[Lua reference manual#number|number]]) ;<code id="person4">person4</code> ([[Lua reference manual#table|table]]) :An explicit table. Can use tparam aliases in table definitions. :<b>Fields</b>:  :*<code>name</code> ([[Lua reference manual#string|string]]) :*<code>age</code> ([[Lua reference manual#number|number]]) '"`UNIQ--nowiki-00000030-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|Entrypoint|code = 1|preface =
== Usage ==
The Scribunto module can now be used with the following syntax:
{{t|string|function|one|two|...}}}} |
=='"`UNIQ--h-22--QINU`"' Usage ==
The Scribunto module can now be used with the following syntax:
'"`UNIQ--nowiki-00000033-QINU`"'[[Template:string|string]]|<font color="gray">''<function>''</font>|<font color="gray">''<one>''</font>|<font color="gray">''<two>''</font>|<font color="gray">''<...>''</font>'"`UNIQ--nowiki-00000034-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto|code = 1|simple = 1}} |
==='"`UNIQ--h-27--QINU`"' Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]]) :Template entrypoint for [[Template:Docbunto]]. ;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Scribunto documentation generator entrypoint. ;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Docbunto taglet parser for Scribunto modules. ;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Doclet renderer for Docbunto taglet data. ;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]]) :Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens. :* Multi-line tags use the <code>'"`UNIQ--nowiki-00000039-QINU`"'</code> token. :* Multi-line preformatted tags use the <code>'"`UNIQ--nowiki-0000003A-QINU`"'</code> token. :* Identifier tags use the <code>'"`UNIQ--nowiki-0000003B-QINU`"'</code> token. :* Single-line tags use the <code>'"`UNIQ--nowiki-0000003C-QINU`"'</code> token. :* Flags use the <code>'"`UNIQ--nowiki-0000003D-QINU`"'</code> token. :* Type tags use the <code>'"`UNIQ--nowiki-0000003E-QINU`"'</code> token. '"`UNIQ--nowiki-0000003F-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|code = 1|simple = 1}} |
==='"`UNIQ--h-27--QINU`"' Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]]) :Template entrypoint for [[Template:Docbunto]]. ;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Scribunto documentation generator entrypoint. ;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Docbunto taglet parser for Scribunto modules. ;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Doclet renderer for Docbunto taglet data. ;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]]) :Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens. :* Multi-line tags use the <code>'"`UNIQ--nowiki-00000039-QINU`"'</code> token. :* Multi-line preformatted tags use the <code>'"`UNIQ--nowiki-0000003A-QINU`"'</code> token. :* Identifier tags use the <code>'"`UNIQ--nowiki-0000003B-QINU`"'</code> token. :* Single-line tags use the <code>'"`UNIQ--nowiki-0000003C-QINU`"'</code> token. :* Flags use the <code>'"`UNIQ--nowiki-0000003D-QINU`"'</code> token. :* Type tags use the <code>'"`UNIQ--nowiki-0000003E-QINU`"'</code> token. '"`UNIQ--nowiki-0000003F-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto|code = 1|simple = 1|noluaref = 1}} |
==='"`UNIQ--h-28--QINU`"' Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> (function) :Template entrypoint for [[Template:Docbunto]]. ;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> (function) :Scribunto documentation generator entrypoint. ;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> (function) :Docbunto taglet parser for Scribunto modules. ;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> (function) :Doclet renderer for Docbunto taglet data. ;<code id="docbunto.tags">docbunto.tags</code> (table) :Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens. :* Multi-line tags use the <code>'"`UNIQ--nowiki-00000040-QINU`"'</code> token. :* Multi-line preformatted tags use the <code>'"`UNIQ--nowiki-00000041-QINU`"'</code> token. :* Identifier tags use the <code>'"`UNIQ--nowiki-00000042-QINU`"'</code> token. :* Single-line tags use the <code>'"`UNIQ--nowiki-00000043-QINU`"'</code> token. :* Flags use the <code>'"`UNIQ--nowiki-00000044-QINU`"'</code> token. :* Type tags use the <code>'"`UNIQ--nowiki-00000045-QINU`"'</code> token. '"`UNIQ--nowiki-00000046-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto|code = 1|simple = 1|plain = 1}} |
==='"`UNIQ--h-29--QINU`"' Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]]) :Template entrypoint for [[Template:Docbunto]]. ;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Scribunto documentation generator entrypoint. ;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Docbunto taglet parser for Scribunto modules. ;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Doclet renderer for Docbunto taglet data. ;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]]) :Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens. :* Multi-line tags use the `'M'` token. :* Multi-line preformatted tags use the `'ML'` token. :* Identifier tags use the `'ID'` token. :* Single-line tags use the `'S'` token. :* Flags use the `'N'` token. :* Type tags use the `'T'` token. '"`UNIQ--nowiki-00000047-QINU`"' | Lua source code not found in Module:function | error | |
{{docbunto|main|Docbunto|code = 1|simple = 1|strip = 1}} |
==='"`UNIQ--h-30--QINU`"' Package items ===
;<code id="docbunto.main">main(f)</code> ([[Lua reference manual#function|function]]) :Template entrypoint for [[Template:Docbunto]]. ;<code id="docbunto.build">build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Scribunto documentation generator entrypoint. ;<code id="docbunto.taglet">taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Docbunto taglet parser for Scribunto modules. ;<code id="docbunto.doclet">doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]]) :Doclet renderer for Docbunto taglet data. ;<code id="docbunto.tags">tags</code> ([[Lua reference manual#table|table]]) :Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens. :* Multi-line tags use the <code>'"`UNIQ--nowiki-00000048-QINU`"'</code> token. :* Multi-line preformatted tags use the <code>'"`UNIQ--nowiki-00000049-QINU`"'</code> token. :* Identifier tags use the <code>'"`UNIQ--nowiki-0000004A-QINU`"'</code> token. :* Single-line tags use the <code>'"`UNIQ--nowiki-0000004B-QINU`"'</code> token. :* Flags use the <code>'"`UNIQ--nowiki-0000004C-QINU`"'</code> token. :* Type tags use the <code>'"`UNIQ--nowiki-0000004D-QINU`"'</code> token. '"`UNIQ--nowiki-0000004E-QINU`"' | Lua source code not found in Module:function | error | |
--- Unit tests for [[Global Lua Modules/Docbunto]].
-- @see [[Module talk:Docbunto/testcases]]
-- <nowiki>
local unindent = require('Dev:Unindent')
return {
main = {
options = {
mode = 'invocation',
preprocess = true,
template = true
},
tests = {
-- content check
{
'DEV/NULL',
'Lua source code not found in Module:DEV/NULL',
{ err = true }
},
-- markup check
{
'Codedoc',
'documentation markup for Docbunto not found in Module:Codedoc',
{ err = true }
},
-- basic functionality
{
'Entrypoint',
unindent [=[
__NOEDITSECTION__{{Infobox Lua
| Title = Entrypoint
| Type = meta
| Status = stable
| Author = [[User:8nml|8nml]]
| Description = Templating wrapper for Scribunto packages.
| Code = Entrypoint
| Languages = mw
}}
<b>Entrypoint</b> templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
== Documentation ==
=== Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
=== Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]])
== Notes ==
* Parent frames are not available in Entrypoint's <code><nowiki>frame</nowiki></code>. This is because recursive (grandparent) frame access is impossible in legacy Scribunto due to [[mw:Manual:Parser#Empty-argument expansion cache|empty-argument expansion cache]] limitations.
* As Entrypoint enables template access rather than a new extension hook, it does not work with named numeric parameters such as <code><nowiki>1=</nowiki></code> or <code><nowiki>2=</nowiki></code>. This may result in unexpected behaviour such as Entrypoint and module errors.
<nowiki />
]=]
},
-- self-documentation and markup
{
'Docbunto',
unindent [=[
__NOEDITSECTION__{{Infobox Lua
| Title = Docbunto
| Image file = Docbunto.svg
| Type = invocable
| Status = stable
| Description = Automatic documentation generator for Scribunto modules.
| Author = [[User:8nml|8nml]]
| Code = Docbunto
| Dependencies =
* [[Module:I18n]]
* [[Module:Lexer]]
* [[Module:T]]
* [[Module:Unindent]]
* [[Module:Yesno]]
| Using code by = [[github:stevedonovan|@stevedonovan]] ([[github:stevedonovan/LDoc|Github]])
| Languages = auto
}}
<b>Docbunto</b> automatic documentation generator for Scribunto modules. The module is based on LuaDoc and LDoc. It produces documentation in the form of MediaWiki markup, using <code><nowiki>@tag</nowiki></code>-prefixed comments embedded in the source code of a Scribunto module. The taglet parser & doclet renderer Docbunto uses are also publicly exposed to other modules.
Docbunto code items are introduced by a block comment (<code><nowiki>--[[]]--</nowiki></code>), an inline comment with three hyphens (<code><nowiki>---</nowiki></code>), or an inline <code><nowiki>@tag</nowiki></code> comment. The module can use static code analysis to infer variable names, item privacy (<code><nowiki>local</nowiki></code> keyword), tables (<code><nowiki>{}</nowiki></code> constructor) and functions (<code><nowiki>function</nowiki></code> keyword). MediaWiki and Markdown formatting is supported.
Items are usually rendered in the order they are defined, if they are public items, or emulated classes extending the Lua primitives. There are many customisation options available to change Docbunto behaviour.
== Documentation ==
=== Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]])
:Template entrypoint for [[Template:Docbunto]].
:<b>Parameter</b>: <code>f</code> Scribunto frame object. ([[Lua reference manual#table|table]])
:<b>Returns</b>: Module documentation output. ([[Lua reference manual#string|string]])
;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Scribunto documentation generator entrypoint.
:<b>Parameters</b>: 
::<code>modname</code> Module page name (without namespace). Default: second-level subpage. ([[Lua reference manual#string|string]]; optional)
::<code>options</code> Configuration options. ([[Lua reference manual#table|table]]; optional)
:::<code>options.all</code> Include local items in documentation. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.boilerplate</code> Removal of boilerplate (license block comments). ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.caption</code> Infobox image caption. ([[Lua reference manual#string|string]]; optional)
:::<code>options.code</code> Only document Docbunto code items - exclude article infobox and lede from rendered documentation. Permits article to be edited in VisualEditor. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.colon</code> Format tags with a <code><nowiki>:</nowiki></code> suffix and without the <code><nowiki>@</nowiki></code> prefix. This bypasses the "doctag soup" some authors complain of. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.image</code> Infobox image. ([[Lua reference manual#string|string]]; optional)
:::<code>options.noluaref</code> Don't link to the [[Lua reference manual]] for types. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.plain</code> Disable Markdown formatting in documentation. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.preface</code> Preface text to insert between lede & item documentation, used to provide usage and code examples. ([[Lua reference manual#string|string]]; optional)
:::<code>options.simple</code> Limit documentation to descriptions only. Removes documentation of subitem tags such as <code><nowiki>@param</nowiki></code> and <code><nowiki>@field</nowiki></code> ([[#Item subtags|see list]]). ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.sort</code> Sort documentation items in alphabetical order. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.strip</code> Remove table index in documentation. ([[Lua reference manual#boolean|boolean]]; optional)
:::<code>options.ulist</code> Indent subitems as <code><nowiki><ul></nowiki></code> lists (LDoc/JSDoc behaviour). ([[Lua reference manual#boolean|boolean]]; optional)
;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Docbunto taglet parser for Scribunto modules.
:<b>Parameters</b>: 
::<code>modname</code> Module page name (without namespace). ([[Lua reference manual#string|string]]; optional)
::<code>options</code> Configuration options. ([[Lua reference manual#table|table]]; optional)
:<b>Errors</b>: 
::'Lua source code not found in $1' ([[Lua reference manual#string|string]]; line 906)
::'documentation markup for Docbunto not found in $1' ([[Lua reference manual#string|string]]; line 912)
:<b>Returns</b>: Module documentation data. ([[Lua reference manual#table|table]])
;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Doclet renderer for Docbunto taglet data.
:<b>Parameters</b>: 
::<code>data</code> Taglet documentation data. ([[Lua reference manual#table|table]])
::<code>options</code> Configuration options. ([[Lua reference manual#table|table]]; optional)
:<b>Returns</b>: Wikitext documentation output. ([[Lua reference manual#string|string]])
;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]])
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the <code><nowiki>'M'</nowiki></code> token.
:* Multi-line preformatted tags use the <code><nowiki>'ML'</nowiki></code> token.
:* Identifier tags use the <code><nowiki>'ID'</nowiki></code> token.
:* Single-line tags use the <code><nowiki>'S'</nowiki></code> token.
:* Flags use the <code><nowiki>'N'</nowiki></code> token.
:* Type tags use the <code><nowiki>'T'</nowiki></code> token.
<nowiki />
]=]
},
-- factory and pragma support
{
'Docbunto/testcases/Factory|code = 1|ulist = 1',
unindent [=[
=== Package items ===
;<code id="i18nf.loadMessages">i18nf.loadMessages(name, options)</code> ([[Lua reference manual#function|function]])
:Loads messages from JSON files in MediaWiki namespace. The messages are wrapped in a custom interface:
:* This function parses and caches messages in the module as a Lua data table.
:* These can be accessed using the <code>[[#I18n:msg|msg]]</code> method of the returned object.
:<b>Parameters</b>: 
:*<code>name</code> Name of <code><nowiki>i18n.json</nowiki></code> root page. ([[Lua reference manual#string|string]])
:*<code>options</code> Configuration options. ([[Lua reference manual#table|table]])
:**<code>options.inline</code> Whether the JSON file uses inline comments instead of multiline comments. ([[Lua reference manual#boolean|boolean]]; optional)
:<b>Returns</b>: Instance of <code>[[#I18n|I18n]]</code> object. ([[#I18n|I18n]])
;<code id="i18nf._getMsg">i18nf._getMsg(name, key, i18n)</code> ([[Lua reference manual#function|function]])
:Fetch a message from the cache of parsed i18n data.
:<b>Parameters</b>: 
:*<code>name</code> Message source name. ([[Lua reference manual#string|string]])
:*<code>key</code> Message key. ([[Lua reference manual#string|string]])
:*<code>i18n</code> Instance of <code>[[#I18n|I18n]]</code> object. ([[#I18n|I18n]])
=== <code>Message</code> ===
Message object, providing getter methods for messages.
;<code id="Message:parse">Message:parse()</code> ([[Lua reference manual#function|function]])
:Parse wikitext links in the message and return the result.
:<b>Returns</b>: Message string with MediaWiki and Markdown rendered. ([[Lua reference manual#string|string]])
;<code id="Message:markdown">Message:markdown()</code> ([[Lua reference manual#function|function]])
:Parse markdown links in the message and return the result.
:<b>Returns</b>: Message string with Markdown rendered. ([[Lua reference manual#string|string]])
;<code id="Message:escape">Message:escape()</code> ([[Lua reference manual#function|function]])
:Escape the message wikitext and return the result.
:<b>Returns</b>: Escaped message string. ([[Lua reference manual#string|string]])
;<code id="Message:plain">Message:plain()</code> ([[Lua reference manual#function|function]])
:Return the message with no processing.
:<b>Returns</b>: Plain message string. ([[Lua reference manual#string|string]])
=== <code>I18n</code> ===
I18n object, providing message getter and language setters.
;<code id="I18n:msg">I18n:msg(...)</code> ([[Lua reference manual#function|function]] • factory • constructor)
:Factory returning <code>[[#Message|Message]]</code> instance.
:<b>Parameter</b>: <code>[[Lua reference manual#varargs|...]]</code> Message key, followed by optional arguments to substitute into. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Instance of <code>[[#Message|Message]]</code>. ([[#Message|Message]])
;<code id="I18n:useLang">I18n:useLang(code)</code> ([[Lua reference manual#function|function]])
:I18n language setter to specificed language.
:<b>Parameter</b>: <code>code</code> Language code to use. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:inLang">I18n:inLang(code)</code> ([[Lua reference manual#function|function]])
:Temporary datastore language setter to a specificed language. Only affects the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Parameter</b>: <code>code</code> Language code to use. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:useContentLang">I18n:useContentLang()</code> ([[Lua reference manual#function|function]])
:I18n language setter to <code><nowiki>wgContentLanguage</nowiki></code>.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:inContentLang">I18n:inContentLang()</code> ([[Lua reference manual#function|function]])
:Temporary language setter to <code><nowiki>wgContentLanguage</nowiki></code>. Only affects the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
;<code id="I18n:useUserLang">I18n:useUserLang()</code> ([[Lua reference manual#function|function]])
:I18n language setter to <code><nowiki>wgUserLanguage</nowiki></code>.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
:<b>Note</b>: Scribunto only registers <code><nowiki>wgUserLanguage</nowiki></code> when an invocation is at the top of the call stack.
;<code id="I18n:inUserLang">I18n:inUserLang()</code> ([[Lua reference manual#function|function]])
:Temporary language setter to <code><nowiki>wgUserLanguage</nowiki></code>. The message language reverts to the default language in the next <code>[[#I18n:msg|I18n:msg]]</code> call.
:<b>Returns</b>: Object instance of I18n (chainable). ([[#I18n|I18n]])
=== See also ===
* [[I18n-js|Original JS library]]
* [[wikipedia:Factory method pattern|"Factory method pattern" on Wikipedia]]
<nowiki />
]=]
},
-- `options.code`
{
'Entrypoint|code = 1',
unindent [=[
=== Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
=== Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]])
=== Notes ===
* Parent frames are not available in Entrypoint's <code><nowiki>frame</nowiki></code>. This is because recursive (grandparent) frame access is impossible in legacy Scribunto due to [[mw:Manual:Parser#Empty-argument expansion cache|empty-argument expansion cache]] limitations.
* As Entrypoint enables template access rather than a new extension hook, it does not work with named numeric parameters such as <code><nowiki>1=</nowiki></code> or <code><nowiki>2=</nowiki></code>. This may result in unexpected behaviour such as Entrypoint and module errors.
<nowiki />
]=]
},
-- `options.all`
{
'Entrypoint|code = 1|all = 1',
unindent [=[
=== Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
=== Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]])
=== Private items===
;<code id="inext">inext(t, i)</code> ([[Lua reference manual#function|function]] • local)
:Stateless, sequential Lua iterator.
:<b>Parameters</b>: 
::<code>t</code> Invariant state to loop over. ([[Lua reference manual#table|table]])
::<code>i</code> Control variable (current index). ([[Lua reference manual#number|number]])
:<b>Returns</b>: 
::Next index. ([[Lua reference manual#number|number]]; optional)
::Next value. ([[Lua reference manual#number|number]]|[[Lua reference manual#string|string]]|[[Lua reference manual#table|table]]|[[Lua reference manual#boolean|boolean]]; optional)
:<b>See also</b>: [[github:lua/lua/blob/v5.1.1/lbaselib.c#L247]]
;<code id="func_check">func_check</code> (variable; [[Lua reference manual#boolean|boolean]] • local)
:Check for MediaWiki version 1. 25. The concurrent Scribunto release adds a type check for package functions.
:<b>See also</b>: [[mw:MediaWiki 1.24/wmf7#Scribunto]]
;<code id="msg">msg(key<span style="opacity: 0.65;">, fn_name</span>)</code> ([[Lua reference manual#function|function]] • local)
:MediaWiki error message getter. Mimics Scribunto error formatting for script errors.
:<b>Parameters</b>: 
::<code>key</code> MediaWiki i18n message key. ([[Lua reference manual#string|string]])
::<code>fn_name</code> Name of package function. ([[Lua reference manual#string|string]]; optional)
:<b>Returns</b>: Formatted lowercase message. ([[Lua reference manual#string|string]])
=== Notes ===
* Parent frames are not available in Entrypoint's <code><nowiki>frame</nowiki></code>. This is because recursive (grandparent) frame access is impossible in legacy Scribunto due to [[mw:Manual:Parser#Empty-argument expansion cache|empty-argument expansion cache]] limitations.
* As Entrypoint enables template access rather than a new extension hook, it does not work with named numeric parameters such as <code><nowiki>1=</nowiki></code> or <code><nowiki>2=</nowiki></code>. This may result in unexpected behaviour such as Entrypoint and module errors.
<nowiki />
]=]
},
-- `options.boilerplate`
{
'Unindent|boilerplate = 1',
unindent [=[
__NOEDITSECTION__{{Infobox Lua
| Title = Unindent
| Type = meta
| Status = stable
| Description = Resets the indentation level of mulitline strings.
| Author = [[User:8nml|8nml]]
| Code = Unindent
| Using code by = [[github:kikito|@kikito]] ([[github:kikito/inspect.lua/blob/master/spec/unindent.lua|Github]])
}}
<b>Unindent</b> resets the indentation level of mulitline strings. It is useful for multiline strings inside functions and large tables. This module serves as a utility function for string parsing, [[Global Lua Modules/Testharness|Testharness]] test suites, [[Global Lua Modules/I18n|I18n]] datastores.
Lua supports multiline strings in the format <code><nowiki>[[\n...\n]]</nowiki></code>. In general, Lua does not outdent indented multiline strings out of the box. Though Lua supports variable indentation in multiline strings, custom logic is necessary to reset the string's indentation. This module adopts a flexible approach based on string scanning.
Unlike Penlight's <code><nowiki>pl.text.dedent</nowiki></code> behaviour where every line has the indentation of the first line removed, the line prefixed with the least non-tab whitespace is reset to zero indentation. Thus, the opening line of the string may retain some indentation <i>if</i> there are lines of less indentation terminating the string.
== Documentation ==
=== Package function ===
;<code id="unindent">unindent(str)</code> ([[Lua reference manual#function|function]])
:Unindent resets the indentation level of mulitline strings.
:<b>Parameter</b>: <code>str</code> Multiline string indented consistently. ([[Lua reference manual#string|string]])
:<b>Returns</b>: Unindented string. ([[Lua reference manual#string|string]])
<nowiki />
]=]
},
-- `options.colon` and LDoc compatibility
{
'Docbunto/testcases/LDoc|code = 1|colon = 1|ulist = 1',
unindent [=[
=== Package items ===
;<code id="multiple.mul1">multiple.mul1()</code> ([[Lua reference manual#function|function]])
:Function with return groups.
:<b>Returns</b>: Result. ([[Lua reference manual#string|string]])
;<code id="multiple.mul2">multiple.mul2()</code> ([[Lua reference manual#function|function]])
:Function with return and error tag.
:<b>Error</b>: 'message'
:<b>Returns</b>: Result.
;<code id="multiple.mul3">multiple.mul3()</code> ([[Lua reference manual#function|function]])
:Function with multiple error tags.
:<b>Errors</b>: 
:*'not found'
:** When <code><nowiki>multiple.lua</nowiki></code> is missing in the same directory.
:*'bad format'
:** When <code><nowiki>multiple.lua</nowiki></code> contains invalid UTF-8 sequences.
:<b>Returns</b>: Result.
;<code id="multiple.mul4">multiple.mul4()</code> ([[Lua reference manual#function|function]])
:Function with inline return and errors.
:<b>Errors</b>: 
:*'not a string' (line 31)
:*'zero-length string' (line 34)
:<b>Returns</b>: Name converted to uppercase. ([[Lua reference manual#string|string]])
;<code id="multiple.mul5">multiple.mul5()</code> ([[Lua reference manual#function|function]])
:Function that raises an error.
:<b>Error</b>: 'file not found'
:<b>Returns</b>: Contents of file in UTF-8 charset. ([[Lua reference manual#string|string]])
;<code id="multiple.mul6">multiple.mul6()</code> ([[Lua reference manual#function|function]])
:First useless function. Optional type specifiers are allowed in this format. Note how these types are rendered!
:<b>Returns</b>:  ([[Lua reference manual#table|table]]|[[Lua reference manual#string|string]]|[[Lua reference manual#nil|nil]])
;<code id="multiple.mul7">multiple.mul7(name)</code> ([[Lua reference manual#function|function]])
:A function with typed args. Note the the standard tparam aliases, and how the 'opt' and 'optchain' modifiers may also be used. If the Lua function has varargs, then you may document an indefinite number of extra arguments!
:<b>Parameter</b>: <code>name</code> Person's name. ([[Lua reference manual#string|string]]|[[#Person|Person]]|[[Lua reference manual#nil|nil]])
:<b>Returns</b>: Birthday month in calendar (usually Gregorian). ([[Lua reference manual#string|string]])
;<code id="multiple.mul8">multiple.mul8(one<span style="opacity: 0.65;">, two</span>, three<span style="opacity: 0.65;">, ...</span>)</code> ([[Lua reference manual#function|function]])
:Testing <code><nowiki>[opt]</nowiki></code>.
:<b>Parameters</b>: 
:*<code>one</code> First parameter.
:*<code>two</code> Second parameter. (optional)
:*<code>three</code> Third parameter.
:*<code>[[Lua reference manual#varargs|...]]</code> Other parameters after/including fourth parameter. (optional)
;<code id="multiple.mul9">multiple.mul9()</code> ([[Lua reference manual#function|function]])
:Third useless function. Can always put comments inline, may be multiple.
;<code id="multiple.mul10">multiple.mul10(<span style="opacity: 0.65;">three</span>)</code> ([[Lua reference manual#function|function]])
:Function with single optional argument.
:<b>Parameter</b>: <code>three</code> Third parameter. Limitations:
:* This parameter must be greater than two.
:* This parameter must be less than four.
:* Valve cannot count to this number.
: (optional)
=== Other items ===
;<code id="person2">person2</code> ([[Lua reference manual#table|table]])
:Implicit table can always use <code><nowiki>:</nowiki></code> notation.
:<b>Fields</b>: 
:*<code>gender</code> Has an official ID number. ([[Lua reference manual#boolean|boolean]])
:*<code>sex</code> One of <code><nowiki>'M'</nowiki></code> (male), <code><nowiki>'F'</nowiki></code> (female) or 'N' (N/A). ([[Lua reference manual#boolean|boolean]])
:*<code>spouse</code> Has a wife or husband. ([[Lua reference manual#boolean|boolean]])
;<code id="person3">person3</code> ([[Lua reference manual#table|table]])
:Explicit table in <code><nowiki>:</nowiki></code> format.
:<b>Fields</b>: 
:*<code>surname</code> Person's surname. ([[Lua reference manual#string|string]])
:*<code>birthdate</code> Person's birthdate. ([[Lua reference manual#string|string]])
:*<code>options</code> List of options for person - <code>[[#person2|person2]]</code>. ([[Lua reference manual#table|table]])
;<code id="person4">person4</code> ([[Lua reference manual#table|table]])
:An implicit table.
:<b>Fields</b>: 
:*<code>name</code> Name of person. ([[Lua reference manual#string|string]])
:*<code>age</code> Age of person. ([[Lua reference manual#number|number]])
;<code id="person4">person4</code> ([[Lua reference manual#table|table]])
:An explicit table. Can use tparam aliases in table definitions.
:<b>Fields</b>: 
:*<code>name</code> ([[Lua reference manual#string|string]])
:*<code>age</code> ([[Lua reference manual#number|number]])
<nowiki />
]=]
},
-- `options.preface`
{
unindent [[
Entrypoint|code = 1|preface =
== Usage ==
The Scribunto module can now be used with the following syntax:
{{t|string|function|one|two|...}}
]],
unindent [=[
== Usage ==
The Scribunto module can now be used with the following syntax:
{{t|string|function|one|two|...}}
== Documentation ==
=== Package function ===
;<code id="entrypoint">entrypoint(package)</code> ([[Lua reference manual#function|function]])
:Entrypoint templating wrapper for Scribunto packages. The module generates an entrypoint function that can execute Scribunto package calls in the template context. This allows a package to support both direct and template invocations.
:<b>Parameter</b>: <code>package</code> Scribunto package. ([[Lua reference manual#table|table]])
:<b>Errors</b>: 
::'you must specify a function to call' ([[Lua reference manual#string|string]]; line 85)
::'the function you specified did not exist' ([[Lua reference manual#string|string]]; line 91)
::'$2 is not a function' ([[Lua reference manual#string|string]]; line 95; optional)
:<b>Returns</b>: Template entrypoint - <code>[[#main|main]]</code>. ([[Lua reference manual#function|function]])
=== Other items ===
;<code id="main">main(frame)</code> ([[Lua reference manual#function|function]])
:Template entrypoint function generated by this module.
:<b>Parameter</b>: <code>frame</code> Scribunto frame in module context. ([[Lua reference manual/Scribunto libraries#Frame object|Frame]])
:<b>Returns</b>: Module output in template context. ([[Lua reference manual#string|string]])
=== Notes ===
* Parent frames are not available in Entrypoint's <code><nowiki>frame</nowiki></code>. This is because recursive (grandparent) frame access is impossible in legacy Scribunto due to [[mw:Manual:Parser#Empty-argument expansion cache|empty-argument expansion cache]] limitations.
* As Entrypoint enables template access rather than a new extension hook, it does not work with named numeric parameters such as <code><nowiki>1=</nowiki></code> or <code><nowiki>2=</nowiki></code>. This may result in unexpected behaviour such as Entrypoint and module errors.
<nowiki />
]=]
},
-- `options.simple`
{
'Docbunto|code = 1|simple = 1',
unindent [=[
=== Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]])
:Template entrypoint for [[Template:Docbunto]].
;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Scribunto documentation generator entrypoint.
;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Docbunto taglet parser for Scribunto modules.
;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Doclet renderer for Docbunto taglet data.
;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]])
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the <code><nowiki>'M'</nowiki></code> token.
:* Multi-line preformatted tags use the <code><nowiki>'ML'</nowiki></code> token.
:* Identifier tags use the <code><nowiki>'ID'</nowiki></code> token.
:* Single-line tags use the <code><nowiki>'S'</nowiki></code> token.
:* Flags use the <code><nowiki>'N'</nowiki></code> token.
:* Type tags use the <code><nowiki>'T'</nowiki></code> token.
<nowiki />
]=]
},
-- default title
{
'code = 1|simple = 1',
unindent [=[
=== Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]])
:Template entrypoint for [[Template:Docbunto]].
;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Scribunto documentation generator entrypoint.
;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Docbunto taglet parser for Scribunto modules.
;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Doclet renderer for Docbunto taglet data.
;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]])
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the <code><nowiki>'M'</nowiki></code> token.
:* Multi-line preformatted tags use the <code><nowiki>'ML'</nowiki></code> token.
:* Identifier tags use the <code><nowiki>'ID'</nowiki></code> token.
:* Single-line tags use the <code><nowiki>'S'</nowiki></code> token.
:* Flags use the <code><nowiki>'N'</nowiki></code> token.
:* Type tags use the <code><nowiki>'T'</nowiki></code> token.
<nowiki />
]=]
},
-- `options.noluaref`
{
'Docbunto|code = 1|simple = 1|noluaref = 1',
unindent [=[
=== Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> (function)
:Template entrypoint for [[Template:Docbunto]].
;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> (function)
:Scribunto documentation generator entrypoint.
;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> (function)
:Docbunto taglet parser for Scribunto modules.
;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> (function)
:Doclet renderer for Docbunto taglet data.
;<code id="docbunto.tags">docbunto.tags</code> (table)
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the <code><nowiki>'M'</nowiki></code> token.
:* Multi-line preformatted tags use the <code><nowiki>'ML'</nowiki></code> token.
:* Identifier tags use the <code><nowiki>'ID'</nowiki></code> token.
:* Single-line tags use the <code><nowiki>'S'</nowiki></code> token.
:* Flags use the <code><nowiki>'N'</nowiki></code> token.
:* Type tags use the <code><nowiki>'T'</nowiki></code> token.
<nowiki />
]=]
},
-- `options.plain`
{
'Docbunto|code = 1|simple = 1|plain = 1',
unindent [=[
=== Package items ===
;<code id="docbunto.main">docbunto.main(f)</code> ([[Lua reference manual#function|function]])
:Template entrypoint for [[Template:Docbunto]].
;<code id="docbunto.build">docbunto.build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Scribunto documentation generator entrypoint.
;<code id="docbunto.taglet">docbunto.taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Docbunto taglet parser for Scribunto modules.
;<code id="docbunto.doclet">docbunto.doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Doclet renderer for Docbunto taglet data.
;<code id="docbunto.tags">docbunto.tags</code> ([[Lua reference manual#table|table]])
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the `'M'` token.
:* Multi-line preformatted tags use the `'ML'` token.
:* Identifier tags use the `'ID'` token.
:* Single-line tags use the `'S'` token.
:* Flags use the `'N'` token.
:* Type tags use the `'T'` token.
<nowiki />
]=]
},
-- `options.strip`
{
'Docbunto|code = 1|simple = 1|strip = 1',
unindent [=[
=== Package items ===
;<code id="docbunto.main">main(f)</code> ([[Lua reference manual#function|function]])
:Template entrypoint for [[Template:Docbunto]].
;<code id="docbunto.build">build(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Scribunto documentation generator entrypoint.
;<code id="docbunto.taglet">taglet(<span style="opacity: 0.65;">modname</span><span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Docbunto taglet parser for Scribunto modules.
;<code id="docbunto.doclet">doclet(data<span style="opacity: 0.65;">, options</span>)</code> ([[Lua reference manual#function|function]])
:Doclet renderer for Docbunto taglet data.
;<code id="docbunto.tags">tags</code> ([[Lua reference manual#table|table]])
:Token dictionary for Docbunto tags. Maps Docbunto tag names to tag tokens.
:* Multi-line tags use the <code><nowiki>'M'</nowiki></code> token.
:* Multi-line preformatted tags use the <code><nowiki>'ML'</nowiki></code> token.
:* Identifier tags use the <code><nowiki>'ID'</nowiki></code> token.
:* Single-line tags use the <code><nowiki>'S'</nowiki></code> token.
:* Flags use the <code><nowiki>'N'</nowiki></code> token.
:* Type tags use the <code><nowiki>'T'</nowiki></code> token.
<nowiki />
]=]
}
}
}
}