summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/doc/DocFactory.scala
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2011-01-21 17:31:29 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2011-01-21 17:31:29 +0000
commit3ca75587df0db94bc4f1a220af93eea35b2828d8 (patch)
tree09f327118494907474772a030d3db00a802d4cde /src/compiler/scala/tools/nsc/doc/DocFactory.scala
parentb89c6e7bb26749e2c8f56d9d98e9ed279ea8927f (diff)
downloadscala-3ca75587df0db94bc4f1a220af93eea35b2828d8.tar.gz
scala-3ca75587df0db94bc4f1a220af93eea35b2828d8.tar.bz2
scala-3ca75587df0db94bc4f1a220af93eea35b2828d8.zip
[scaladoc] First attempt at modularisation of S...
[scaladoc] First attempt at modularisation of Scaladoc generator. Option "docgenerator" controls which generation backend is called. No review for now; needs a discussion.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/DocFactory.scala')
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocFactory.scala37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
index 62e84861f2..13a2fe0508 100644
--- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
@@ -1,10 +1,11 @@
/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */
-
package scala.tools.nsc
package doc
import reporters.Reporter
+import util.NoPosition
+import java.lang.ClassNotFoundException
/** A documentation processor controls the process of generating Scala documentation, which is as follows.
*
@@ -46,7 +47,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
/** Creates a scaladoc site for all symbols defined in this call's `files`, as well as those defined in `files` of
* previous calls to the same processor.
* @param files The list of paths (relative to the compiler's source path, or absolute) of files to document. */
- def universe(files: List[String]): Option[Universe] = {
+ def makeUniverse(files: List[String]): Option[Universe] = {
(new compiler.Run()) compile files
compiler.addSourceless
assert(settings.docformat.value == "html")
@@ -61,9 +62,35 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
/** Generate document(s) for all `files` containing scaladoc documenataion.
* @param files The list of paths (relative to the compiler's source path, or absolute) of files to document. */
- def document(files: List[String]): Unit =
- universe(files) foreach { docModel =>
- new html.HtmlFactory(docModel, new model.IndexModelFactory makeModel(docModel)) generate
+ def document(files: List[String]): Unit = {
+
+ class NoCompilerRunException extends Exception
+
+ try {
+ val docletClass = Class.forName(settings.docgenerator.value) // default is html.Doclet
+ val docletInstance = docletClass.newInstance().asInstanceOf[doclet.Generator]
+ if (docletInstance.isInstanceOf[doclet.Universer]) {
+ makeUniverse(files) match {
+ case Some(universe) =>
+ docletClass.getMethod("setUniverse", classOf[Universe]).invoke(docletInstance, universe)
+ if (docletInstance.isInstanceOf[doclet.Indexer]) {
+ val index = model.IndexModelFactory.makeIndex(universe)
+ docletClass.getMethod("setIndex", classOf[Index]).invoke(docletInstance, index)
+ }
+ case None =>
+ throw new NoCompilerRunException()
+ }
+ }
+ docletInstance.generate
+ }
+ catch {
+ case e: ClassNotFoundException =>
+ case e: NoCompilerRunException =>
+ reporter.info(NoPosition, "No documentation generated with unsucessful compiler run", false)
}
+
+
+ }
+
}