Table of Contents

  1. The Trac User and Administration Guide
    1. Table of Contents
    2. Support and Other Sources of Information
  1. Trac Installation Guide
    1. Requirements
      1. For SQLite
      2. For PostgreSQL
      3. Optional Requirements
    2. Installing Trac
      1. Advanced Users
    3. Creating a Project Environment
    4. Running the Standalone Server
    5. Running Trac on a Web Server
    6. Configuring Authentication
    7. Using Trac
  1. Upgrade Instructions
    1. General Instructions
      1. Update the Trac Code
      2. Upgrade the Trac Environment
      3. Update the Trac Documentation
      4. Restart the Web Server
    2. Specific Versions
    3. From 0.9-beta to 0.9
    4. From 0.8.x to 0.9
    5. From 0.7.x to 0.8
  1. The Trac Configuration File
    1. Global Configuration
    2. Reference
    3. [components]
  1. TracAdmin
    1. Usage
    2. Interactive Mode
  1. Trac Backup
    1. Creating a Backup
      1. Restoring a Backup
  1. Trac Logging
    1. Supported Logging Methods
    2. Log Levels
  1. Trac Permissions
    1. Available Privileges
      1. Repository Browser
      2. Ticket System
      3. Roadmap
      4. Reports
      5. Wiki System
      6. Others
    2. Granting Privileges
    3. Permission Groups
    4. Default Permissions
  1. The Trac Wiki Engine
  1. WikiFormatting
    1. Font Styles
    2. Headings
  2. Heading
    1. Subheading
      1. About this
    2. Paragraphs
    3. Lists
    4. Definition Lists
    5. Preformatted Text
    6. Blockquotes
    7. Tables
    8. Links
      1. Trac Links
    9. Escaping Links and WikiPageNames
    10. Images
    11. Macros
    12. Processors
    13. Miscellaneous
  1. The Trac Browser
    1. RSS Support
  1. The Trac Roadmap
    1. The Roadmap View
    2. The Milestone View
    3. Roadmap Administration
    4. iCalendar Support
  1. Trac Changeset Module
    1. Changeset Header
    2. Diff Views
    3. The Different Ways to Get a Diff
      1. Examining a Changeset
      2. Examining Differences Between Revisions
      3. Examining Arbitrary Differences
      4. Checking the Last Change
  1. The Trac Ticket System
    1. Ticket Fields
    2. Changing and Commenting Tickets
      1. State Diagram
    3. Default Values for Drop-Down Fields
    4. Hiding Fields and Adding Custom Fields
    5. Assign-to as Drop-Down List
    6. Preset Values for New Tickets
  1. Trac Reports
    1. Changing Sort Order
    2. Alternate Download Formats
      1. Comma-delimited - CSV (Comma Separated Values)
      2. Tab-delimited
      3. RSS - XML Content Syndication
    3. Creating Custom Reports
    4. Ticket columns
    5. Advanced Reports: Dynamic Variables
      1. Using Variables in a Query
      2. Special/Constant Variables
    6. Advanced Reports: Custom Formatting
    7. Special Columns
      1. Automatically formatted columns
      2. Custom formatting columns
      3. Changing layout of report rows
      4. Reporting on custom fields
  1. Trac Ticket Queries
    1. Filters
    2. Navigating Tickets
    3. Saving Queries
      1. Using TracLinks
      2. Using the [[TicketQuery]] Macro
      3. Query Language
  1. The Trac Timeline
    1. RSS Support
  1. Using RSS with Trac
    1. How to access RSS data
    2. Links
  1. Email Notification of Ticket Changes
    1. Receiving Notification
    2. Configuring SMTP Notification
      1. Configuration Options
      2. Example Configuration
    3. Sample Email

Table of Contents Macro

Description

The TocMacro generates a table of contents for the current page or a set of pages.

If no arguments are given, a table of contents is generated for the current page, with the top-level title stripped:

[[TOC]]

To generate a table of contents for a set of pages, simply pass them as comma separated arguments to the TOC macro. This is the macro call for the table of contents visible on the right side of this page:

[[TOC(TracGuide, TracInstall, TracUpgrade, TracIni, TracAdmin, TracBackup, TracLogging,
TracPermissions, TracWiki, WikiFormatting, TracBrowser, TracRoadmap, TracChangeset,
TracTickets, TracReports, TracQuery, TracTimeline, TracRss, TracNotification)]]

A wildcard '*' can be used to fetch a sorted list of all pages starting with the preceding pagename stub (Since [2801]):

[[TOC(Trac*, WikiFormatting, WikiMacros)]]

For 'titleindex' argument, an empty pagelist will evaluate to all pages (Since [2801]):

[[TOC(titleindex, notitle, heading=All pages)]]

'sectionindex' allows to generate a title index for all pages in a given section of the wiki. A section is defined by wiki page name, using '/' as a section level delimiter (like directories in a file system). Giving '/' or '*' as the page name produces the same result as 'titleindex' (title of all pages). If a page name ends with a '/', only children of this page will be processed. Else the page given in the argument is also included, if it exists. For 'sectionindex' argument, an empty pagelist will evaluate to all page below the same parent as the current page:

[[TOC(sectionindex, notitle, heading=This section pages)]]

The following control arguments change the default behaviour of the TOC macro (Since [22]):

Argument Meaning
heading=<x> Override the default heading of "Table of Contents" or "Page Index" for titleindex.
noheading Suppress display of the heading.
depth=<n> Display headings of subsequent pages to a maximum depth of <n>.
inline Display TOC inline rather than as a side-bar.
sectionindex Only display the page name and title of each page for all pages in a given section. (Since [3417]).
titleindex Only display the page name and title of each page, similar to TitleIndex. (Since [37]).
notitle Supress display of page title (Since [2801]).

Bugs/Feature Requests

Existing bugs and feature requests are here. If you have any issues, create a new ticket.

Installation

Both 0.10 and 0.11 entries at Python Package Index (pypi) are not up-to-date with latest versions and dependencies. To install the most recent versions, use direct installation from source:

easy_install http://trac-hacks.org/svn/tocmacro/0.10   # 0.10
easy_install http://trac-hacks.org/svn/tocmacro/0.11   # 0.11

...or download / check out the source from repository (see below) and install it in usual manner.

Do not forget to enable the macro in trac.ini (at least with 0.11 and 0.10.4) in the components section like this:

tractoc.* = enabled

Download

download:tocmacro

TocMacro requires that AnchorPatch be applied to 0.8 Trac. Trac 0.9 already includes this patch.

Source

You can check out the source for TocMacro from Subversion at http://trac-hacks.org/svn/tocmacro.

Example

[[TOC(inline, heading=Trac Table of Contents, TracGuide, TracInstall, depth=2,
 TracLogging, depth=99, TracPermissions)]]

On the right you can see the TOC macro version of the default TracGuideToc macro.

Change Log

[4366] by osimons on 10/02/08 00:47:15

TocMacro: Fixed a serious bug whereby the 0.11 version of the macro would keep a database connection open after execution.

This innocent-looking line...

self.formatter = formatter

... essentially attaches the transient formatter and its formatter.db connection to the instantiated plugin/component that lives for the lifetime of the environment (that in most setups gets cached for the duration of the process or until event like config change forces reload). Next time the macro executes it will free the old connection, and replace it with the new.

The problem continually ties up 1 connection of a process-wide default maximum number of 10. Many projects using the macro can get to the point where it locks the process due to no database connections being available - failing with TimeoutError. Particularly dangerous with embedded interpreter on Apache for Windows as it serves all requests using just a single process.

Code is changed to not persist the formatter, but instead pass it around as needed.

To all users of 0.11 version: Please upgrade!

[3418] by jouvin on 03/25/08 16:42:36

Add inline documentation for sectionindex

[3417] by jouvin on 03/25/08 15:35:22

Add support for keyword sectionindex in 11.0.0 (see http://trac-hacks.org/ticket/2790 and documentation); version incremented to 11.0.0.3

[3416] by coderanger on 03/25/08 07:39:08

Change my email to avoid Yahoo, which decided to brake my scraper script recently.

Author/Contributors

Authors: athomas, jouvin, coderanger, cboos, osimons