Index: /trac/trunk/wiki-macros/TracNav.py
===================================================================
--- /trac/trunk/wiki-macros/TracNav.py	(revision 3059)
+++ /trac/trunk/wiki-macros/TracNav.py	(revision 3060)
@@ -108,5 +108,4 @@
         OneLinerFormatter.__init__(self, env)
         self.link = None
-        self.myenv = env
 
     def _make_link(self, namespace, target, match, label):
@@ -127,10 +126,9 @@
 def get_toc_entry(toc_text, env):
     """
-    Filter the toc_text for toc entries.
+    Parse and format the entries in toc_text.
     """
     for match in LISTRULE.finditer(toc_text):
         indent = len(match.group('indent'))
         label, link = format_toc_entry(match.group('rest'), env)
-        # env.log.debug("link is '%s'" % link)
         yield indent, link, label
 
@@ -138,8 +136,7 @@
 def get_toc_entry_and_indent(gen):
     """
-    Filter for get_toc_entry().  Returns link and label of the current
-    toc entry and the indentation level of the next entry or -1 if
-    there are no more entries. The first call to next() returns the
-    indentation of the first entry.
+    Filter for get_toc_entry().  The first call to next() returns the
+    indentation level of the next entry (or -1 if there are no more
+    entries) and the second call returns the entry itself.
     """
     while True:
@@ -161,5 +158,5 @@
         else:                   # broken indentation structure
             toclist.append((None, None, sublist))
-    while 1:
+    while True:
         if next_indent == level:
             (link, label), next_indent = gen.next(), gen.next()
@@ -175,4 +172,7 @@
 
 def parse_toc(toc_text, env):
+    """
+    Recursively construct the toc tree using _parse_toc().
+    """
     gen = get_toc_entry_and_indent(get_toc_entry(toc_text, env))
     toclist, _ = _parse_toc(gen, gen.next())
@@ -181,4 +181,7 @@
 
 def execute(hdf, args, env):
+    """
+    Main routine of the wiki macro.
+    """
     preview = hdf.getValue('args.preview', "")
     curpage = hdf.getValue('wiki.page_name', "")
