Difference between revisions of "Module:Disambiguation/doc"
Jump to navigation
Jump to search
blackwiki>Evad37 (start doc) |
m (3 revisions imported) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 14: | Line 14: | ||
You can also use magic words like {{tl|SUBJECTPAGENAME}}: | You can also use magic words like {{tl|SUBJECTPAGENAME}}: | ||
* <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}</nowiki>}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}} | * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}</nowiki>}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}} | ||
| + | |||
| + | ===Usage within Lua modules=== | ||
| + | Import this module, e.g with | ||
| + | <syntaxhighlight lang="lua"> | ||
| + | local mDisambiguation = require('Module:Disambiguation') | ||
| + | </syntaxhighlight> | ||
| + | Then you can use the functions <code>isDisambiguation</code> and <code>_isDisambiguationPage</code>. | ||
| + | |||
| + | If you have already have a [[mw:Lua_reference_manual#Title_objects|Title object]] for the page to check, get the content using the title object's getContent() method, and pass that into <code>isDisambiguation</code>: | ||
| + | <syntaxhighlight lang="lua"> | ||
| + | local isDab = mDisambiguation.isDisambiguation(content) -- returns true or false | ||
| + | </syntaxhighlight> | ||
| + | :(where <code>content</code> is a string, the wikitext content of page to check) | ||
| + | |||
| + | If you don't otherwise need the title, you can pass in the page name to <code>_isDisambiguationPage</code>: | ||
| + | <syntaxhighlight lang="lua"> | ||
| + | local isDab = mDisambiguation._isDisambiguationPage(pageName) -- returns true or false | ||
| + | </syntaxhighlight> | ||
| + | :(where <code>pageName</code> is a string, the name of page to check) | ||
Latest revision as of 16:03, 26 September 2020
| 26x26px | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
This module detects if a given page is a disambiguation page.
Usage
{{#invoke:Disambiguation|isDisambiguationPage|Page title}}
- returns
yesif the page is a disambiguation page, or nothing if the page is not a disambiguation page
Examples:
{{#invoke:Disambiguation|isDisambiguationPage|Paris}}→{{#invoke:Disambiguation|isDisambiguationPage|New}}→{{#invoke:Disambiguation|isDisambiguationPage|Black swan (disambiguation)}}→ yes
You can also use magic words like {{SUBJECTPAGENAME}}:
{{#invoke:Disambiguation|isDisambiguationPage|{{SUBJECTPAGENAME}}}}→
Usage within Lua modules
Import this module, e.g with
local mDisambiguation = require('Module:Disambiguation')
Then you can use the functions isDisambiguation and _isDisambiguationPage.
If you have already have a Title object for the page to check, get the content using the title object's getContent() method, and pass that into isDisambiguation:
local isDab = mDisambiguation.isDisambiguation(content) -- returns true or false
- (where
contentis a string, the wikitext content of page to check)
If you don't otherwise need the title, you can pass in the page name to _isDisambiguationPage:
local isDab = mDisambiguation._isDisambiguationPage(pageName) -- returns true or false
- (where
pageNameis a string, the name of page to check)