summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
diff options
context:
space:
mode:
authorKato Kazuyoshi <kato.kazuyoshi@gmail.com>2011-06-20 14:20:45 +0000
committerKato Kazuyoshi <kato.kazuyoshi@gmail.com>2011-06-20 14:20:45 +0000
commit2627ab313f0d9f33e1b97e8aeda4447cf34bd27d (patch)
treeb119264c47c6c990395ba3610209905aaf270b51 /src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
parentd2fd3d61d1cceb79c731a4be46977384c7cb7c9b (diff)
downloadscala-2627ab313f0d9f33e1b97e8aeda4447cf34bd27d.tar.gz
scala-2627ab313f0d9f33e1b97e8aeda4447cf34bd27d.tar.bz2
scala-2627ab313f0d9f33e1b97e8aeda4447cf34bd27d.zip
Separete index.js to parallelize downloads.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala')
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala71
1 files changed, 2 insertions, 69 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
index d99403e5ba..cfa846b097 100644
--- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
@@ -15,18 +15,11 @@ import xml.dtd.{DocType, PublicID}
import scala.collection._
import scala.reflect.NameTransformer
import java.nio.channels.Channels
-import java.io.{FileOutputStream, File}
/** An html page that is part of a Scaladoc site.
* @author David Bernard
* @author Gilles Dubochet */
-abstract class HtmlPage { thisPage =>
-
- /** The path of this page, relative to the API site. `path.tail` is a list of folder names leading to this page (from
- * closest package to one-above-root package), `path.head` is the file name of this page. Note that `path` has a
- * length of at least one. */
- def path: List[String]
-
+abstract class HtmlPage extends Page { thisPage =>
/** The title of this page. */
protected def title: String
@@ -36,9 +29,6 @@ abstract class HtmlPage { thisPage =>
/** The body of this page. */
def body: NodeSeq
- /** Writes this page as a file. The file's location is relative to the generator's site root, and the encoding is
- * also defined by the generator.
- * @param generator The generator that is writing this page. */
def writeFor(site: HtmlFactory): Unit = {
val doctype =
DocType("html", PublicID("-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"), Nil)
@@ -51,10 +41,7 @@ abstract class HtmlPage { thisPage =>
</head>
{ body }
</html>
- val pageFile = new File(site.siteRoot, absoluteLinkTo(thisPage.path))
- val pageFolder = pageFile.getParentFile
- if (!pageFolder.exists) pageFolder.mkdirs()
- val fos = new FileOutputStream(pageFile.getPath)
+ val fos = createFileOutputStream(site)
val w = Channels.newWriter(fos.getChannel, site.encoding)
try {
w.write("<?xml version='1.0' encoding='" + site.encoding + "'?>\n")
@@ -68,52 +55,6 @@ abstract class HtmlPage { thisPage =>
//XML.save(pageFile.getPath, html, site.encoding, xmlDecl = false, doctype = doctype)
}
- def templateToPath(tpl: TemplateEntity): List[String] = {
- def doName(tpl: TemplateEntity): String =
- NameTransformer.encode(tpl.name) + (if (tpl.isObject) "$" else "")
- def downPacks(pack: Package): List[String] =
- if (pack.isRootPackage) Nil else (doName(pack) :: downPacks(pack.inTemplate))
- def downInner(nme: String, tpl: TemplateEntity): (String, Package) = {
- tpl.inTemplate match {
- case inPkg: Package => (nme + ".html", inPkg)
- case inTpl => downInner(doName(inTpl) + "$" + nme, inTpl)
- }
- }
- val (file, pack) =
- tpl match {
- case p: Package => ("package.html", p)
- case _ => downInner(doName(tpl), tpl)
- }
- file :: downPacks(pack)
- }
-
- /** A relative link from this page to some destination class entity.
- * @param destEntity The class or object entity that the link will point to. */
- def relativeLinkTo(destClass: TemplateEntity): String =
- relativeLinkTo(templateToPath(destClass))
-
- /** A relative link from this page to some destination page in the Scaladoc site.
- * @param destPage The page that the link will point to. */
- def relativeLinkTo(destPage: HtmlPage): String = {
- relativeLinkTo(destPage.path)
- }
-
- /** A relative link from this page to some destination path.
- * @param destPath The path that the link will point to. */
- def relativeLinkTo(destPath: List[String]): String = {
- def relativize(from: List[String], to: List[String]): List[String] = (from, to) match {
- case (f :: fs, t :: ts) if (f == t) => // both paths are identical to that point
- relativize(fs, ts)
- case (fss, tss) =>
- List.fill(fss.length - 1)("..") ::: tss
- }
- relativize(thisPage.path.reverse, destPath.reverse).mkString("/")
- }
-
- def absoluteLinkTo(destPath: List[String]): String = {
- destPath.reverse.mkString("/")
- }
-
/** Transforms an optional comment into an styled HTML tree representing its body if it is defined, or into an empty
* node sequence if it is not. */
def commentToHtml(comment: Option[Comment]): NodeSeq =
@@ -229,14 +170,6 @@ abstract class HtmlPage { thisPage =>
case tpl :: tpls => templateToHtml(tpl) ++ sep ++ templatesToHtml(tpls, sep)
}
- def docEntityKindToString(ety: DocTemplateEntity) =
- if (ety.isTrait) "trait"
- else if (ety.isCaseClass) "case class"
- else if (ety.isClass) "class"
- else if (ety.isObject) "object"
- else if (ety.isPackage) "package"
- else "class" // FIXME: an entity *should* fall into one of the above categories, but AnyRef is somehow not
-
/** Returns the _big image name corresponding to the DocTemplate Entity (upper left icon) */
def docEntityKindToBigImage(ety: DocTemplateEntity) =
if (ety.isTrait && !ety.companion.isEmpty && ety.companion.get.visibility.isPublic && ety.companion.get.inSource != None) "trait_to_object_big.png"