Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

134 lines (112 sloc) 3.444 kb
/* NSC -- new Scala compiler
* Copyright 2007-2011 LAMP/EPFL
* @author David Bernard, Manohar Jonnalagedda
package doc
package html
import model._
import{ File => JFile }
import io.{ Streamable, Directory }
import scala.collection._
/** A class that can generate Scaladoc sites to some fixed root folder.
* @author David Bernard
* @author Gilles Dubochet */
class HtmlFactory(val universe: doc.Universe, index: doc.Index) {
/** The character encoding to be used for generated Scaladoc sites.
* This value is currently always UTF-8. */
def encoding: String = "UTF-8"
def siteRoot: JFile = new JFile(universe.settings.outdir.value)
def libResources = List(
/** Generates the Scaladoc site for a model into the site root.
* A scaladoc site is a set of HTML and related files
* that document a model extracted from a compiler run.
* @param model The model to generate in the form of a sequence of packages. */
def generate() {
def copyResource(subPath: String) {
val bytes = new Streamable.Bytes {
val p = "/scala/tools/nsc/doc/html/resource/" + subPath
val inputStream = getClass.getResourceAsStream(p)
assert(inputStream != null, p)
val dest = Directory(siteRoot) / subPath
val out = dest.toFile.bufferedOutput()
try out.write(bytes, 0, bytes.length)
finally out.close()
libResources foreach (s => copyResource("lib/" + s))
new page.Index(universe, index) writeFor this
new page.IndexScript(universe, index) writeFor this
writeTemplates(_ writeFor this)
for (letter <- index.firstLetterIndex) {
new, index, universe) writeFor this
def writeTemplates(writeForThis: HtmlPage => Unit) {
val written = mutable.HashSet.empty[DocTemplateEntity]
def writeTemplate(tpl: DocTemplateEntity) {
if (!(written contains tpl)) {
writeForThis(new page.Template(universe, tpl))
written += tpl
tpl.templates map writeTemplate
Jump to Line
Something went wrong with that request. Please try again.