Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WiktionaryThe Free Dictionary
Search

Module:documentation

From Wiktionary, the free dictionary

The followingdocumentation is located atModule:documentation/documentation.[edit]
Useful links:subpage listlinkstransclusionstestcasessandbox

Serves{{documentation}} and{{translit module documentation}}.{{documentation}} is added to modules automatically (throughMediaWiki:Scribunto-doc-page-show if the doc page exists, otherwise throughMediaWiki:Scribunto-doc-page-does-not-exist); added to user JavaScript pages automatically (throughMediaWiki:Clearyourcache); and manually added to template pages. It automatically adds categories, or categories and documentation, to some modules based on their titles.

More specifically, for modules:

  1. When there is no doc page for the module,Module:documentation checks for various sorts of special modules (based on the module title) and autogenerates the documentation and categories of those modules. If this check fails, the module is added toCategory:Templates and modules needing documentation, andModule:module categorization is called to autogenerate the categories for lang-specific modules of the formLANGCODE-TYPE, optionally with a subpage (e.g.LANGCODE-TYPE/data,LANGCODE-TYPE/testcases,LANGCODE-TYPE/data/testcases, or any other subpage). If this check also fails, the module is added toCategory:Uncategorized modules.
  2. When there is a doc page for the module, the contents of that page take precedence over any autogenerated content. However, if that page does not have an<includeonly>...</includeonly> section and does not have an invocation of{{module cat}}, the same checks are done as when no doc page exists (including checks for specially-titled modules and falling back to callingModule:module categorization), but only for the purposes of autogenerating categories. If no such categories could be determined, the module is added toCategory:Uncategorized modules.

More specifically, for templates:

  • ... (DOCUMENT ME)

Ideas:

  • Make more usable on other Wiktionaries by creating data module with translations of text, and moving module regex to separate module.

Automatic module documentation generators

RegexCategoryHandling modules
^Module:languages/data/(3/%l/extra)$(unspecified)(handled internally)
^Module:languages/data/(3/%l)$(unspecified)(handled internally)
^Module:languages/data/(2/extra)$(unspecified)(handled internally)
^Module:languages/data/(2)$(unspecified)(handled internally)
^Module:languages/data/(exceptional/extra)$(unspecified)(handled internally)
^Module:languages/data/(exceptional)$(unspecified)(handled internally)
^Module:languages/.+$Language and script modules(no documentation generator)
^Module:scripts/.+$Language and script modules(no documentation generator)
^Module:data tables/data..?.?.?$Reference module sharded data tables(no documentation generator)
^Module:zh/data/dial%-pron/.+$Chinese dialectal pronunciation data modulesModule:documentation/functions/zh dial or syn
^Module:zh/data/dial%-syn/.+$Chinese dialect synonyms data modulesModule:documentation/functions/zh dial or syn
^Module:zh/data/glyph%-data/.+$Chinese historical character forms data modules(handled internally)
^Module:zh/data/ltc%-pron/(.+)$Middle Chinese pronunciation data modules|%1Module:documentation/functions/zh data
^Module:zh/data/och%-pron%-BS/(.+)$Old Chinese (Baxter-Sagart) pronunciation data modules|%1Module:documentation/functions/zh data
^Module:zh/data/och%-pron%-ZS/(.+)$Old Chinese (Zhengzhang) pronunciation data modules|%1Module:documentation/functions/zh data
^Module:zh/data/(.+)$Chinese data modules|%1(no documentation generator)
^Module:mul/guoxue%-data/cjk%-?(.*)$(unspecified)Module:documentation/functions/guoxue-data
^Module:Unicode data/(.+)$Unicode data modules|%1(handled internally)
^Module:number list/data/(.+)$(unspecified)(handled internally)
^Module:accel/(.+)$(unspecified)(handled internally)
^Module:inc%-ash/dial/data/(.+)$Ashokan Prakrit modules|%1(handled internally)
^.+%-translit$(unspecified)Module:documentation/functions/translit
^Module:form of/lang%-data/(.+)$(unspecified)(handled internally)
^Module:labels/data/lang/(.+)$(unspecified)(handled internally)
^Module:category tree/lang/(.+)$(unspecified)(handled internally)
^Module:category tree/topic/(.+)$(unspecified)(handled internally)
^Module:category tree/(.+)$(unspecified)(handled internally)
^Module:ja/data/(.+)$Japanese data modules|%1(no documentation generator)
^Module:fi%-dialects/data/feature/Kettunen1940 ([0-9]+)$Finnish dialectal data atlas modules|%1(handled internally)
^Module:fi%-dialects/data/feature/(.+)Finnish dialectal data modules|%1(no documentation generator)
^Module:fi%-dialects/data/word/(.+)Finnish dialectal data modules|%1(no documentation generator)
^Module:Swadesh/data/([%l-]+)$(unspecified)(handled internally)
^Module:Swadesh/data/([%l-]+)/([^/]*)$(unspecified)(handled internally)
^Module:typing%-aids(unspecified)(handled internally)
^Module:R:([%l-]+):(.+)$(unspecified)(handled internally)
^Module:Quotations/([%l-]+)/?(.*)(unspecified)Module:documentation/functions/Quotation
^Module:affix/lang%-data/([%l-]+)(unspecified)Module:documentation/functions/affix lang-data
^Module:dialect synonyms/([%l-]+)$(unspecified)(handled internally)
^Module:dialect synonyms/([%l-]+)/(.+)$(unspecified)(handled internally)
^Module:bibliography/data/([%l-]+)$(unspecified)(handled internally)

localexport={}localarray_module="Module:array"localdebug_track_module="Module:debug/track"localframe_module="Module:frame"localfun_is_callable_module="Module:fun/isCallable"locallanguages_module="Module:languages"locallinks_module="Module:links"localload_module="Module:load"localmodule_categorization_module="Module:module categorization"localnumber_list_show_module="Module:number list/show"localpages_module="Module:pages"localparameters_module="Module:parameters"localscripts_module="Module:scripts"localstring_endswith_module="Module:string/endswith"localstring_gline_module="Module:string/gline"localstring_insert_module="Module:string/insert"localstring_startswith_module="Module:string/startswith"localstring_utilities_module="Module:string utilities"localtemplate_parser_module="Module:template parser"localtitle_exists_module="Module:title/exists"localtitle_new_title_module="Module:title/newTitle"localconcat=table.concatlocalerror=errorlocalfull_url=mw.uri.fullUrllocalget_current_title=mw.title.getCurrentTitlelocalinsert=table.insertlocalipairs=ipairslocallist_to_text=mw.text.listToTextlocalnew_message=mw.message.newlocalpcall=pcalllocalrequire=requirelocaltonumber=tonumberlocaltostring=tostringlocaltype=typelocalunpack=unpackortable.unpack-- Lua 5.2 compatibilitylocalfunctionArray(...)Array=require(array_module)returnArray(...)endlocalfunctioncategorize_module(...)categorize_module=require(module_categorization_module).categorizereturncategorize_module(...)endlocalfunctiondebug_track(...)debug_track=require(debug_track_module)returndebug_track(...)endlocalfunctionendswith(...)endswith=require(string_endswith_module)returnendswith(...)endlocalfunctionexpand_template(...)expand_template=require(frame_module).expandTemplatereturnexpand_template(...)endlocalfunctionfind_templates(...)find_templates=require(template_parser_module).find_templatesreturnfind_templates(...)endlocalfunctionfull_link(...)full_link=require(links_module).full_linkreturnfull_link(...)endlocalfunctionget_lang(...)get_lang=require(languages_module).getByCodereturnget_lang(...)endlocalfunctionget_pagetype(...)get_pagetype=require(pages_module).get_pagetypereturnget_pagetype(...)endlocalfunctionget_script(...)get_script=require(scripts_module).getByCodereturnget_script(...)endlocalfunctiongline(...)gline=require(string_gline_module)returngline(...)endlocalfunctionis_callable(...)is_callable=require(fun_is_callable_module)returnis_callable(...)endlocalfunctionis_documentation(...)is_documentation=require(pages_module).is_documentationreturnis_documentation(...)endlocalfunctionis_sandbox(...)is_sandbox=require(pages_module).is_sandboxreturnis_sandbox(...)endlocalfunctionnew_title(...)new_title=require(title_new_title_module)returnnew_title(...)endlocalfunctionnumber_list_show_table(...)number_list_show_table=require(number_list_show_module).tablereturnnumber_list_show_table(...)endlocalfunctionpreprocess(...)preprocess=require(frame_module).preprocessreturnpreprocess(...)endlocalfunctionprocess_params(...)process_params=require(parameters_module).processreturnprocess_params(...)endlocalfunctionsafe_load_data(...)safe_load_data=require(load_module).safe_load_datareturnsafe_load_data(...)endlocalfunctionsplit(...)split=require(string_utilities_module).splitreturnsplit(...)endlocalfunctionstartswith(...)startswith=require(string_startswith_module)returnstartswith(...)endlocalfunctionstring_insert(...)string_insert=require(string_insert_module)returnstring_insert(...)endlocalfunctiontitle_exists(...)title_exists=require(title_exists_module)returntitle_exists(...)endlocalfunctionugsub(...)ugsub=require(string_utilities_module).gsubreturnugsub(...)endlocalfunctionumatch(...)umatch=require(string_utilities_module).matchreturnumatch(...)endlocalskins={["common"]="";["vector"]="Vector";["monobook"]="Monobook";["cologneblue"]="Cologne Blue";["modern"]="Modern";}localfunctiontrack(page)debug_track("documentation/"..page)returntrueendlocalfunctioncompare_pages(page1,page2,text)return"["..tostring(full_url("Special:ComparePages",{page1=page1,page2=page2})).." "..text.."]"end-- Avoid transcluding [[Module:languages/cache]] everywhere.locallang_cache=setmetatable({},{__index=function(self,k)returnrequire("Module:languages/cache")[k]end})localfunctionzh_link(word)returnfull_link{lang=lang_cache.zh,term=word}endlocalfunctionmake_languages_data_documentation(title,cats,division)localdoc_template,module_catifendswith(division,"/extra")thendivision=division:sub(1,-7)doc_template="language extradata documentation"module_cat="Language extra data modules"elsedoc_template="language data documentation"module_cat="Language data modules"endlocalsort_keyifdivision=="exceptional"thensort_key="x"elsesort_key=division:gsub("/","")endcats:insert(module_cat.."|"..sort_key)return{title=doc_template}endlocalfunctionmake_Unicode_data_documentation(title,cats)localsubpage,first_three_of_code_point=title.fullText:match("^Module:Unicode data/([^/]+)/(%x%x%x)$")ifsubpage=="names"orsubpage=="images"orsubpage=="emoji images"thenlocallow,high=tonumber(first_three_of_code_point.."000",16),tonumber(first_three_of_code_point.."FFF",16)localtext,text_typeifsubpage=="names"thentext_type="titles of images"elseifsubpage=="images"thentext_type="titles of images"elseifsubpage=="emoji images"thentext_type="emoji-style images"endtext=string.format("This data module contains the "..text_type.." of ".."[[Appendix:Unicode|Unicode]] code points within the range U+%04X to U+%04X.",low,high)ifsubpage=="images"andsafe_load_data("Module:Unicode data/emoji images/"..first_three_of_code_point)thentext=text.." This list includes the text variants of emojis. For the list of emoji variants of those characters, see [[Module:Unicode data/emoji images/"..first_three_of_code_point.."]]."elseifsubpage=="emoji images"thentext=text.." For text-style images, see [[Module:Unicode data/images/"..first_three_of_code_point.."]]."endreturntextendendlocalfunctioninsert_lang_data_module_cats(cats,langcode,overall_data_module_cat)locallang=lang_cache[langcode]iflangthenlocallangnameiflang._fullCodethenlangname=lang_cache[lang._fullCode]:getCanonicalName()elselangname=lang:getCanonicalName()endcats:insert(overall_data_module_cat.."|"..langname)cats:insert(langname.." modules")cats:insert(langname.." data modules")returnlang,langnameendend--[=[This provides categories and documentation for various data modules, so that [[Category:Uncategorized modules]] isn'tunnecessarily cluttered. It is a list of tables, each of which have the following possible fields:`regex` (required): A Lua pattern to match the module's title. If it matches, the data in this entry will be used.Any captures in the pattern can by referenced in the `cat` field using %1 for the first capture, %2 for thesecond, etc. (often used for creating the sortkey for the category). In addition, the captures are passed to the`process` function as the third and subsequent parameters.`process` (optional): This may be a function or a string. If it is a function, it is called as follows:   `process(TITLE, CATS, CAPTURE1, CAPTURE2, ...)`where:   * TITLE is a title object describing the module's title; see     [https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Title_objects].   * CATS is an array object (see [[Module:array]]) of categories that the module will be added to.   * CAPTURE1, CAPTURE2, ... contain any captures in the `regex` field.The return value of `process` should either be a string (which will be used as the module's documentation), or atable specifying the name of a template to expand to get the documentation, along with the arguments to thattemplate. In the latter format, the template name (bare, without the "Template:" prefix) should be in the `title`field, and any arguments should be in `args; in this case, the template name will be listed above the generateddocumentation as the source of the documentation, along with an edit button to edit the template's contents.If, however, the return value of the `process` function is a string, any template invocations will be expandedusing frame:preprocess(), and [[Module:documentation]] will be listed as the source of the documentation.If `process` itself is a string rather than a function, it should name a submodule under[[Module:documentation/functions/]] which returns a function, of the same type as described above. This submodulewill be specified as the source of the documentation (unless it returns a table naming a template to expand to getthe documentation, as described above).If `process` is omitted entirely, the module will have no documentation.`cat` (optional): A string naming the category into which the module should be placed, or a list of such strings.Captures specified in `regex` may be referenced in this string using %1 for the first capture, %2 for the second,etc. It is also possible to add categories in the `process` function by inserting them into the passed-in CATSarray (the second parameter).]=]localmodule_regex={{regex="^Module:languages/data/(3/%l/extra)$",process=make_languages_data_documentation,},{regex="^Module:languages/data/(3/%l)$",process=make_languages_data_documentation,},{regex="^Module:languages/data/(2/extra)$",process=make_languages_data_documentation,},{regex="^Module:languages/data/(2)$",process=make_languages_data_documentation,},{regex="^Module:languages/data/(exceptional/extra)$",process=make_languages_data_documentation,},{regex="^Module:languages/data/(exceptional)$",process=make_languages_data_documentation,},{regex="^Module:languages/.+$",cat="Language and script modules",},{regex="^Module:scripts/.+$",cat="Language and script modules",},{regex="^Module:data tables/data..?.?.?$",cat="Reference module sharded data tables",},{regex="^Module:zh/data/dial%-pron/.+$",cat="Chinese dialectal pronunciation data modules",process="zh dial or syn",},{regex="^Module:zh/data/dial%-syn/.+$",cat="Chinese dialect synonyms data modules",process="zh dial or syn",},{regex="^Module:zh/data/glyph%-data/.+$",cat="Chinese historical character forms data modules",process=function(title,cats)localcharacter=title.fullText:match("^Module:zh/data/glyph%-data/(.+)")ifcharacterthenreturn("This module contains data on historical forms of the Chinese character %s."):format(zh_link(character))endend,},{regex="^Module:zh/data/ltc%-pron/(.+)$",cat="Middle Chinese pronunciation data modules|%1",process="zh data",},{regex="^Module:zh/data/och%-pron%-BS/(.+)$",cat="Old Chinese (Baxter-Sagart) pronunciation data modules|%1",process="zh data",},{regex="^Module:zh/data/och%-pron%-ZS/(.+)$",cat="Old Chinese (Zhengzhang) pronunciation data modules|%1",process="zh data",},{-- capture rest of zh/data submodulesregex="^Module:zh/data/(.+)$",cat="Chinese data modules|%1",},{regex="^Module:mul/guoxue%-data/cjk%-?(.*)$",process="guoxue-data",},{regex="^Module:Unicode data/(.+)$",cat="Unicode data modules|%1",process=make_Unicode_data_documentation,},{regex="^Module:number list/data/(.+)$",process=function(title,cats,lang_code)locallang=insert_lang_data_module_cats(cats,lang_code,"Number data modules")iflangthenreturn("This module contains data on various types of numbers in %s.\n%s"):format(lang:makeCategoryLink(),number_list_show_table()or"")endend,},{regex="^Module:accel/(.+)$",process=function(title,cats)locallang_code=title.subpageTextlocallang=lang_cache[lang_code]iflangthencats:insert(lang:getCanonicalName().." modules|accel")cats:insert(("Accel submodules|%s"):format(lang:getCanonicalName()))return("This module contains new entry creation rules for %s; see [[WT:ACCEL]] for an overview, and [[Module:accel]] for information on creating new rules."):format(lang:makeCategoryLink())endend,},{regex="^Module:inc%-ash/dial/data/(.+)$",cat="Ashokan Prakrit modules|%1",process=function(title,cats)localword=title.fullText:match("^Module:inc%-ash/dial/data/(.+)$")ifwordthenlocallang=lang_cache["inc-ash"]return("This module contains data on the pronunciation of %s in dialects of %s."):format(full_link({term=word,lang=lang},"term"),lang:makeCategoryLink())endend,},{regex="^.+%-translit$",process="translit",},{regex="^Module:form of/lang%-data/(.+)$",process=function(title,cats,lang_code)locallang,langname=insert_lang_data_module_cats(cats,lang_code,"Language-specific form-of modules")iflangthen-- FIXME, display more info.return"This module contains language-specific form-of data (tags, shortcuts, base lemma params. etc.) for "..langname.."."endend},{regex="^Module:labels/data/lang/(.+)$",process=function(title,cats,lang_code)locallang=insert_lang_data_module_cats(cats,lang_code,"Language-specific label data modules")iflangthenreturn{title="label language-specific data documentation",args={[1]=lang_code},}endend},{regex="^Module:category tree/lang/(.+)$",process=function(title,cats,lang_code)locallang,langname=insert_lang_data_module_cats(cats,lang_code,"Category tree data modules/lang")iflangthenreturn"This module handles generating the descriptions and categorization for "..langname.." category pages ".."of the format\""..langname.." LABEL\" where LABEL can be any text. Examples are ".."[[:Category:Bulgarian conjugation 2.1 verbs]] and [[:Category:Russian velar-stem neuter-form nouns]]. ".."This module is part of the category tree system, which is a general framework for generating the ".."descriptions and categorization of category pages.\n\n".."For more information, see [[Module:category tree/lang/documentation]].\n\n".."'''NOTE:''' If you add a new language-specific module, you must add the language code to the ".."list at the top of [[Module:category tree/lang]] in order for the module to be recognized."endend},{regex="^Module:category tree/topic/(.+)$",process=function(title,cats,submodule)cats:insert("Category tree data modules/topic| ")return{title="topic cat data submodule documentation"}end},{regex="^Module:category tree/(.+)$",process=function(title,cats,submodule)cats:insert("Category tree data modules| ")return{title="category tree data submodule documentation"}end},{regex="^Module:ja/data/(.+)$",cat="Japanese data modules|%1",},{regex="^Module:fi%-dialects/data/feature/Kettunen1940 ([0-9]+)$",cat="Finnish dialectal data atlas modules|%1",process=function(title,cats,shard)return"This module contains shard "..shard.." of the online version of Lauri Kettunen's 1940 work ".."''Suomen murteet III A. Murrekartasto'' (\"Finnish dialects III A: Dialect atlas\"). ".."It was imported and converted from urn:nbn:fi:csc-kata20151130145346403821, published by the ".."''Kotimaisten kielten keskus'' under the CC BY 4.0 license."end},{regex="^Module:fi%-dialects/data/feature/(.+)",cat="Finnish dialectal data modules|%1",},{regex="^Module:fi%-dialects/data/word/(.+)",cat="Finnish dialectal data modules|%1",},{regex="^Module:Swadesh/data/([%l-]+)$",process=function(title,cats,lang_code)locallang,langname=insert_lang_data_module_cats(cats,lang_code,"Swadesh modules")iflangthenreturn"This module contains the [[Swadesh list]] of basic vocabulary in "..langname.."."endend},{regex="^Module:Swadesh/data/([%l-]+)/([^/]*)$",process=function(title,cats,lang_code,variety)locallang,langname=insert_lang_data_module_cats(cats,lang_code,"Swadesh modules")iflangthenlocalprefix="This module contains the [[Swadesh list]] of basic vocabulary in the "localetym_lang=get_lang(variety,nil,"allow etym")ifetym_langthenreturn("%s %s variety of %s."):format(prefix,etym_lang:getCanonicalName(),langname)endlocalscript=get_script(variety)ifscriptthenreturn("%s %s %s script."):format(prefix,langname,script:getCanonicalName())endreturn("%s %s variety of %s."):format(prefix,variety,langname)endend},{regex="^Module:typing%-aids",process=function(title,cats)localdata_suffix=title.fullText:match("^Module:typing%-aids/data/(.+)$")localsortkeyifdata_suffixthenifdata_suffix:find"^[%l-]+$"thenlocallang=get_lang(data_suffix)iflangthensortkey=lang:getCanonicalName()cats:insert(sortkey.." data modules")endelseifdata_suffix:find"^%u%l%l%l$"thenlocalscript=get_script(data_suffix)ifscriptthensortkey=script:getCanonicalName()cats:insert(script:getCategoryName())endendcats:insert("Character insertion data modules|"..(sortkeyordata_suffix))endend,},{regex="^Module:R:([%l-]+):(.+)$",process=function(title,cats,lang_code,refname)locallang=lang_cache[lang_code]iflangthencats:insert(lang:getCanonicalName().." modules|"..refname)cats:insert(("Reference modules|%s"):format(lang:getCanonicalName()))return"This module implements the reference template {{temp|R:"..lang_code..":"..refname.."}}."endend,},{regex="^Module:Quotations/([%l-]+)/?(.*)",process="Quotation",},{regex="^Module:affix/lang%-data/([%l-]+)",process="affix lang-data",},{regex="^Module:dialect synonyms/([%l-]+)$",process=function(title,cats,lang_code)locallang=lang_cache[lang_code]iflangthenlocallangname=lang:getCanonicalName()cats:insert("Dialect synonyms data modules|"..langname)cats:insert(langname.." dialect synonyms data modules| ")return"This module contains data on specific varieties of "..langname..", for use by ".."{{tl|dialect synonyms}}. The actual synonyms themselves are contained in submodules.\n\n"..expand_template({title='dial syn',args={lang_code,["demo mode"]="y"}})endend,},{regex="^Module:dialect synonyms/([%l-]+)/(.+)$",process=function(title,cats,lang_code,term)locallang=lang_cache[lang_code]iflangthenlocallangname=lang:getCanonicalName()cats:insert("Dialect synonyms data modules|"..langname)cats:insert(langname.." dialect synonyms data modules|"..term)return("This module contains dialectal %s synonyms for {{m|%s|%s}}.\n\n%s"):format(langname,lang_code,term,expand_template({title='dial syn',args={lang_code,term}}))endend,},{regex="^Module:bibliography/data/([%l-]+)$",process=function(title,cats,lang_code)iflang_code=="preload"thenreturn'Used as a base model for other languages when the button "create new language submodule" is clicked.'endlocalpage=require(title.fullText).bib_pageifnotpagethenpage=lang_cache[lang_code]:getCanonicalName()ifpagethencats:insert(page.." modules")endendcats:insert("Reference modules")return"This module holds bibliographical data for "..page..". For the formatted bibliography see '''[[Appendix:Bibliography/"..page.."]]'''."end,},}functionexport.show(frame)localboolean_default_false={type="boolean",default=false}localargs=process_params(frame.args,{["hr"]=true,["for"]=true,["from"]=true,["allowondoc"]=boolean_default_false,-- Don't throw an error if used on a documentation subpage.["notsubpage"]=boolean_default_false,["nodoc"]=boolean_default_false,["nolinks"]=boolean_default_false,-- suppress all "Useful links"["nosandbox"]=boolean_default_false,-- supress sandbox})localoutput=Array('\n<div>\n')localcats=Array()localnodoc=args.nodocif(notargs.hr)or(args.hr=="above")thenoutput:insert("----\n")endlocaltitle=args["for"]andnew_title(args["for"])orget_current_title()localdoc_title=args.from~="-"andnew_title(args.fromortitle.fullText..'/documentation')ornillocalcontentModel=title.contentModellocalpagetype,is_script_or_stylesheet=get_pagetype(title)localpreload,fallback_docs,doc_content,old_doc_title,user_name,skin_name,needs_doclocaldoc_content_source="Module:documentation"localauto_generated_cat_sourcelocalcats_auto_generated=falseifnotargs.allowondocandis_documentation(title)then-- TODO: merge with {{documentation subpage}}, and choose behaviour based on the page type.error("This template should not be used on a documentation page. Please use [[Template:documentation subpage]].")elseifis_sandbox(title)thenlocalsandbox_ns=title.nsTextpreload=("Template:documentation/preload%s%sSandbox"):format(sandbox_ns=="Module"andsandbox_nsor"Template",title.rootText:match("^[Uu]ser:(.+)")and"User"or"")elseifpagetype:match("%f[%w]gadget%f[%W]")thenpreload="Template:documentation/preloadGadget"elseifpagetype:match("%f[%w]script%f[%W]")then-- .jsiftitle.nsText=="MediaWiki"thenpreload="Template:documentation/preloadMediaWikiJavaScript"elsepreload="Template:documentation/preloadTemplate"-- XXXiftitle.nsText=="User"thenuser_name=title.rootTextendendis_script_or_stylesheet=trueelseifpagetype:match("%f[%w]stylesheet%f[%W]")then-- .csspreload="Template:documentation/preloadTemplate"-- XXXiftitle.nsText=="User"thenuser_name=title.rootTextendis_script_or_stylesheet=trueelseifcontentModel=="Scribunto"then-- Exclude pages in Module: which aren't Scribunto.preload="Template:documentation/preloadModule"elseifpagetype:match("%f[%w]template%f[%W]")orpagetype:match("%f[%w]project%f[%W]")thenpreload="Template:documentation/preloadTemplate"endifdoc_titleanddoc_title.isRedirectthenold_doc_title=doc_titledoc_title=doc_title.redirectTargetendoutput:insert("<dl class=\"plainlinks\" style=\"font-size: smaller;\">")localfunctionget_module_doc_and_cats(categories_only)cats_auto_generated=truelocalautomatic_cats=nilifuser_namethenfallback_docs="documentation/fallback/user module"automatic_cats={"User sandbox modules"}elsefor_,datainipairs(module_regex)dolocalcaptures={umatch(title.fullText,data.regex)}if#captures>0thenlocalcat,process_functionifis_callable(data.process)thenprocess_function=data.processelseiftype(data.process)=="string"thendoc_content_source="Module:documentation/functions/"..data.processprocess_function=require(doc_content_source)endifprocess_functionthendoc_content=process_function(title,cats,unpack(captures))endiftype(doc_content)=="table"thendoc_content_source=doc_content.titleand"Template:"..doc_content.titleordoc_content_sourcedoc_content=expand_template(doc_content)elseifdoc_content~=nilthendoc_content=preprocess(doc_content)endcat=data.catifcattheniftype(cat)=="string"thencat={cat}endfor_,cinipairs(cat)doinsert(cats,(ugsub(title.fullText,data.regex,c)))endendbreakendendendiftitle.subpageText=="templates"thencats:insert("Template interface modules")endifautomatic_catsthenfor_,cinipairs(automatic_cats)docats:insert(c)endendif#cats==0thenlocalauto_cats=categorize_module(frame,"return raw","noerror")if#auto_cats>0thenauto_generated_cat_source="Module:module categorization"endfor_,categoryinipairs(auto_cats)docats:insert(category)endend-- meaning module is not in user’s sandbox or one of many datamodule boring seriesneeds_doc=notcategories_onlyandnot(automatic_catsordoc_contentorfallback_docs)end-- Override automatic documentation, if present.ifdoc_titleanddoc_title.existsthenlocalcats_auto_generated_text=""ifcontentModel=="Scribunto"thenlocaldoc_page_content=doc_title.content-- Track then do nothing if there are uses of includeonly. The-- pattern is slightly too permissive, but any false-positives are-- obvious typos that should be corrected.ifdoc_page_content:lower():match("</?includeonly%f[%s/>][^>]*>")thentrack("module-includeonly")else-- Check for uses of {{module cat}}. find_templates treats the-- input as transcluded by default (i.e. it parses the wikitext-- which will be transcluded through to the module page).localmodule_catfortemplateinfind_templates(doc_page_content)doiftemplate:get_name()=="module cat"thenmodule_cat=truebreakendendifnotmodule_catthenget_module_doc_and_cats("categories only")auto_generated_cat_source=auto_generated_cat_sourceordoc_content_sourcecats_auto_generated_text=" Categories were auto-generated by [["..auto_generated_cat_source.."]]. <sup>[["..new_title(auto_generated_cat_source):fullUrl{action="edit"}.." edit]]</sup>"endendendoutput:insert("<dd><i style=\"font-size: larger;\">The following ".."[[Help:Documenting templates and modules|documentation]] is located at [["..doc_title.fullText.."]]. ".."<sup>[["..doc_title:fullUrl{action="edit"}.." edit]]</sup>"..cats_auto_generated_text.."</i></dd>")elseifcontentModel=="Scribunto"thenget_module_doc_and_cats(false)elseiftitle.nsText=="Template"then--cats:insert("Uncategorized templates")needs_doc=not(fallback_docsornodoc)elseifuser_nameandis_script_or_stylesheetthenskin_name=skins[title.text:sub(#title.rootText+1):match("^/(%l+)%.[jc]ss?$")]ifskin_namethenfallback_docs="documentation/fallback/user "..contentModelendendifdoc_contentthenoutput:insert("<dd><i style=\"font-size: larger;\">The following ".."[[Help:Documenting templates and modules|documentation]] is ".."generated by [["..doc_content_source.."]]. <sup>[["..new_title(doc_content_source):fullUrl{action="edit"}.." edit]]</sup> </i></dd>")elseifnotnodocthenifdoc_titlethenoutput:insert("<dd><i style=\"font-size: larger;\">This "..pagetype.." lacks a [[Help:Documenting templates and modules|documentation subpage]]. "..(fallback_docsand"You may "or"Please ").."["..doc_title:fullUrl{action="edit",preload=preload}.." create it].</i></dd>\n")elseoutput:insert("<dd><i style=\"font-size: larger; color: #FF0000;\">Unable to auto-generate ".."documentation for this "..pagetype..".</i></dd>\n")endendendifstartswith(title.fullText,"MediaWiki:Gadget-")thenlocalis_gadget=falseforlineingline(new_title("MediaWiki:Gadgets-definition").content)dolocalgadget,items=line:match("^%*%s*(%a[%w_-]*)%[.-%]|(.+)$")ifnotgadgetthengadget,items=line:match("^%*%s*(%a[%w_-]*)|(.+)$")endifgadgetthenitems=Array(split(items,"|"))fori,iteminipairs(items)doiftitle.fullText==("MediaWiki:Gadget-"..item)thenis_gadget=trueoutput:insert("<dd> ''This script is a part of the <code>")output:insert(gadget)output:insert("</code> gadget ([")output:insert(tostring(full_url("MediaWiki:Gadgets-definition",{action="edit"})))output:insert(" edit definitions])'' <dl>")output:insert("<dd> ''Description ([")output:insert(tostring(full_url("MediaWiki:Gadget-"..gadget,{action="edit"})))output:insert(" edit])'': ")output:insert(preprocess(new_message('Gadget-'..gadget):plain()))output:insert(" </dd>")items:remove(i)if#items>0thenforj,iteminipairs(items)doitems[j]='[[MediaWiki:Gadget-'..item..'|'..item..']]'endoutput:insert("<dd> ''Other parts'': ")output:insert(list_to_text(items))output:insert("</dd>")endoutput:insert("</dl></dd>")breakendendendendifnotis_gadgetthenoutput:insert("<dd> ''This script is not a part of any [")output:insert(tostring(full_url("Special:Gadgets",{uselang="en"})))output:insert(' gadget] ([')output:insert(tostring(full_url("MediaWiki:Gadgets-definition",{action="edit"})))output:insert(' edit definitions]).</dd>')-- else-- cats:insert("Wiktionary gadgets")endendifold_doc_titlethenoutput:insert("<dd> ''Redirected from'' [")output:insert(old_doc_title:fullUrl{redirect="no"})output:insert(" ")output:insert(old_doc_title.fullText)output:insert("] ([")output:insert(old_doc_title:fullUrl{action="edit"})output:insert(" edit]).</dd>\n")endifnotargs.nolinksthenlocallinks=Array()iftitle.isSubpageandnotargs.notsubpagethenlinks:insert("[[:"..title.nsText..":"..title.rootText.."|root page]]")links:insert("[[Special:PrefixIndex/"..title.nsText..":"..title.rootText.."/|root page’s subpages]]")elselinks:insert("[[Special:PrefixIndex/"..title.fullText.."/|subpage list]]")endlinks:insert("["..tostring(full_url("Special:WhatLinksHere/"..title.fullText,{hidetrans=true,hideredirs=true})).." links]")ifcontentModel~="Scribunto"thenlinks:insert("["..tostring(full_url("Special:WhatLinksHere/"..title.fullText,{hidelinks=true,hidetrans=true})).." redirects]")endifis_script_or_stylesheetthenifuser_namethenlinks:insert("[[Special:MyPage"..title.text:sub(#title.rootText+1).."|your own]]")endelselinks:insert("["..tostring(full_url("Special:WhatLinksHere/"..title.fullText,{hidelinks=true,hideredirs=true})).." transclusions]")endifcontentModel=="Scribunto"thenlocalis_testcases=title.isSubpageandtitle.subpageText=="testcases"localwithout_subpage=title.nsText..":"..title.baseTextifis_testcasesthenlinks:insert("[[:"..without_subpage.."|tested module]]")elselinks:insert("[["..title.fullText.."/testcases|testcases]]")endifuser_namethenlinks:insert("[[User:"..user_name.."|user page]]")links:insert("[[User talk:"..user_name.."|user talk page]]")links:insert("[[Special:PrefixIndex/User:"..user_name.."/|userspace]]")-- If sandbox module, add a link to the module that this is a sandbox of.-- Exclude user sandbox modules like [[User:Dine2016/sandbox]].elseiftitle.text:find("/sandbox%d*%f[/%z]")thencats:insert("Sandbox modules")-- Sandbox modules don’t really need documentation.needs_doc=false-- Don't track user sandbox modules.localtext_title=new_title(title.text)ifnot(text_titleandtext_title.namespace==2)thentrack("sandbox to be moved")localsandbox_of,diff=title.baseTextiftitle_exists(sandbox_of)thendiff=" ("..compare_pages(title.fullText,sandbox_of,"diff")..")"elsetrack("no sandbox of")endlinks:insert("[[:"..sandbox_of.."|sandbox of]]"..(diffor""))end-- If not a sandbox module, add link to sandbox module.-- Sometimes there are multiple sandboxes for a single module:-- [[Module:sa-pronunc/sandbox]],  [[Module:sa-pronunc/sandbox2]].-- Occasionally sandbox modules have their own subpages that are also-- sandboxes: [[Module:grc-decl/sandbox/decl]].elselocalsandbox_titleiftitle.rootText=="grc-decl"thensandbox_title=string_insert(title.fullText,16,"/sandbox")elseifis_testcasesthensandbox_title=title.fullText:gsub("/testcases","/sandbox/testcases")elsesandbox_title=title.fullText.."/sandbox"endlocalsandbox_link="[[:"..sandbox_title.."|sandbox]]"localdiffiftitle_exists(sandbox_title)thendiff=" ("..compare_pages(title.fullText,sandbox_title,"diff")..")"endlinks:insert(sandbox_link..(diffor""))endendiftitle.nsText=="Template"then-- Error search: all(any namespace), hastemplate (show pages using the template), insource (show source code), incategory (any/specific error) -- [[mw:Help:CirrusSearch]], [[w:Help:Searching/Regex]]-- apparently same with/without: &profile=advanced&fulltext=1localerrorq='searchengineselect=mediawiki&search=all: hastemplate:\"'..title.rootText..'\" insource:\"'..title.rootText..'\" incategory:'localeincategory="Pages_with_module_errors|ParserFunction_errors|DisplayTitle_errors|Pages_with_ISBN_errors|Pages_with_ISSN_errors|Pages_with_reference_errors|Pages_with_syntax_highlighting_errors|Pages_with_TemplateStyles_errors"links:insert('['..tostring(full_url('Special:Search',errorq..eincategory))..' errors]'..' ('..'['..tostring(full_url('Special:Search',errorq..'ParserFunction_errors'))..' parser]'..'/'..'['..tostring(full_url('Special:Search',errorq..'Pages_with_module_errors'))..' module]'..')')iftitle.isSubpageandtitle.text:find("/sandbox%d*%f[/%z]")then-- This is a sandbox template.-- At the moment there are no user sandbox templates with subpage-- “/sandbox”.cats:insert("Sandbox templates")-- Sandbox templates don’t really need documentation.needs_doc=false-- Will behave badly if “/sandbox” occurs twice in title!localsandbox_of=title.fullText:gsub("/sandbox%d*%f[/%z]","")localdiffiftitle_exists(sandbox_of)thendiff=" ("..compare_pages(title.fullText,sandbox_of,"diff")..")"elsetrack("no sandbox of")endlinks:insert("[[:"..sandbox_of.."|sandbox of]]"..(diffor""))-- This is a template that can have a sandbox.elseifnotargs.nosandboxthen-- unless we tell it not tolocalsandbox_title=title.fullText.."/sandbox"localdiffiftitle_exists(sandbox_title)thendiff=" ("..compare_pages(title.fullText,sandbox_title,"diff")..")"endlinks:insert("[[:"..sandbox_title.."|sandbox]]"..(diffor""))endendif#links>0thenoutput:insert("<dd> ''Useful links'': "..links:concat(" • ").."</dd>")endendoutput:insert("</dl>\n")-- Show error from [[Module:category tree/topic cat/data]] on its submodules'-- documentation to, for instance, warn about duplicate labels.ifstartswith(title.fullText,"Module:category tree/topic/")thenlocalok,err=pcall(require,"Module:category tree/topic/data")ifnotokthenoutput:insert('<span>'..err..'</span>\n\n')endendifdoc_titleanddoc_title.existsthen-- Override automatic documentation, if present.doc_content=expand_template{title=doc_title.fullText}elseifnotdoc_contentandfallback_docsthendoc_content=expand_template{title=fallback_docs,args={['user']=user_name,['page']=title.fullText,['skin name']=skin_name,},}endifdoc_contentthenoutput:insert(doc_content)endoutput:insert(('\n<%s />'):format(args.hr=="below"and"hr"or"br"))ifcats_auto_generatedandnotcats[1]and(notdoc_contentornotdoc_content:find("%[%[Category:"))thenifcontentModel=="Scribunto"thencats:insert("Uncategorized modules")-- elseif title.nsText == "Template" then-- cats:insert("Uncategorized templates")endendifneeds_docthencats:insert("Templates and modules needing documentation")endfor_,catinipairs(cats)dooutput:insert("[[Category:"..cat.."]]")endoutput:insert("</div>\n")returnoutput:concat()endfunctionexport.module_auto_doc_table()localparts={}localfunctionins(text)insert(parts,text)endins('{|class="wikitable"')ins("! Regex !! Category !! Handling modules")for_,specinipairs(module_regex)dolocalcat_textlocalcats=spec.catifcatsthenlocalcat_parts={}iftype(cats)=="string"thencats={cats}endfor_,catinipairs(cats)doinsert(cat_parts,("<code>%s</code>"):format((cat:gsub("|","&#124;"))))endcat_text=concat(cat_parts,", ")elsecat_text="''(unspecified)''"endins("|-")ins(("| <code>%s</code> || %s || %s"):format(spec.regex,cat_text,is_callable(spec.process)and"''(handled internally)''"ortype(spec.process)=="string"and("[[Module:documentation/functions/%s]]"):format(spec.process)or"''(no documentation generator)''"))endins("|}")returnconcat(parts,"\n")end-- Used by {{translit module documentation}}.functionexport.translitModuleLangList(frame)localpagename,subpageifframe.args[1]thenpagename=frame.args[1]elselocaltitle=get_current_title()subpage=title.subpageTextpagename=title.textifsubpage~=pagenamethenpagename=title.rootTextendendlocaltranslitModule=pagenamelocallanguageObjects=require("Module:languages/byTranslitModule")(translitModule)localcodeInPagename=pagename:match("^([%l-]+)%-.*translit$")localcategories=Array()localcodeInPagenameInList=falseifcodeInPagenametheniflanguageObjects[1]andsubpage~="documentation"thenlocalagreement=languageObjects[2]and"s"or""categories:insert("[[Category:Transliteration modules used by "..#languageObjects.." language"..agreement.."]]")endlanguageObjects=Array(languageObjects):filter(function(lang)localresult=lang:getCode()~=codeInPagenamecodeInPagenameInList=codeInPagenameInListorresultreturnresultend)endifsubpage~="documentation"thenforscript_codeinpagename:gmatch("%f[^-%z]%u%l%l%l%f[-]")dolocalscript=get_script(script_code)ifscriptthencategories:insert("[[Category:"..script:getCategoryName().."]]")endendendifsubpage~="documentation"andnottitle_exists("Module:"..pagename.."/testcases")thencategories:insert("[[Category:Transliteration modules without a testcases subpage]]")endifnotlanguageObjects[1]thenreturncategories:concat()endlocallangs=Array(languageObjects):sort(function(lang1,lang2)returnlang1:getCode()<lang2:getCode()end)-- This will not error because languageObjects is not empty.:map(languageObjects[1].makeCategoryLink):serialCommaJoin()return"It is "..(codeInPagenameInListand"also"or"").." used to transliterate "..langs.."."..categories:concat()end-- Used by {{entry name module documentation}}.functionexport.entryNameModuleLangList(frame)localpagename,subpageifframe.args[1]thenpagename=frame.args[1]elselocaltitle=get_current_title()subpage=title.subpageTextpagename=title.textifsubpage~=pagenamethenpagename=title.rootTextendendlocalentryNameModule=pagenamelocallanguageObjects=require("Module:languages/byEntryNameModule")(entryNameModule)localcodeInPagename=pagename:match("^([%l-]+)%-.*entryname$")localcategories=Array()localcodeInPagenameInList=falseifcodeInPagenametheniflanguageObjects[1]andsubpage~="documentation"thenlocalagreement=languageObjects[2]and"s"or""categories:insert("[[Category:Entry name-generating modules used by "..#languageObjects.." language"..agreement.."]]")endlanguageObjects=Array(languageObjects):filter(function(lang)localresult=lang:getCode()~=codeInPagenamecodeInPagenameInList=codeInPagenameInListorresultreturnresultend)endifsubpage~="documentation"thenforscript_codeinpagename:gmatch("%f[^-%z]%u%l%l%l%f[-]")dolocalscript=get_script(script_code)ifscriptthencategories:insert("[[Category:"..script:getCategoryName().."]]")endendendifsubpage~="documentation"andnottitle_exists("Module:"..pagename.."/testcases")thencategories:insert("[[Category:Entry name-generating modules without a testcases subpage]]")endifnotlanguageObjects[1]thenreturncategories:concat()endlocallangs=Array(languageObjects):sort(function(lang1,lang2)returnlang1:getCode()<lang2:getCode()end)-- This will not error because languageObjects is not empty.:map(languageObjects[1].makeCategoryLink):serialCommaJoin()return"It is "..(codeInPagenameInListand"also"or"").." used to generate entry names for "..langs.."."..categories:concat()end-- Used by {{sortkey module documentation}}.functionexport.sortkeyModuleLangList(frame)localpagename,subpageifframe.args[1]thenpagename=frame.args[1]elselocaltitle=get_current_title()subpage=title.subpageTextpagename=title.textifsubpage~=pagenamethenpagename=title.rootTextendendlocalsortkeyModule=pagenamelocallanguageObjects=require("Module:languages/bySortkeyModule")(sortkeyModule)localcodeInPagename=pagename:match("^([%l-]+)%-.*sortkey$")localcategories=Array()localcodeInPagenameInList=falseifcodeInPagenametheniflanguageObjects[1]andsubpage~="documentation"thenlocalagreement=languageObjects[2]and"s"or""categories:insert("[[Category:Sortkey-generating modules used by "..#languageObjects.." language"..agreement.."]]")endlanguageObjects=Array(languageObjects):filter(function(lang)localresult=lang:getCode()~=codeInPagenamecodeInPagenameInList=codeInPagenameInListorresultreturnresultend)endifsubpage~="documentation"thenforscript_codeinpagename:gmatch("%f[^-%z]%u%l%l%l%f[-]")dolocalscript=get_script(script_code)ifscriptthencategories:insert("[[Category:"..script:getCategoryName().."]]")endendendifsubpage~="documentation"andnottitle_exists("Module:"..pagename.."/testcases")thencategories:insert("[[Category:Sortkey-generating modules without a testcases subpage]]")endifnotlanguageObjects[1]thenreturncategories:concat()endlocallangs=Array(languageObjects):sort(function(lang1,lang2)returnlang1:getCode()<lang2:getCode()end)-- This will not error because languageObjects is not empty.:map(languageObjects[1].makeCategoryLink):serialCommaJoin()return"It is "..(codeInPagenameInListand"also"or"").." used to sort "..langs.."."..categories:concat()endreturnexport
Retrieved from "https://en.wiktionary.org/w/index.php?title=Module:documentation&oldid=85273729"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp