Wiktionary:Coding conventions: difference between revisions
Content deleted Content added
SemperBlotto (talk | contribs) m Reverted edits by 2600:1004:B058:F01C:0:4A:9683:F801. If you think this rollback is in error, please leave a message on my talk page. Tag: Rollback |
→Customary abbreviations: delete form-of inflection tag abbreviations; out of date; properly maintained version found on Template:inflection of documentation |
||
(38 intermediate revisions by 30 users not shown) | |||
Line 4:
* Language, family and script codes are based on [[w:BCP 47|BCP 47]].
** Non-standard language and family codes should consist of a (preferably standard) parent family code and a Wiktionary-specific suffix.
** Codes for
** Non-standard script codes should consist of a language code prefix, and a standard {{w|ISO 15924}} script code. (Exceptions: <code>
== Templates ==
* Names of templates related to a particular language should be prefixed by the language code, see [[WT:List of languages]]. Likewise for templates specific to a script; see [[WT:List of scripts]] for a list of script codes.
** For proto-languages, it is permitted to drop <code>-pro</code> from the code, and use the code of the family alone.
* Names of reference templates should have the prefix
* Likewise, usage note templates should have the prefix
* Relatively complex templates, especially those with parser functions (like {{temp|#if:}} or {{temp|#switch:}}), should have the code split up onto multiple lines for readability. Wikicode constructs should be aligned so that the starting curly braces and ending curly braces line up vertically. The line breaks themselves should be wrapped in comments; each line should end with a begin-comment tag <code><nowiki><!--</nowiki></code> paired with an end-comment tag <code><nowiki>--></nowiki></code> on the next line. This avoids line breaks accidentally appearing in the output or parameters of templates. Like so:
<pre><!--
-->{{#if:{{{something|}}}<!-- -->|<!--
-->do things<!--
-->}}<!--
-->
</pre>
* Templates which add categories that are only intended for entries should have extra code that only adds the category in the entry namespaces (main namespace and Appendix:). The templates {{temp|
* If a template adds a category, but it would be desirable to suppress that category in some cases, it should have a {{para|nocat}} parameter which prevents that.
* If you want to accept a variable number of named parameters of the same type in a template, the first shall be named {{para|<var>foo</var>}}, while the rest shall be {{para|<var>foo</var>2}}, {{para|<var>foo</var>3}}, {{para|<var>foo</var>4}} and so on.
Line 24 ⟶ 26:
* Headword-line templates should either be implemented in a separate module using [[Module:headword]], or use {{temp|head}}.
* Redirects for templates intended for entries should be created sparingly.
* Avoid doing string processing in templates. If you find yourself in need of a
== Lua ==
Line 33 ⟶ 35:
* Variables holding return values from {{code|lua|require()}} (i.e. imported modules) should have their names prefixed with <code>m_</code>.
* Words in variable and function names should be separated with underscores. Variables should be all-lowercase unless other reasons dictate otherwise.
* Unit tests for a module, if any, shall be put on a <code>/testcases</code> subpage.
** Unit test modules should use [[Module:UnitTests]]. See that
** If a specific kind of test is to be performed repeatedly, it shall have its own method whose name starts with <code>check_</code>.
** An alternative test framework, [[Module:ScribuntoUnit]], has been imported from Wikipedia and can also be used.
Line 55:
== Customary abbreviations ==
* <code>a</code>
* <code>adj</code>
* <code>adv</code>
* <code>alt</code>
* <code>c</code>
* <code>conj</code>
* <code>d</code> ''or'' <code>du</code>
* <code>decl</code>
* <code>f</code>
* <code>g</code>
* <code>gloss</code> ''or'' <code>t</code>
* <code>id</code>
* <code>impf</code>
* <code>infl</code>
* <code>lang</code>
* <code>m</code>
* <code>n</code>
* <code>p</code> ''or'' <code>pl</code>
* <code>pf</code>
* <code>pos</code>
* <code>pron</code>
* <code>pronunc</code>
* <code>rf...</code>
* <code>s</code> ''or'' <code>sg</code>
* <code>sc</code>
* <code>tr</code>, <code>translit</code>
== And above all ==
Line 135 ⟶ 86:
== External links ==
* [http://blog.codinghorror.com/spartan-programming/ Jeff Atwood,
* [http://javascript.crockford.com/code.html Douglas
[[Category:Modules| ]]
|