logo

class

docCompiler::TopIndexGenerator

sys::Obj
  fandoc::HtmlDocWriter
    docCompiler::HtmlGenerator
      docCompiler::TopIndexGenerator
  1  //
  2  // Copyright (c) 2007, Brian Frank and Andy Frank
  3  // Licensed under the Academic Free License version 3.0
  4  //
  5  // History:
  6  //   5 May 07  Brian Frank  Creation
  7  //
  8  
  9  using compiler
 10  using fandoc
 11  
 12  **
 13  ** TopIndexGenerator generates the top level index file.
 14  **
 15  class TopIndexGenerator : HtmlGenerator
 16  {
 17  
 18  //////////////////////////////////////////////////////////////////////////
 19  // Constructor
 20  //////////////////////////////////////////////////////////////////////////
 21  
 22    new make(DocCompiler compiler, Location loc, OutStream out)
 23      : super(compiler, loc, out)
 24    {
 25    }
 26  
 27  //////////////////////////////////////////////////////////////////////////
 28  // Generator
 29  //////////////////////////////////////////////////////////////////////////
 30  
 31    override Str title()
 32    {
 33      return docHome
 34    }
 35  
 36    override Str pathToRoot()
 37    {
 38      return ""
 39    }
 40  
 41    override Void header()
 42    {
 43      out.print("<ul>\n")
 44      out.print("  <li>$docHome</li>\n")
 45      out.print("</ul>\n")
 46    }
 47  
 48    override Void content()
 49    {
 50      listPods("Manuals", false)
 51      listPods("APIs", true)
 52    }
 53  
 54    Void listPods(Str title, Bool api)
 55    {
 56      out.print("<h1>$title</h1>\n")
 57      out.print("<table>\n")
 58  
 59      pods := Pod.list.rw
 60      pods.swap(0, pods.index(Pod.find("docIntro")))
 61      pods.swap(1, pods.index(Pod.find("docLang")))
 62  
 63      pods = pods.findAll |Pod p -> Bool| { return p.name != "sysTest" && api == isAPI(p) }
 64      pods.each |Pod p, Int i|
 65      {
 66        cls := i % 2 == 0 ? "even" : "odd"
 67        doc := p.facets["description"]
 68        out.print("<tr class='$cls'>\n")
 69        out.print("  <td class='first'><a href='$p.name/index.html'>$p.name</a></td>\n")
 70        out.print("  <td>$doc</td>\n")
 71        out.print("</tr>\n")
 72      }
 73      out.print("</table>\n")
 74    }
 75  
 76    Bool isAPI(Pod pod)
 77    {
 78      if (!pod.name.startsWith("doc")) return true
 79      if (pod.name == "docCompiler") return true
 80      return false
 81    }
 82  
 83  }