diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-03-05 15:07:14 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-03-05 15:07:14 +0000 |
commit | 1fcc24dd92a885b44e242d57764105c871979fe7 (patch) | |
tree | ca94c292242b116288d16921dec319f50c96b445 | |
parent | 3b8407a9ae6ab9c888e4458c1ef443b533341fd2 (diff) | |
download | scala-1fcc24dd92a885b44e242d57764105c871979fe7.tar.gz scala-1fcc24dd92a885b44e242d57764105c871979fe7.tar.bz2 scala-1fcc24dd92a885b44e242d57764105c871979fe7.zip |
ScalaDoc, etc.
of Settings. All doc related settings have been commented out of
Settings (soon to be removed) and are now found in doc.Settings.
-Ydoc is no more.
I believe I have updated the scaladoc Ant task correctly, but it is not
clear how to test it.
-rw-r--r-- | build.xml | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/ant/Scaladoc.scala | 49 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/CompilerCommand.scala | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ScalaDoc.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DefaultDocDriver.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocDriver.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/ModelExtractor.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/ModelFrames.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/Settings.scala | 28 | ||||
-rw-r--r-- | test/files/run/docgenerator.scala | 16 |
12 files changed, 84 insertions, 61 deletions
@@ -500,7 +500,6 @@ BUILD LOCAL REFERENCE (LOCKER) LAYER file="${locker.dir}/bin/${scaladoc.exec.name}" name="Scala doc generator" class="scala.tools.nsc.ScalaDoc" - toolflags="-Ydoc" version="${version.number}" copyright="${copyright.string}" javaFlags="${java.flags}"/> @@ -697,7 +696,6 @@ BUILD QUICK-TEST LAYER file="${quick.dir}/bin/${scaladoc.exec.name}" name="Scala doc generator" class="scala.tools.nsc.ScalaDoc" - toolflags="-Ydoc" version="${version.number}" copyright="${copyright.string}" javaFlags="${java.flags}"/> @@ -1271,7 +1269,6 @@ OPTIMIZE file="${optimised.dir}/bin/${scaladoc.exec.name}" name="Scala doc generator" class="scala.tools.nsc.ScalaDoc" - toolflags="-Ydoc" version="${version.number}" copyright="${copyright.string}" javaFlags="${java.flags}"/> @@ -1462,7 +1459,6 @@ TEST file="${strap.dir}/bin/${scaladoc.exec.name}" name="Scala doc generator" class="scala.tools.nsc.ScalaDoc" - toolflags="-Ydoc" version="${version.number}" copyright="${copyright.string}" javaFlags="${java.flags}"/> diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 79abc2740c..0259a4294b 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -474,7 +474,7 @@ class Scaladoc extends MatchingTask { \*============================================================================*/ /** Initializes settings and source files */ - protected def initialize: Pair[Settings, List[File]] = { + protected def initialize: Pair[scala.tools.nsc.doc.Settings, List[File]] = { // Tests if all mandatory attributes are set and valid. if (origin.isEmpty) error("Attribute 'srcdir' is not set.") if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.") @@ -524,28 +524,27 @@ class Scaladoc extends MatchingTask { // Builds-up the compilation settings for Scalac with the existing Ant // parameters. - val settings = new Settings(error) - settings.doc.value = true - settings.outdir.value = asString(destination.get) + val docSettings = new scala.tools.nsc.doc.Settings(error) + docSettings.outdir.value = asString(destination.get) if (!classpath.isEmpty) - settings.classpath.value = asString(getClasspath) + docSettings.classpath.value = asString(getClasspath) if (!sourcepath.isEmpty) - settings.sourcepath.value = asString(getSourcepath) + docSettings.sourcepath.value = asString(getSourcepath) /*else if (origin.get.size() > 0) settings.sourcepath.value = origin.get.list()(0)*/ if (!bootclasspath.isEmpty) - settings.bootclasspath.value = asString(getBootclasspath) - if (!extdirs.isEmpty) settings.extdirs.value = asString(getExtdirs) - if (!encoding.isEmpty) settings.encoding.value = encoding.get - if (!windowtitle.isEmpty) settings.windowtitle.value = windowtitle.get - if (!doctitle.isEmpty) settings.doctitle.value = decodeEscapes(doctitle.get) - if (!stylesheetfile.isEmpty) settings.stylesheetfile.value = stylesheetfile.get - if (!pageheader.isEmpty) settings.pageheader.value = decodeEscapes(pageheader.get) - if (!pagefooter.isEmpty) settings.pagefooter.value = decodeEscapes(pagefooter.get) - if (!pagetop.isEmpty) settings.pagetop.value = decodeEscapes(pagetop.get) - if (!pagebottom.isEmpty) settings.pagebottom.value = decodeEscapes(pagebottom.get) - settings.deprecation.value = deprecation - settings.unchecked.value = unchecked + docSettings.bootclasspath.value = asString(getBootclasspath) + if (!extdirs.isEmpty) docSettings.extdirs.value = asString(getExtdirs) + if (!encoding.isEmpty) docSettings.encoding.value = encoding.get + if (!windowtitle.isEmpty) docSettings.windowtitle.value = windowtitle.get + if (!doctitle.isEmpty) docSettings.doctitle.value = decodeEscapes(doctitle.get) + if (!stylesheetfile.isEmpty) docSettings.stylesheetfile.value = stylesheetfile.get + if (!pageheader.isEmpty) docSettings.pageheader.value = decodeEscapes(pageheader.get) + if (!pagefooter.isEmpty) docSettings.pagefooter.value = decodeEscapes(pagefooter.get) + if (!pagetop.isEmpty) docSettings.pagetop.value = decodeEscapes(pagetop.get) + if (!pagebottom.isEmpty) docSettings.pagebottom.value = decodeEscapes(pagebottom.get) + docSettings.deprecation.value = deprecation + docSettings.unchecked.value = unchecked log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG) var args = if (addParams.trim() == "") Nil @@ -553,13 +552,13 @@ class Scaladoc extends MatchingTask { while (!args.isEmpty) { val argsBuf = args if (args.head startsWith "-") { - for (setting <- settings.allSettings) - args = setting.tryToSet(args); + for (docSetting <- docSettings.allSettings) + args = docSetting.tryToSet(args); } else error("Parameter '" + args.head + "' does not start with '-'.") if (argsBuf eq args) error("Parameter '" + args.head + "' is not recognised by Scaladoc.") } - Pair(settings, sourceFiles) + Pair(docSettings, sourceFiles) } /** Performs the compilation. */ @@ -568,13 +567,15 @@ class Scaladoc extends MatchingTask { val reporter = new ConsoleReporter(commandSettings) // Compiles the actual code - val compiler = new Global(commandSettings, reporter) + val compiler = new Global(commandSettings, reporter) { + override val onlyPresentation = true + } try { val run = new compiler.Run run.compile(sourceFiles.map (_.toString)) object generator extends DefaultDocDriver { - val global: compiler.type = compiler - def settings = commandSettings + lazy val global: compiler.type = compiler + lazy val settings = commandSettings } generator.process(run.units) if (reporter.ERROR.count > 0) diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 25c53cb2b7..e005e0208e 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -35,9 +35,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, /** A message explaining usage and options */ def usageMsg: String = { settings.allSettings - .filter(setting => - setting.isStandard && - (settings.doc.value == setting.isDocOption)) + .filter(_.isStandard) .map(setting => format(setting.helpSyntax) + " " + setting.helpDescription) .mkString("Usage: " + cmdName + " <options> <source files>\n" + @@ -49,9 +47,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, /** A message explaining usage and options */ def xusageMsg: String = { settings.allSettings - .filter(setting => - setting.isAdvanced && - (settings.doc.value == setting.isDocOption)) + .filter(_.isAdvanced) .map(setting => format(setting.helpSyntax) + " " + setting.helpDescription) .mkString("Possible advanced options include:\n ", @@ -62,9 +58,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, /** A message explaining usage and options */ def yusageMsg: String = { settings.allSettings - .filter(setting => - setting.isPrivate && - (settings.doc.value == setting.isDocOption)) + .filter(_.isPrivate) .map(setting => format(setting.helpSyntax) + " " + setting.helpDescription) .mkString("Possible private options include:\n ", diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 493c39dd15..93bdc02d50 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -704,7 +704,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def forCLDC: Boolean = settings.target.value == "cldc" def forJVM : Boolean = settings.target.value startsWith "jvm" def forMSIL: Boolean = settings.target.value == "msil" - def onlyPresentation = inIDE || settings.doc.value + def onlyPresentation = inIDE private val unpickleIDEHook0 : (( => Type) => Type) = f => f def unpickleIDEHook : (( => Type) => Type) = unpickleIDEHook0 diff --git a/src/compiler/scala/tools/nsc/ScalaDoc.scala b/src/compiler/scala/tools/nsc/ScalaDoc.scala index 021150ee2f..0811b2749f 100644 --- a/src/compiler/scala/tools/nsc/ScalaDoc.scala +++ b/src/compiler/scala/tools/nsc/ScalaDoc.scala @@ -31,9 +31,9 @@ object ScalaDoc { } def process(args: Array[String]) { - val settings = new Settings(error) - reporter = new ConsoleReporter(settings) - val command = new CompilerCommand(List.fromArray(args), settings, error, false) + val docSettings : doc.Settings = new doc.Settings(error) + reporter = new ConsoleReporter(docSettings) + val command = new CompilerCommand(List.fromArray(args), docSettings, error, false) if (command.settings.version.value) reporter.info(null, versionMsg, true) else { @@ -44,7 +44,9 @@ object ScalaDoc { command.settings.assemrefs.value + File.pathSeparator + libpath } try { - object compiler extends Global(command.settings, reporter) + object compiler extends Global(command.settings, reporter) { + override val onlyPresentation = true + } if (reporter.hasErrors) { reporter.flush() return @@ -68,9 +70,9 @@ object ScalaDoc { run compile command.files val generator = new DefaultDocDriver { lazy val global: compiler.type = compiler - def settings = command.settings + lazy val settings = docSettings } - generator.process(command.settings, run.units) + generator.process(run.units) reporter.printSummary() } } catch { diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index ef590cc545..9b1567d145 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -132,7 +132,7 @@ class Settings(error: String => Unit) { val debug = BooleanSetting ("-Ydebug", "Output debugging messages").hideToIDE val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination") val Xdetach = BooleanSetting ("-Ydetach", "Perform detaching of remote closures") - val doc = BooleanSetting ("-Ydoc", "Generate documentation").hideToIDE +// val doc = BooleanSetting ("-Ydoc", "Generate documentation").hideToIDE val inline = BooleanSetting ("-Yinline", "Perform inlining when possible") val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") val log = PhasesSetting ("-Ylog", "Log operations in") @@ -151,7 +151,7 @@ class Settings(error: String => Unit) { /*default*/"off") val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations") - +/* /** scaladoc specific options */ val memberaccess = ChoiceSetting ("-access", "Show only public, protected/public (default) or all classes and members", List("public", "protected", "private"), "protected").dependsOn(doc) @@ -165,7 +165,7 @@ class Settings(error: String => Unit) { val stylesheetfile = StringSetting ("-stylesheetfile", "stylesheetfile", "File to change style of the generated documentation", "style.css").dependsOn(doc) val pagetop = StringSetting ("-top", "pagetop", "Include top text for each page", "").dependsOn(doc) val windowtitle = StringSetting ("-windowtitle", "windowtitle", "Specify window title of generated HTML documentation", "Scala 2").dependsOn(doc) - +*/ /** A list of all settings */ def allSettings: List[Setting] = allsettings.reverse /** Disable a setting */ @@ -252,9 +252,11 @@ class Settings(error: String => Unit) { (name startsWith "-X") && !(name eq "-X") def isPrivate: Boolean = (name == "-P") || ((name startsWith "-Y") && !(name eq "-Y")) + +/* def isDocOption: Boolean = !dependency.isEmpty && dependency.get._1 == doc - +*/ // initialization allsettings = this :: allsettings } diff --git a/src/compiler/scala/tools/nsc/doc/DefaultDocDriver.scala b/src/compiler/scala/tools/nsc/doc/DefaultDocDriver.scala index 56f6c09d9f..96e50ff67d 100644 --- a/src/compiler/scala/tools/nsc/doc/DefaultDocDriver.scala +++ b/src/compiler/scala/tools/nsc/doc/DefaultDocDriver.scala @@ -31,10 +31,6 @@ abstract class DefaultDocDriver extends DocDriver with ModelFrames with ModelToX def init {} } - def process(settings: Settings, units: Iterator[CompilationUnit]) { - process(units) - } - def process(units: Iterator[CompilationUnit]) { assert(global.definitions != null) diff --git a/src/compiler/scala/tools/nsc/doc/DocDriver.scala b/src/compiler/scala/tools/nsc/doc/DocDriver.scala index 417b54fb7f..a75317e1d8 100644 --- a/src/compiler/scala/tools/nsc/doc/DocDriver.scala +++ b/src/compiler/scala/tools/nsc/doc/DocDriver.scala @@ -14,6 +14,7 @@ package scala.tools.nsc.doc abstract class DocDriver { val global: Global import global._ + def settings: doc.Settings - def process(settings: Settings, units: Iterator[CompilationUnit]): Unit + def process(units: Iterator[CompilationUnit]): Unit } diff --git a/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala b/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala index 90d15557c7..a3fcfa223b 100644 --- a/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala +++ b/src/compiler/scala/tools/nsc/doc/ModelExtractor.scala @@ -18,6 +18,7 @@ import compat.Platform.{EOL => LINE_SEPARATOR} trait ModelExtractor { val global: Global import global._ + def settings: doc.Settings def assert(b: Boolean) { if (!b) throw new Error diff --git a/src/compiler/scala/tools/nsc/doc/ModelFrames.scala b/src/compiler/scala/tools/nsc/doc/ModelFrames.scala index f93e502baf..5d7ba96397 100644 --- a/src/compiler/scala/tools/nsc/doc/ModelFrames.scala +++ b/src/compiler/scala/tools/nsc/doc/ModelFrames.scala @@ -18,7 +18,7 @@ import scala.xml.{NodeSeq, Text, Unparsed, Utility} */ trait ModelFrames extends ModelExtractor { import DocUtil._ - def settings: Settings + def settings: doc.Settings val SyntheticClasses = new scala.collection.mutable.HashSet[global.Symbol]; { diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala new file mode 100644 index 0000000000..e938f4f36c --- /dev/null +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -0,0 +1,28 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2007 LAMP/EPFL + * @author Martin Odersky + */ +// $Id$ + +package scala.tools.nsc.doc + +import java.io.File +import java.lang.System + +class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) { + + /** scaladoc specific options */ + val memberaccess = ChoiceSetting ("-access", "Show only public, protected/public (default) or all classes and members", + List("public", "protected", "private"), "protected") + val pagebottom = StringSetting ("-bottom", "pagebottom", "Include bottom text for each page", "") + val doccharset = StringSetting ("-charset", "doccharset", "Charset for cross-platform viewing of generated documentation.", "") + val doctitle = StringSetting ("-doctitle", "doctitle", "Include title for the overview page", "Scala 2<br/>API Specification") + val pagefooter = StringSetting ("-footer", "pagefooter", "Include footer text for each page", "") + val pageheader = StringSetting ("-header", "pageheader", "Include header text for each page", "") + val linksource = BooleanSetting ("-linksource", "Generate source in HTML").hideToIDE + val nocomment = BooleanSetting ("-nocomment", "Suppress description and tags, generate only declarations.").hideToIDE + val stylesheetfile = StringSetting ("-stylesheetfile", "stylesheetfile", "File to change style of the generated documentation", "style.css") + val pagetop = StringSetting ("-top", "pagetop", "Include top text for each page", "") + val windowtitle = StringSetting ("-windowtitle", "windowtitle", "Specify window title of generated HTML documentation", "Scala 2") + +} diff --git a/test/files/run/docgenerator.scala b/test/files/run/docgenerator.scala index d36700f82b..4792106456 100644 --- a/test/files/run/docgenerator.scala +++ b/test/files/run/docgenerator.scala @@ -21,7 +21,7 @@ object Test { private def test1(tmpDir: File) { def testOptions(inFile: File, outDirName: String, opts: String*) { val outDir = createDir(tmpDir, outDirName) - val args = Array.concat(Array("-Ydoc", "-d", outDir.getPath, inFile.getPath), opts.toArray:Array[String]) + val args = Array.concat(Array("-d", outDir.getPath, inFile.getPath), opts.toArray:Array[String]) if (MainDoc.main0(args)) { for (name <- List("all-classes.html", "index.html")) { val outFile = new File(outDir, name) @@ -91,7 +91,7 @@ object Foo2 { f } val outDir = createDir(tmpDir, "annots1") - val args = Array.concat(Array("-Ydoc", "-d", outDir.getPath, inFile.getPath)) + val args = Array.concat(Array("-d", outDir.getPath, inFile.getPath)) if (MainDoc.main0(args)) { for (name <- List("all-classes.html", "index.html")) { val outFile = new File(outDir, name) @@ -112,11 +112,13 @@ object Foo2 { def error(msg: String) { Console.err.println(msg) } var reporter: ConsoleReporter = _ def process(args: Array[String]) { - val settings = new Settings(error) - reporter = new ConsoleReporter(settings) - val command = new CompilerCommand(List.fromArray(args), settings, error, false) + val docSettings = new scala.tools.nsc.doc.Settings(error) + reporter = new ConsoleReporter(docSettings) + val command = new CompilerCommand(List.fromArray(args), docSettings, error, false) try { - object compiler extends Global(command.settings, reporter) + object compiler extends Global(command.settings, reporter) { + override val onlyPresentation = true + } if (reporter.hasErrors) { reporter.flush() return @@ -125,7 +127,7 @@ object Foo2 { run compile command.files object generator extends DefaultDocDriver { lazy val global: compiler.type = compiler - def settings = command.settings + lazy val settings = docSettings } generator process run.units reporter.printSummary() |