This module provides a way to generate tables of contents for books.

Usage edit

This module, in order to be used, must be invoked directly, which means there is no intermediary template. In theory, an intermediary template could be created, but it would only support a limited number of arguments, while the direct invocation of the modules allows an unlimited number of arguments.

This module recognizes an unlimited number of sequences of four numbered parameters that respectively indicate the name of a section, the page of that section (the name of the page on the wiki to which the section label will link), the description of that section and the completion status of that section (a multiple of 25 smaller than 100 followed by a percentage sign). Only the first is required, and the format of the table of contents will adapt automatically depending on which parameters are given values to.

The module recognizes some named parameters that are described in the next section. Parameters, both named and numbered, are considered to have a value when they are provided an argument that does not contain only whitespace.

Parameters edit

All the parameters described here are optional.

indent
This is the length of the left margin of the section list, specified as a CSS margin length.
list style
The value of this parameter will be used as the value for the list-style CSS property of the section list. The most common use is to remove the bullets of a list by setting it to none.
page name prefix
This is a prefix added to all page names given for sections. It is most commonly used to add the name of the book to the page names with Module:Table of contents.
unordered
The list of sections will be ordered unless an argument is provided for this parameter.

Examples edit

This module will, depending on whether descriptions are provided and on whether the section list is ordered or not, adapt the layout and appearance of the table of contents.

Described sections edit

{{#invoke:table of contents|generate
| Section 1 | Section 1 | This is the first section.   | 100%
| Section 2 | Section 2 | This is the second section.  | 50%
| Section 3 | Section 3 | This is the third section.   | 75%
| Section 4 |           | This is the fourth section.  | 75%
| Section 5 | Section 5 | This is the fifth section.   | 25%
| Section 6 | Section 6 | This is the sixth section.   | 100%
| Section 7 | Section 7 | This is the seventh section. | 25%
| Section 8 | Section 8 | This is the eighth section.  | 50%
}}
Section 1  
This is the first section.
Section 2  
This is the second section.
Section 3  
This is the third section.
Section 4  
This is the fourth section.
Section 5  
This is the fifth section.
Section 6  
This is the sixth section.
Section 7  
This is the seventh section.
Section 8  
This is the eighth section.

Ordered sections with no completion status edit

{{#invoke:table of contents|generate
| Section 1 | Section 1 | |
| Section 2 | Section 2 | |
| Section 3 | Section 3 | |
| Section 4 |           | |
| Section 5 | Section 5 | |
| Section 6 | Section 6 | |
| Section 7 | Section 7 | |
| Section 8 | Section 8 | |
}}
  1. Section 1
  2. Section 2
  3. Section 3
  4. Section 4
  5. Section 5
  6. Section 6
  7. Section 7
  8. Section 8

Unordered sections edit

{{#invoke:table of contents|generate
| Section 1 | Section 1 | | 100%
| Section 2 | Section 2 | | 50%
| Section 3 | Section 3 | | 75%
| Section 4 |           | | 75%
| Section 5 | Section 5 | | 25%
| Section 6 | Section 6 | | 100%
| Section 7 | Section 7 | | 25%
| Section 8 | Section 8 | | 50%
| unordered = true
}}
Unordered sections with no indentation, marker or completion status edit
{{#invoke:table of contents|generate
| Section 1 | Section 1 | |
| Section 2 | Section 2 | |
| Section 3 | Section 3 | |
| Section 4 |           | |
| Section 5 | Section 5 | |
| Section 6 | Section 6 | |
| Section 7 | Section 7 | |
| Section 8 | Section 8 | |
| unordered = true
| indent = 0
| list style = none
}}