Template:Scribunto
Usage
This helps with the creation of doc pages for Lua metamodules that reference the Scribunto manual or specific function within it.
{{scribunto |<!--anchor--> |<!--link text--> }}
If an anchor is provided, the link will be wrapped in <code>...</code>
. For example:<syntaxhighlight lang="wikitext">{{scribunto|mw.html.create}}</syntaxhighlight> produces this link:
mw.html.create
<syntaxhighlight lang="wikitext">{{scribunto|HTML_library|mw.html}}</syntaxhighlight> produces this link: mw.html
Advanced
|self=
and |args=
You may also use |self={{PAGENAME}}
to reference your own functions and |args=
to specify args, like so:<syntaxhighlight lang="wikitext">{{scribunto|self=Buffer/doc|:_all|args=...}}</syntaxhighlight> produces this link:
Buffer:_all<syntaxhighlight lang="lua" inline="">( ... )</syntaxhighlight>
If the first char matches the pattern <syntaxhighlight lang="text" class="" style="" inline="1">^[:%.]</syntaxhighlight> then title specified by |self=
will be inserted in front, minus any subpages, unless
escaped with the <syntaxhighlight lang="text" class="" style="" inline="1">\</syntaxhighlight> char:
<syntaxhighlight lang="wikitext">{{scribunto|self=Example\/testcases/doc|.test1|args=string}}</syntaxhighlight> produces:
Example/testcases.test1<syntaxhighlight lang="lua" inline="">( string )</syntaxhighlight>
no 'main'
If your module has no "main" method (e.g. Module:Buffer), you can pass the escape char <syntaxhighlight lang="text" class="" style="" inline="1">\</syntaxhighlight> as the first char in the function name to make a self-reference:<syntaxhighlight lang="wikitext">{{scribunto|self=Buffer/doc|\|args=...}}</syntaxhighlight> produces:
Buffer<syntaxhighlight lang="lua" inline="">( ... )</syntaxhighlight>
'
If the second parameter contains <syntaxhighlight lang="text" class="" style="" inline="1">***</syntaxhighlight>, then the first param will be substituted (or the self-reference, as applicable): <syntaxhighlight lang="wikitext">{{scribunto|self=Buffer|\|require('Module:***')|args=...}}</syntaxhighlight><syntaxhighlight lang="lua" inline="">require('Module:Buffer')</syntaxhighlight><syntaxhighlight lang="lua" inline="">( ... )</syntaxhighlight>
|args2=
and |args3=
Use to specify up to 3 argument variations.<syntaxhighlight lang="wikitext">{{scribunto|table.insert|args=table, value|args2=table, pos, value}}</syntaxhighlight>
table.insert<syntaxhighlight lang="lua" inline="">( table, value )</syntaxhighlight>
table.insert<syntaxhighlight lang="lua" inline="">( table, pos, value )</syntaxhighlight>
|plain=
If set to anything, the result will no longer be wrapped in <code>...</code>
.
See also
- {{Scribunto/helper}} and {{Scribunto/helper2}}, two helper templates. These should not be called directly.
- {{Luaself}}, a wrapper template that makes Lua self-references easier.
- Module:Buffer/doc, an example of a doc that uses this
- {{Lua}}
- Category:Lua metamodules