Toggle menu
15
236
70
27.5K
Kenshi Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Disambiguation/doc: Difference between revisions

From Kenshi Wiki
Created page with "{{used in system}} {{lua|Module:Redirect}} This module detects if a given page is a disambiguation page. ==Usage== <pre> {{#invoke:Disambiguation|isDisambiguationPage|Page title}} </pre> :returns <code>yes</code> if the page is a disambiguation page, or nothing if the page is not a disambiguation page Examples: * <code><nowiki>{{#invoke:Disambiguation|isDisambiguationPage|</nowiki>Paris}}</code> → {{#invoke:Disambiguation|isDisambiguationPage|Paris}} * <code><now..."
 
No edit summary
Line 1: Line 1:
{{used in system}}
{{doc sub}}
{{lua|Module:Redirect}}
{{lua|Module:Redirect}}
This module detects if a given page is a disambiguation page.
This module detects if a given page is a disambiguation page.
Line 41: Line 41:


<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||
[[Category:Modules]]
[[Category:Disambiguation and redirection templates]]
[[Category:Disambiguation and redirection templates]]
}}</includeonly><noinclude>
}}</includeonly><noinclude>
[[Category:Module documentation pages]]
[[Category:Module documentation pages]]
</noinclude>
</noinclude>

Revision as of 22:47, 27 February 2025

This module detects if a given page is a disambiguation page.

Usage

{{#invoke:Disambiguation|isDisambiguationPage|Page title}}
returns yes if 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 content 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 _isDisambiguationPage:

local isDab = mDisambiguation._isDisambiguationPage(pageName) -- returns true or false
(where pageName is a string, the name of page to check)

Internal operations

  • Although set index articles are treated by some templates as disambiguation pages, they are actually considered a special type of list and are not treated as disambiguation pages by this module
  • As this module relies on detecting templates with names like "disambiguation" in the article text, it is subject to false positives by templates such as {{italic disambiguation}}. These templates should be added to the falsePositives list in the code to exclude them.
  • The list of disambiguation templates is maintained at Module:Disambiguation/templates.