Вікіпедія:Документація шаблонів

Матеріал з Вікіпедії — вільної енциклопедії.

Скорочення:
ВП:ДОК

The template doc page pattern is a method to securely split template documentation off from template code in a separate page. It enables full protection of template code while retaining the documentation part unprotected, so that everyone can still edit the documentation.

Зміст

[ред.] Що це вирішить?

Wikipedians generally like to have a usage description of the template right at the template page (example: template:cite news). This can be achieved by writing some descriptive text into the template wiki-source inside <noinclude>...</noinclude>. However, this has some drawbacks:

  • The text inside <noinclude>...</noinclude> does add to the pre-expand include size, which is limited (see Wikipedia:Template limits).
  • Some templates are fully protected, because they are transcluded into a lot of pages. Editing the documentation is awkward in this case, because non-sysops must make a request to edit a protected page and a sysop has to do the edit.
  • There is an upper limit to both the pre-included and post-expanded sizes of a page. Worse, the more a template is included, its pre-expanded size gets multiplied by however many bytes its size needs. So there are conflicting needs. (see Wikipedia:Template limits).

This How to page sets forth a strategy 'and technique' that satisfies both the human needs to refresh their memory, (or most commonly, learn from the first exposure! The 'needs' for documentation, especially for the newer editors still on the many steep wiki learning curves.) and has the added benefit of building pages faster and unloading the servers processing loads. (We all do love to wait for that page to load, soooo much!)

In summation, the dual solution is to place the documentation and usage notes in a documentation template instead of the tool or utility template (which if worded carefully, can usually cover several related tools or utility type templates) that is walled behind a <noinclude>...</noinclude> block that is very short... so easy on the processor and, thus, we get to have our documentation cake and eat it too — faster!

The solution also has two apppreciable spin-off benefits:

  1. It minimizes server loading again for widely used templates which occurs when they are updated in the least way, such as when someone adds a foreign language interwiki link.
  2. Key protected templates that are fully matured can be edited for documentation adds, clarity, categories, etc. without bothering the main utility.

[ред.] Як це використовувати

Для шаблону з назвою Шаблон:Х треба створити сторінку нижчого рівня Шаблон:Х/документація і зкопіювати наступні вікі коди на початок тієї сторінки:

<noinclude>{{документація шаблона (безпосередня)}}</noinclude>
<!-- РЕДАГУЙТЕ ДОКУМЕНТАЦІЮ ШАБЛОНУ НИЖЧЕ ЦІЄЇ ЛІНІЇ -->

<includeonly>

<!-- ДОДАВАЙТЕ КАТЕГОРІЇ НИЖЧЕ ЦІЄЇ ЛІНІЇ -->

<!-- ДОДАВАЙТЕ НАПРАВЛЕННЯ ІНТЕРВІКІ НИЖЧЕ ЦІЄЇ ЛІНІЇ -->

</includeonly>

Вставити документацію, категорії і інтервікі так як показано в коментарі вгорі.

В сторінці для шаблону Х відредагувати код шаблону наступним чином:

[--код шаблона--]<noinclude>
{{документація шаблона}}
<!-- Додавайте категорії та направлення інтервікі на сторінку нижчого рівня /документація, а не тут! -->
</noinclude>

Увага: Вважайте щоб на початку <noinclude> починалося на одній строчці з останньою літерою коду шаблону (або тексту), не на новій строчці. В інакшому випадку з’явиться нова строчка на сторінці включаючи в себе Х, а це не бажано.

Шаблон тепер може бути повністю захищений, сторінка його документації 'X/документація' може залишатися незахищеною щоб іншим можна було редагувати документацію. cascade-protecting також захищає сторінку документації.

[ред.] Користь

  • Edits to the X/doc page only propagate to the template display page itself, not to transclusions of X. Pages transcluding X are therefore not dependent on the doc page, so edits to the doc page don't inflate the job queue for heavy use templates.
  • Edits to the documentation can't do any harm to the template itself and to transcluding pages. Vandalism to the doc page doesn't propagate into pages transcluding X.
  • Everyone can edit the template documentation, even if the template itself is fully protected. Categories and interwikis can be easily added to the X/doc subpage.

[ред.] Examples

[ред.] See also

Іншими мовами