# HG changeset patch
# User Paul Boddie <paul@boddie.org.uk>
# Date 1296864641 -3600
# Node ID 6cd0ccfc8dcd328a55fe128de27f4fa51a864394
# Parent  cb354dd67783be0dbc71ff48b4f13c0fa3742374
Added an optional minimum heading depth argument to the TableOfContents macro.

diff -r cb354dd67783 -r 6cd0ccfc8dcd MoinMoin/macro/TableOfContents.py
--- a/MoinMoin/macro/TableOfContents.py	Sun Oct 03 00:53:07 2010 +0200
+++ b/MoinMoin/macro/TableOfContents.py	Sat Feb 05 01:10:41 2011 +0100
@@ -131,19 +131,31 @@
     comment = _anything_return_empty
     transclusion = _anything_return_empty
 
-def macro_TableOfContents(macro, maxdepth=int):
+def macro_TableOfContents(macro, min_or_maxdepth=int, maxdepth=int):
     """
 Prints a table of contents.
 
+ mindepth:: minimum depth the table of contents is generated for (defaults to 1)
  maxdepth:: maximum depth the table of contents is generated for (defaults to unlimited)
     """
-    try:
-        mindepth = int(macro.request.getPragma('section-numbers', 1))
-    except (ValueError, TypeError):
-        mindepth = 1
 
-    if maxdepth is None:
-        maxdepth = 99
+    # if both parameters are specified, they provide the limits of heading
+    # inclusion in the table.
+    if maxdepth is not None:
+        mindepth = min_or_maxdepth
+
+    # if the explicit maxdepth parameter is None, min_or_maxdepth determines
+    # maximum depth.
+    else:
+        try:
+            mindepth = int(macro.request.getPragma('section-numbers', 1))
+        except (ValueError, TypeError):
+            mindepth = 1
+
+        if min_or_maxdepth is None:
+            maxdepth = 99
+        else:
+            maxdepth = min_or_maxdepth
 
     pname = macro.formatter.page.page_name
 
