summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-07 07:31:02 +0000
committerPaul Phillips <paulp@improving.org>2011-04-07 07:31:02 +0000
commitf8f09796e884e62a5562efcf8c1e0f49eaa97c49 (patch)
tree937edee858dc437aee7b1a0400a6d922658894ae /src/compiler/scala/tools/nsc/doc/Uncompilable.scala
parent6a204df670a118be6a31676ed26a20a6408e2ab6 (diff)
downloadscala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.tar.gz
scala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.tar.bz2
scala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.zip
Deleted SourcelessComments.
Nothing and Null with improved documentation of their particulars and convinced scaladoc to parse them without leaving scalac institutionalized. Now rather than seeing our hardcoded documentation strings bitrot in a shadowy flight from classes which do not exist, we are championing the cause of the innocent and powerless. Nothing and Null aren't above the law! So now any responsible party can fire up their text editor and go to town on Nothing.scala. As I'm sure they will. Review by malayeri.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/Uncompilable.scala')
-rw-r--r--src/compiler/scala/tools/nsc/doc/Uncompilable.scala48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
new file mode 100644
index 0000000000..1f0c85361e
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
@@ -0,0 +1,48 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala.tools.nsc
+package doc
+
+/** Some glue between DocParser (which reads source files which can't be compiled)
+ * and the scaladoc model.
+ */
+trait Uncompilable {
+ val global: Global
+ val settings: Settings
+
+ import global.{ reporter, inform, warning, newTypeName, newTermName, Symbol, Name, DocComment }
+ import global.definitions.RootClass
+
+ private implicit def translateName(name: Global#Name) =
+ if (name.isTypeName) newTypeName("" + name) else newTermName("" + name)
+
+ def docSymbol(p: DocParser.Parsed) = p.nameChain.foldLeft(RootClass: Symbol)(_.tpe member _)
+ def docDefs(code: String) = new DocParser(settings, reporter) docDefs code
+ def docPairs(code: String) = docDefs(code) map (p => (docSymbol(p), new DocComment(p.raw)))
+
+ lazy val pairs = files flatMap { f =>
+ val comments = docPairs(f.slurp())
+ if (settings.verbose.value)
+ inform("Found %d doc comments in parse-only file %s: %s".format(comments.size, f, comments.map(_._1).mkString(", ")))
+
+ comments
+ }
+ def files = settings.uncompilableFiles
+ def symbols = pairs map (_._1)
+ def templates = symbols filter (x => x.isClass || x.isTrait) toSet
+ def comments = {
+ if (settings.debug.value || settings.verbose.value)
+ inform("Found %d uncompilable files: %s".format(files.size, files mkString ", "))
+
+ if (pairs.isEmpty)
+ warning("no doc comments read from " + settings.docUncompilable.value)
+
+ pairs
+ }
+ override def toString = pairs.size + " uncompilable symbols:\n" + (
+ symbols map (x => " " + x.owner.fullName + " " + x.defString) mkString "\n"
+ )
+}