Module:Documentation: Difference between revisions

Jump to navigation Jump to search
i18n of link names in the endBox function
(finish i18n for the startBox function)
(i18n of link names in the endBox function)
Line 21:
cfg.contentArg = 'content' -- Passes documentation content directly from the {{documentation}} invocation.
cfg.linkBoxArg = 'link box' -- Specifies a custom link box (end box) or prevents it from being generated.
 
-- Argument values
-- The following are argument values that are checked by the module.
 
cfg.linkBoxOff = 'off' -- The value to send to cfg.linkBoxArg to turn the link box off.
 
-- Software settings
Line 26 ⟶ 31:
-- defined in commons.css or the names of templates.
 
cfg.docSubpage = 'doc' -- The name of the subpage typically used for documentation pages.
cfg.sandboxSubpage = 'sandbox' -- The name of the template subpage typically used for sandboxes.
cfg.testcasesSubpage = 'testcases' -- The name of the template subpage typically used for test cases.
cfg.mainDivId = 'template-documentation' -- The "id" attribute of the main HTML "div" tag.
cfg.mainDivClasses = 'template-documentation iezoomfix' -- The CSS classes added to the main HTML "div" tag.
cfg.sandboxSubpage = 'sandbox' -- The name of the template subpage typically used for sandboxes.
cfg.sandboxNoticeTemplate = 'template sandbox notice' -- The name of the template to display at the top of sandbox pages.
cfg.sandboxNoticeLivepageParam = 1 -- The parameter of the sandbox notice template to send the cfg.livepageArg to.
cfg.protectionTemplate = 'pp-template' -- The name of the template that displays the protection icon (a padlock on enwiki).
cfg.protectionTemplateArgs = {docusage = 'yes'} -- Any arguments to send to the protection template.
cfg.docSubpage = 'doc' -- The name of the subpage typically used for documentation pages.
cfg.startBoxLinkclasses = 'mw-editsection plainlinks' -- The CSS classes used for the [view][edit][history] or [create] links in the start box.
cfg.startBoxLinkId = 'doc_editlinks' -- The HTML "id" attribute for the links in the start box.
cfg.fileDocpagePreload = 'Template:Documentation/preload-filespace' -- A preload file for documentation page in the file namespace.
cfg.docpagePreload = 'Template:Documentation/preload-filespace' -- A preload file for template documentation pages in all namespaces.
 
-- Settings for the {{fmbox}} template.
 
cfg.fmboxIdParam = 'id' -- The name of the "id" parameter of {{fmbox}}.
cfg.fmboxId = 'documentation-meta-data' -- The id sent to the "id" parameter of the {{fmbox}} template.
cfg.fmboxImageParam = 'image' -- The name of the "image" parameter of {{fmbox}}.
cfg.fmboxImageNone = 'none' -- The value to suppress image output from the "image" parameter of {{fmbox}}.
cfg.fmboxStyleParam = 'style' -- The name of the "style" parameter of {{fmbox}}.
cfg.fmboxStyle = 'background-color: #ecfcf4' -- The value sent to the style parameter of {{fmbox}}.
cfg.fmboxTextstyleParam = 'textstyle' -- The name of the "textstyle" parameter of {{fmbox}}.
cfg.fmboxTextstyle = 'font-style: italic;' -- The value send to the "textstyle parameter of {{fmbox}}.
 
-- Display settings
Line 48 ⟶ 65:
cfg.createLinkDisplay = 'create' -- The text to display for "create" links.
cfg.sandboxLinkDisplay = 'sandbox' -- The text to display for "sandbox" links.
cfg.sandboxEditLinkDisplay = 'edit' -- The text to display for sandbox "edit" links.
cfg.sandboxCreateLinkDisplay = 'create' -- The text to display for sandbox "create" links.
cfg.compareLinkDisplay = 'diff' -- The text to display for "compare" links.
cfg.mirrorLinkDisplay = 'mirror' -- The text to display for "mirror" links.
cfg.testcasesLinkDisplay = 'testcases' -- The text to display for "testcases" links.
cfg.testcasesEditLinkDisplay = 'edit' -- The text to display for test cases "edit" links.
cfg.testcasesCreateLinkDisplay = 'create' -- The text to display for test cases "create" links.
cfg.documentationIconWikitext = '[[File:Template-info.png|50px|link=|alt=Documentation icon]]' -- The wikitext for the icon shown at the top of the template.
cfg.templateNamespaceHeading = 'Template documentation' -- The heading shown in the template namespace.
Line 327 ⟶ 351:
local docnameFed = args[1] and true
local sandbox = docpageRoot .. '/' .. cfg.sandboxSubpage
local testcases = docpageRoot .. '/testcases' .. cfg.testcasesSubpage
templatePage = currentTitle.nsText .. ':' .. templatePage
 
Line 334 ⟶ 358:
-- First, check whether we should output the end box at all. Add the end box by default if the documentation
-- exists or if we are in the user, module or template namespaces.
if linkBox == 'off'cfg.linkBoxOff or not (docExist or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10) then
return nil
end
Line 340 ⟶ 364:
-- Assemble the arguments for {{fmbox}}.
local fmargs = {}
fmargs[cfg.fmboxIdParam] = cfg.fmboxId -- Sets fmargs.id = 'documentation-meta-data'
fmargs[cfg.fmboxImageParam] = cfg.fmboxImageNone -- Sets fmargs.image = 'none'
fmargs[cfg.fmboxStyleParam] = cfg.fmboxStyle -- Sets fmargs.style = 'background-color: #ecfcf4'
fmargs[cfg.fmboxTextstyleParam] = cfg.fmboxTextstyle -- Sets fmargs.textstyle = 'font-style: italic;'
 
-- Assemble the fmbox text field.
Line 354 ⟶ 378:
-- /doc exists; link to it.
local docLink = makeWikilink(docpage)
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, 'edit'cfg.editLinkDisplay)
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, 'history'cfg.historyLinkDisplay)
text = text .. 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from '
.. docLink .. '. ' .. makeToolbar(editLink, historyLink) .. '<br />'
elseif subjectSpace == 828 then
-- /doc does not exist; ask to create it.
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = 'Template:Documentation/preload-module-doc'}, 'create'cfg.createLinkDisplay)
text = text .. 'You might want to ' .. createLink .. ' a documentation page for this [[Wikipedia:Lua|Scribunto module]].<br />'
end
Line 371 ⟶ 395:
if sandboxTitle.exists then
local sandboxLink = makeWikilink(sandbox, cfg.sandboxLinkDisplay)
local sandboxEditLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit'}, 'edit'cfg.sandboxEditLinkDisplay)
local compareLink = makeUrlLink(mw.title.new('Special:ComparePages'):fullUrl{page1 = templatePage, page2 = sandbox}, 'diff'cfg.compareLinkDisplay)
text = text .. sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
else
local sandboxPreload = 'Template:Documentation/preload-' .. (subjectSpace == 828 and 'module-' or '') .. 'sandbox'
local sandboxCreateLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}, 'create'cfg.sandboxCreateLinkDisplay)
local mirrorSummary = 'Create sandbox version of ' .. makeWikilink(templatePage)
local mirrorLink = makeUrlLink(sandboxTitle:fullUrl{action = 'edit', preload = templatePage, summary = mirrorSummary}, 'mirror'cfg.mirrorLinkDisplay)
text = text .. cfg.sandboxLinkDisplay .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
end
Line 384 ⟶ 408:
local testcaseTitle = mw.title.new(testcases)
if testcaseTitle.exists then
local testcasesLink = makeWikilink(testcases, 'testcases'cfg.testcasesLinkDisplay)
local testcasesEditLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit'}, 'edit'cfg.testcasesEditLinkDisplay)
text = text .. testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
else
local testcasesPreload = 'Template:Documentation/preload-' .. (subjectSpace == 828 and 'module-' or '') .. 'testcases'
local testcasesCreateLink = makeUrlLink(testcaseTitle:fullUrl{action = 'edit', preload = testcasesPreload}, 'create'cfg.testcasesCreateLinkDisplay)
text = text .. cfg.testcasesLinkDisplay .. 'testcases ' .. makeToolbar(testcasesCreateLink)
end
text = text .. ' pages. <br />'
Line 429 ⟶ 453:
local ret = ''
local subpage = currentTitle.subpageText
if subpage == cfg.docSubpage or subpage == 'testcases'cfg.testcasesSubpage then
local sort = (currentTitle.namespace == 0 and 'Main:' or '') .. currentTitle.prefixedText -- Sort on namespace.
ret = ret .. makeWikilink('Category:Wikipedia pages with strange ((documentation)) usage', sort)
Line 450 ⟶ 474:
-- Determines the template page. No namespace or interwiki prefixes are included.
local subpage = currentTitle.subpageText
if subpage == cfg.sandboxSubpage or subpage == 'testcases'cfg.testcasesSubpage then
return currentTitle.baseText
else
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu