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}"
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}"/>

View File

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

View File

@ -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 ",

View File

@ -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

View File

@ -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 {

View File

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

View File

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

View File

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

View File

@ -18,7 +18,8 @@ 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
}

View File

@ -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];
{

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) {
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()