<ul>
  <<for name, mod in modules>>
    <li><a href="#<<t name>>"><<t name>></a>
      <ul>
        <<do var empty = true>>
        <<if mod.options>>
          <<do empty = false>>
          <li><a href="#<<t name>>_options">options</a></li>
        <</if>>
        <<for cname, cls in mod.classes>>
          <<if cls.$toc != "false" && !cls.noAnchor>>
            <<do empty = false>>
            <li><a href="#<<t cname>>"><<t cls.$toc || cname>></a></li>
          <</if>>
        <</for>>
        <<if mod.commands && !empty>>
          <li><a href="#<<t name>>_commands">commands</a></li>
        <</if>>
        <<if mod.functions && !empty>>
          <li><a href="#<<t name>>_functions">functions</a></li>
        <</if>>
        <<if mod.vars && !empty>>
          <li><a href="#<<t name>>_consts">constants</a></li>
        <</if>>
      </ul>
    </li>
  <</for>>
</ul>

<<do
  function count(obj) { if (obj) for (var prop in obj) if (!obj[prop].$noAnchor) return 1; return 0 }
>>

<ul>
  <<for name, mod in modules>>
    <li><a href="#<<t name>>"><<t name>></a>
      <<if (count(mod.options) + count(mod.classes) + count(mod.commands) + count(mod.functions) + count(mod.vars)) > 2>>
        <ul>
          <<if mod.options>>
            <li><a href="#<<t name>>_options">options</a></li>
          <</if>>
          <<do var foundClass = false>>
          <<for cname, cls in mod.classes>>
            <<if !foundClass && !cls.$noAnchor>>
              <li><a href="#<<t cname>>">classes</a></li>
              <<do foundClass = true>>
            <</if>>
          <</for>>
          <<if mod.commands>>
            <li><a href="#<<t name>>_commands">commands</a></li>
          <</if>>
          <<if mod.functions>>
            <li><a href="#<<t name>>_functions">functions</a></li>
          <</if>>
          <<if mod.vars>>
            <li><a href="#<<t name>>_consts">constants</a></li>
          <</if>>
        </ul>
      <</if>>
    </li>
  <</for>>
</ul>

Simplify table of contents generation in manual.html
Simplify table of contents generation in manual.html
