Module:CR/doc

Welcome to the CR, or Comprehensive Rules, Lua module for MTG Wiki. This module exists to minimize the labor of copying of Comprehensive Rules text to the wiki.

Please use the module indirectly via CR. Using the module directly is more likely to break in the future.

Bug reports and feature requests
Please use the module's talk page to discuss small non-critical bugs in output or to request changes to the text generated or its style.

Maintenance
Most maintenance should be simple. Two changes need to be made when a new version of the Comp Rules is available: updating the name of the newest set, and copy and pasting the newest rules.

Updating the most recent set name
Update CURRENTSET with the plain (unlinked) name of the set.

Updating the full Comprehensive Rules text
At the top of the rules subpage, you should see: return { -- BEGIN COMP RULES text = And following that line, the entire plaintext Comprehensive Rules is included, spanning several thousand lines, followed by: -- END COMP RULES }

The most recent official version of the Comprehensive Rules can currently be found on the Wizards of the Coast website.

No further editing of this module or of the rules themselves should be necessary. The module ignores blank lines and can find its way by the indices in the CR.

Nonstandard
If a plaintext version of the Comp Rules update is unavailable, but could be created from another version of the Comp Rules, this module:
 * ignores blank lines
 * expects the table of contents at the beginning of the Comp Rules to be present
 * expects each rules index in the table of contents and the body of the rules to be separated by newlines
 * expects each line in the table of contents and the body of the rules to begin with the rules index for that line
 * expects the table of contents to be immediately followed, and separated from body of the rules, by the string TOC_END_LINE
 * expects the body of the rules to be immediately followed by BODY_END_LINE

In the unlikely event that Wizards of the Coast should overhaul the formatting of the Comp Rules, this module will require a major rewrite.

If such a rewrite is necessary, or something else has gone horribly wrong, try contacting any of the following previous maintainers:
 * corveroth@gmail.com

Direct Usage
In the event that a template does not serve your purposes, if you must invoke this module directly, the following functions are provided:
 * CR.TOC returns a listing from the table of contents section of the Comprehensive Rules.
 * When called with an integer value, it returns the list for a section.
 * For example,   will return the table of contents for Game Concepts.
 * When called with no value, it returns the full table of contents.


 * CR.full returns the text at the given index in the Comprehensive Rules including all nested subsections.
 * For example,   will return the entire section on Abilities.


 * CR.title returns the text matching the specified title line in the Comprehensive Rules. Aside from using a title rather than an index, it operates identically to CR.full.
 *   will return the entire section on Abilities, just like    (as of this writing).


 * CR.only returns only the text at the specified index, not including subsections.
 * For example,   will return the definition of a Spell, without the 111.1a and 111.1b subsections detailing copies.
 * CR.only also accepts a second parameter specifying a number of additional levels; a compromise between CR.only and CR.full.
 * For example,   will the list of keyword abilities, without their descriptions.

Generally, CR.title or CR.full will yield the desired results, because the Comprehensive Rules are shallowly nested. CR.title is recommended because titles are less likely to change than indices. That is, while the section detailing Trample will likely retain a title index containing simply "Trample", it may no longer reside at index 702.19 as further keywords are added to rule 702.
 * CR.glossary returns the text matching the specified title line in the Glossary of the Comprehensive Rules.

CR.only is provided for the sake of completeness, and may be useful for cases such as contrasting related rules at distant indices.

CR.TOC is expected to see use on pages covering broad rules topics. CR.only|index|levels is an alternative for narrower, but still broad topics, such as Keyword abilities.