summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/doc/Processor.scala
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2009-11-24 19:27:10 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2009-11-24 19:27:10 +0000
commitd9e3dde6d6d18b9a93e7566447cc3ee342f033d5 (patch)
tree13084c6cd10ca3d673d6eca2af3af8d96a96155f /src/compiler/scala/tools/nsc/doc/Processor.scala
parent583e431b07fae9c3fbeb075e40d7729958df6499 (diff)
downloadscala-d9e3dde6d6d18b9a93e7566447cc3ee342f033d5.tar.gz
scala-d9e3dde6d6d18b9a93e7566447cc3ee342f033d5.tar.bz2
scala-d9e3dde6d6d18b9a93e7566447cc3ee342f033d5.zip
Scaladoc 2.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/Processor.scala')
-rw-r--r--src/compiler/scala/tools/nsc/doc/Processor.scala56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/Processor.scala b/src/compiler/scala/tools/nsc/doc/Processor.scala
new file mode 100644
index 0000000000..8e08010f2c
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/doc/Processor.scala
@@ -0,0 +1,56 @@
+/* NSC -- new Scala compiler -- Copyright 2007-2009 LAMP/EPFL */
+
+// $Id$
+
+package scala.tools.nsc
+package doc
+
+import reporters.Reporter
+
+/** A documentation processor controls the process of generating Scala documentation, which is as follows.
+ *
+ * * A simplified compiler instance (with only the front-end phases enabled) is created, and additional
+ * ''sourceless'' comments are registered.
+ * * Documentable files are compiled, thereby filling the compiler's symbol table.
+ * * A documentation model is extracted from the post-compilation compiler's symbol table.
+ * * A generator is used to transform the model into the correct final format (HTML).
+ *
+ * A processor contains a single compiler instantiated from the processor's settings. Each call to the `run` method
+ * uses the same compiler instance with the same symbol table. In particular, this implies that the scaladoc site
+ * obtained from a call to `run` will contain documentation about files compiled during previous calls to the same
+ * processor's `run` method.
+ *
+ * @param reporter The reporter to which both documentation and compilation errors will be reported.
+ * @param settings The settings to be used by the documenter and compiler for generating documentation.
+ *
+ * @author Gilles Dubochet */
+class Processor(val reporter: Reporter, val settings: doc.Settings) { processor =>
+
+ /** The unique compiler instance used by this processor and constructed from its `settings`. */
+ object compiler extends Global(settings, reporter) {
+ override protected def computeInternalPhases() {
+ phasesSet += syntaxAnalyzer
+ phasesSet += analyzer.namerFactory
+ phasesSet += analyzer.typerFactory
+ phasesSet += superAccessors
+ phasesSet += pickler
+ phasesSet += refchecks
+ }
+ override def onlyPresentation = true
+ lazy val addSourceless = {
+ val sless = new SourcelessComments { val global = compiler }
+ comments ++= sless.comments
+ }
+ }
+
+ /** 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 document(files: List[String]): Unit = {
+ (new compiler.Run()) compile files
+ compiler.addSourceless
+ if (!reporter.hasErrors)
+ (new html.SiteFactory(reporter, settings)) generate (new model.EntityFactory(compiler, settings)).makeModel
+ }
+
+}