ScalaDoc, etc. now use a doc.Settings, which is a subclass

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.



git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@14270 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
washburn 2008-03-05 15:07:14 +00:00
parent f983d8037e
commit 6f5f1b4016
12 changed files with 85 additions and 62 deletions

View File

@ -500,7 +500,6 @@ BUILD LOCAL REFERENCE (LOCKER) LAYER
file="${locker.dir}/bin/${scaladoc.exec.name}" file="${locker.dir}/bin/${scaladoc.exec.name}"
name="Scala doc generator" name="Scala doc generator"
class="scala.tools.nsc.ScalaDoc" class="scala.tools.nsc.ScalaDoc"
toolflags="-Ydoc"
version="${version.number}" version="${version.number}"
copyright="${copyright.string}" copyright="${copyright.string}"
javaFlags="${java.flags}"/> javaFlags="${java.flags}"/>
@ -697,7 +696,6 @@ BUILD QUICK-TEST LAYER
file="${quick.dir}/bin/${scaladoc.exec.name}" file="${quick.dir}/bin/${scaladoc.exec.name}"
name="Scala doc generator" name="Scala doc generator"
class="scala.tools.nsc.ScalaDoc" class="scala.tools.nsc.ScalaDoc"
toolflags="-Ydoc"
version="${version.number}" version="${version.number}"
copyright="${copyright.string}" copyright="${copyright.string}"
javaFlags="${java.flags}"/> javaFlags="${java.flags}"/>
@ -1271,7 +1269,6 @@ OPTIMIZE
file="${optimised.dir}/bin/${scaladoc.exec.name}" file="${optimised.dir}/bin/${scaladoc.exec.name}"
name="Scala doc generator" name="Scala doc generator"
class="scala.tools.nsc.ScalaDoc" class="scala.tools.nsc.ScalaDoc"
toolflags="-Ydoc"
version="${version.number}" version="${version.number}"
copyright="${copyright.string}" copyright="${copyright.string}"
javaFlags="${java.flags}"/> javaFlags="${java.flags}"/>
@ -1462,7 +1459,6 @@ TEST
file="${strap.dir}/bin/${scaladoc.exec.name}" file="${strap.dir}/bin/${scaladoc.exec.name}"
name="Scala doc generator" name="Scala doc generator"
class="scala.tools.nsc.ScalaDoc" class="scala.tools.nsc.ScalaDoc"
toolflags="-Ydoc"
version="${version.number}" version="${version.number}"
copyright="${copyright.string}" copyright="${copyright.string}"
javaFlags="${java.flags}"/> javaFlags="${java.flags}"/>

View File

@ -474,7 +474,7 @@ class Scaladoc extends MatchingTask {
\*============================================================================*/ \*============================================================================*/
/** Initializes settings and source files */ /** 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. // Tests if all mandatory attributes are set and valid.
if (origin.isEmpty) error("Attribute 'srcdir' is not set.") if (origin.isEmpty) error("Attribute 'srcdir' is not set.")
if (getOrigin.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 // Builds-up the compilation settings for Scalac with the existing Ant
// parameters. // parameters.
val settings = new Settings(error) val docSettings = new scala.tools.nsc.doc.Settings(error)
settings.doc.value = true docSettings.outdir.value = asString(destination.get)
settings.outdir.value = asString(destination.get)
if (!classpath.isEmpty) if (!classpath.isEmpty)
settings.classpath.value = asString(getClasspath) docSettings.classpath.value = asString(getClasspath)
if (!sourcepath.isEmpty) if (!sourcepath.isEmpty)
settings.sourcepath.value = asString(getSourcepath) docSettings.sourcepath.value = asString(getSourcepath)
/*else if (origin.get.size() > 0) /*else if (origin.get.size() > 0)
settings.sourcepath.value = origin.get.list()(0)*/ settings.sourcepath.value = origin.get.list()(0)*/
if (!bootclasspath.isEmpty) if (!bootclasspath.isEmpty)
settings.bootclasspath.value = asString(getBootclasspath) docSettings.bootclasspath.value = asString(getBootclasspath)
if (!extdirs.isEmpty) settings.extdirs.value = asString(getExtdirs) if (!extdirs.isEmpty) docSettings.extdirs.value = asString(getExtdirs)
if (!encoding.isEmpty) settings.encoding.value = encoding.get if (!encoding.isEmpty) docSettings.encoding.value = encoding.get
if (!windowtitle.isEmpty) settings.windowtitle.value = windowtitle.get if (!windowtitle.isEmpty) docSettings.windowtitle.value = windowtitle.get
if (!doctitle.isEmpty) settings.doctitle.value = decodeEscapes(doctitle.get) if (!doctitle.isEmpty) docSettings.doctitle.value = decodeEscapes(doctitle.get)
if (!stylesheetfile.isEmpty) settings.stylesheetfile.value = stylesheetfile.get if (!stylesheetfile.isEmpty) docSettings.stylesheetfile.value = stylesheetfile.get
if (!pageheader.isEmpty) settings.pageheader.value = decodeEscapes(pageheader.get) if (!pageheader.isEmpty) docSettings.pageheader.value = decodeEscapes(pageheader.get)
if (!pagefooter.isEmpty) settings.pagefooter.value = decodeEscapes(pagefooter.get) if (!pagefooter.isEmpty) docSettings.pagefooter.value = decodeEscapes(pagefooter.get)
if (!pagetop.isEmpty) settings.pagetop.value = decodeEscapes(pagetop.get) if (!pagetop.isEmpty) docSettings.pagetop.value = decodeEscapes(pagetop.get)
if (!pagebottom.isEmpty) settings.pagebottom.value = decodeEscapes(pagebottom.get) if (!pagebottom.isEmpty) docSettings.pagebottom.value = decodeEscapes(pagebottom.get)
settings.deprecation.value = deprecation docSettings.deprecation.value = deprecation
settings.unchecked.value = unchecked docSettings.unchecked.value = unchecked
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG) log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
var args = var args =
if (addParams.trim() == "") Nil if (addParams.trim() == "") Nil
@ -553,13 +552,13 @@ class Scaladoc extends MatchingTask {
while (!args.isEmpty) { while (!args.isEmpty) {
val argsBuf = args val argsBuf = args
if (args.head startsWith "-") { if (args.head startsWith "-") {
for (setting <- settings.allSettings) for (docSetting <- docSettings.allSettings)
args = setting.tryToSet(args); args = docSetting.tryToSet(args);
} else error("Parameter '" + args.head + "' does not start with '-'.") } else error("Parameter '" + args.head + "' does not start with '-'.")
if (argsBuf eq args) if (argsBuf eq args)
error("Parameter '" + args.head + "' is not recognised by Scaladoc.") error("Parameter '" + args.head + "' is not recognised by Scaladoc.")
} }
Pair(settings, sourceFiles) Pair(docSettings, sourceFiles)
} }
/** Performs the compilation. */ /** Performs the compilation. */
@ -568,13 +567,15 @@ class Scaladoc extends MatchingTask {
val reporter = new ConsoleReporter(commandSettings) val reporter = new ConsoleReporter(commandSettings)
// Compiles the actual code // Compiles the actual code
val compiler = new Global(commandSettings, reporter) val compiler = new Global(commandSettings, reporter) {
override val onlyPresentation = true
}
try { try {
val run = new compiler.Run val run = new compiler.Run
run.compile(sourceFiles.map (_.toString)) run.compile(sourceFiles.map (_.toString))
object generator extends DefaultDocDriver { object generator extends DefaultDocDriver {
val global: compiler.type = compiler lazy val global: compiler.type = compiler
def settings = commandSettings lazy val settings = commandSettings
} }
generator.process(run.units) generator.process(run.units)
if (reporter.ERROR.count > 0) if (reporter.ERROR.count > 0)

View File

@ -35,9 +35,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings,
/** A message explaining usage and options */ /** A message explaining usage and options */
def usageMsg: String = { def usageMsg: String = {
settings.allSettings settings.allSettings
.filter(setting => .filter(_.isStandard)
setting.isStandard &&
(settings.doc.value == setting.isDocOption))
.map(setting => .map(setting =>
format(setting.helpSyntax) + " " + setting.helpDescription) format(setting.helpSyntax) + " " + setting.helpDescription)
.mkString("Usage: " + cmdName + " <options> <source files>\n" + .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 */ /** A message explaining usage and options */
def xusageMsg: String = { def xusageMsg: String = {
settings.allSettings settings.allSettings
.filter(setting => .filter(_.isAdvanced)
setting.isAdvanced &&
(settings.doc.value == setting.isDocOption))
.map(setting => .map(setting =>
format(setting.helpSyntax) + " " + setting.helpDescription) format(setting.helpSyntax) + " " + setting.helpDescription)
.mkString("Possible advanced options include:\n ", .mkString("Possible advanced options include:\n ",
@ -62,9 +58,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings,
/** A message explaining usage and options */ /** A message explaining usage and options */
def yusageMsg: String = { def yusageMsg: String = {
settings.allSettings settings.allSettings
.filter(setting => .filter(_.isPrivate)
setting.isPrivate &&
(settings.doc.value == setting.isDocOption))
.map(setting => .map(setting =>
format(setting.helpSyntax) + " " + setting.helpDescription) format(setting.helpSyntax) + " " + setting.helpDescription)
.mkString("Possible private options include:\n ", .mkString("Possible private options include:\n ",

View File

@ -704,7 +704,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def forCLDC: Boolean = settings.target.value == "cldc" def forCLDC: Boolean = settings.target.value == "cldc"
def forJVM : Boolean = settings.target.value startsWith "jvm" def forJVM : Boolean = settings.target.value startsWith "jvm"
def forMSIL: Boolean = settings.target.value == "msil" def forMSIL: Boolean = settings.target.value == "msil"
def onlyPresentation = inIDE || settings.doc.value def onlyPresentation = inIDE
private val unpickleIDEHook0 : (( => Type) => Type) = f => f private val unpickleIDEHook0 : (( => Type) => Type) = f => f
def unpickleIDEHook : (( => Type) => Type) = unpickleIDEHook0 def unpickleIDEHook : (( => Type) => Type) = unpickleIDEHook0

View File

@ -31,9 +31,9 @@ object ScalaDoc {
} }
def process(args: Array[String]) { def process(args: Array[String]) {
val settings = new Settings(error) val docSettings : doc.Settings = new doc.Settings(error)
reporter = new ConsoleReporter(settings) reporter = new ConsoleReporter(docSettings)
val command = new CompilerCommand(List.fromArray(args), settings, error, false) val command = new CompilerCommand(List.fromArray(args), docSettings, error, false)
if (command.settings.version.value) if (command.settings.version.value)
reporter.info(null, versionMsg, true) reporter.info(null, versionMsg, true)
else { else {
@ -44,7 +44,9 @@ object ScalaDoc {
command.settings.assemrefs.value + File.pathSeparator + libpath command.settings.assemrefs.value + File.pathSeparator + libpath
} }
try { try {
object compiler extends Global(command.settings, reporter) object compiler extends Global(command.settings, reporter) {
override val onlyPresentation = true
}
if (reporter.hasErrors) { if (reporter.hasErrors) {
reporter.flush() reporter.flush()
return return
@ -68,9 +70,9 @@ object ScalaDoc {
run compile command.files run compile command.files
val generator = new DefaultDocDriver { val generator = new DefaultDocDriver {
lazy val global: compiler.type = compiler 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() reporter.printSummary()
} }
} catch { } catch {

View File

@ -132,7 +132,7 @@ class Settings(error: String => Unit) {
val debug = BooleanSetting ("-Ydebug", "Output debugging messages").hideToIDE val debug = BooleanSetting ("-Ydebug", "Output debugging messages").hideToIDE
val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination") val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination")
val Xdetach = BooleanSetting ("-Ydetach", "Perform detaching of remote closures") 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 inline = BooleanSetting ("-Yinline", "Perform inlining when possible")
val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo")
val log = PhasesSetting ("-Ylog", "Log operations in") val log = PhasesSetting ("-Ylog", "Log operations in")
@ -151,7 +151,7 @@ class Settings(error: String => Unit) {
/*default*/"off") /*default*/"off")
val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations") val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations")
/*
/** scaladoc specific options */ /** scaladoc specific options */
val memberaccess = ChoiceSetting ("-access", "Show only public, protected/public (default) or all classes and members", val memberaccess = ChoiceSetting ("-access", "Show only public, protected/public (default) or all classes and members",
List("public", "protected", "private"), "protected").dependsOn(doc) 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 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 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) val windowtitle = StringSetting ("-windowtitle", "windowtitle", "Specify window title of generated HTML documentation", "Scala 2").dependsOn(doc)
*/
/** A list of all settings */ /** A list of all settings */
def allSettings: List[Setting] = allsettings.reverse def allSettings: List[Setting] = allsettings.reverse
/** Disable a setting */ /** Disable a setting */
@ -252,9 +252,11 @@ class Settings(error: String => Unit) {
(name startsWith "-X") && !(name eq "-X") (name startsWith "-X") && !(name eq "-X")
def isPrivate: Boolean = def isPrivate: Boolean =
(name == "-P") || ((name startsWith "-Y") && !(name eq "-Y")) (name == "-P") || ((name startsWith "-Y") && !(name eq "-Y"))
/*
def isDocOption: Boolean = def isDocOption: Boolean =
!dependency.isEmpty && dependency.get._1 == doc !dependency.isEmpty && dependency.get._1 == doc
*/
// initialization // initialization
allsettings = this :: allsettings allsettings = this :: allsettings
} }

View File

@ -31,10 +31,6 @@ abstract class DefaultDocDriver extends DocDriver with ModelFrames with ModelToX
def init {} def init {}
} }
def process(settings: Settings, units: Iterator[CompilationUnit]) {
process(units)
}
def process(units: Iterator[CompilationUnit]) { def process(units: Iterator[CompilationUnit]) {
assert(global.definitions != null) assert(global.definitions != null)

View File

@ -14,6 +14,7 @@ package scala.tools.nsc.doc
abstract class DocDriver { abstract class DocDriver {
val global: Global val global: Global
import global._ import global._
def settings: doc.Settings
def process(settings: Settings, units: Iterator[CompilationUnit]): Unit def process(units: Iterator[CompilationUnit]): Unit
} }

View File

@ -18,6 +18,7 @@ import compat.Platform.{EOL => LINE_SEPARATOR}
trait ModelExtractor { trait ModelExtractor {
val global: Global val global: Global
import global._ import global._
def settings: doc.Settings
def assert(b: Boolean) { def assert(b: Boolean) {
if (!b) throw new Error if (!b) throw new Error

View File

@ -18,7 +18,7 @@ import scala.xml.{NodeSeq, Text, Unparsed, Utility}
*/ */
trait ModelFrames extends ModelExtractor { trait ModelFrames extends ModelExtractor {
import DocUtil._ import DocUtil._
def settings: Settings def settings: doc.Settings
val SyntheticClasses = new scala.collection.mutable.HashSet[global.Symbol]; val SyntheticClasses = new scala.collection.mutable.HashSet[global.Symbol];
{ {

View File

@ -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")
}

View File

@ -21,7 +21,7 @@ object Test {
private def test1(tmpDir: File) { private def test1(tmpDir: File) {
def testOptions(inFile: File, outDirName: String, opts: String*) { def testOptions(inFile: File, outDirName: String, opts: String*) {
val outDir = createDir(tmpDir, outDirName) 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)) { if (MainDoc.main0(args)) {
for (name <- List("all-classes.html", "index.html")) { for (name <- List("all-classes.html", "index.html")) {
val outFile = new File(outDir, name) val outFile = new File(outDir, name)
@ -91,7 +91,7 @@ object Foo2 {
f f
} }
val outDir = createDir(tmpDir, "annots1") 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)) { if (MainDoc.main0(args)) {
for (name <- List("all-classes.html", "index.html")) { for (name <- List("all-classes.html", "index.html")) {
val outFile = new File(outDir, name) val outFile = new File(outDir, name)
@ -112,11 +112,13 @@ object Foo2 {
def error(msg: String) { Console.err.println(msg) } def error(msg: String) { Console.err.println(msg) }
var reporter: ConsoleReporter = _ var reporter: ConsoleReporter = _
def process(args: Array[String]) { def process(args: Array[String]) {
val settings = new Settings(error) val docSettings = new scala.tools.nsc.doc.Settings(error)
reporter = new ConsoleReporter(settings) reporter = new ConsoleReporter(docSettings)
val command = new CompilerCommand(List.fromArray(args), settings, error, false) val command = new CompilerCommand(List.fromArray(args), docSettings, error, false)
try { try {
object compiler extends Global(command.settings, reporter) object compiler extends Global(command.settings, reporter) {
override val onlyPresentation = true
}
if (reporter.hasErrors) { if (reporter.hasErrors) {
reporter.flush() reporter.flush()
return return
@ -125,7 +127,7 @@ object Foo2 {
run compile command.files run compile command.files
object generator extends DefaultDocDriver { object generator extends DefaultDocDriver {
lazy val global: compiler.type = compiler lazy val global: compiler.type = compiler
def settings = command.settings lazy val settings = docSettings
} }
generator process run.units generator process run.units
reporter.printSummary() reporter.printSummary()