scaladoc.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 607 行 · 第 1/2 页
SCALA
607 行
/* __ *\** ________ ___ / / ___ Scala Ant Tasks **** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: Scaladoc.scala 14416 2008-03-19 01:17:25Z mihaylov $package scala.tools.antimport java.io.Fileimport org.apache.tools.ant.{BuildException, Project}import org.apache.tools.ant.taskdefs.MatchingTaskimport org.apache.tools.ant.types.{Path, Reference}import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper}import scala.tools.nsc.{Global, Settings}import scala.tools.nsc.doc.DefaultDocDriverimport scala.tools.nsc.reporters.{Reporter, ConsoleReporter}/** <p> * An Ant task to document Scala code. * </p> * <p> * This task can take the following parameters as attributes: * </p> * <ul> * <li>srcdir (mandatory),</li> * <li>srcref,</li> * <li>destdir,</li> * <li>classpath,</li> * <li>classpathref,</li> * <li>sourcepath,</li> * <li>sourcepathref,</li> * <li>bootclasspath,</li> * <li>bootclasspathref,</li> * <li>extdirs,</li> * <li>extdirsref,</li> * <li>encoding,</li> * <li>windowtitle,</li> * <li>doctitle,</li> * <li>stylesheetfile,</li> * <li>header,</li> * <li>footer,</li> * <li>top,</li> * <li>bottom,</li> * <li>addparams,</li> * <li>deprecation,</li> * <li>unchecked.</li> * </ul> * <p> * It also takes the following parameters as nested elements: * </p> * <ul> * <li>src (for srcdir),</li> * <li>classpath,</li> * <li>sourcepath,</li> * <li>bootclasspath,</li> * <li>extdirs.</li> * </ul> * * @author Gilles Dubochet, Stephane Micheloud */class Scaladoc extends MatchingTask { /** The unique Ant file utilities instance to use in this task. */ private val fileUtils = FileUtils.newFileUtils()/*============================================================================*\** Ant user-properties **\*============================================================================*/ abstract class PermissibleValue { val values: List[String] def isPermissible(value: String): Boolean = (value == "") || values.exists(_.startsWith(value)) } /** Defines valid values for the <code>deprecation</code> and * <code>unchecked</code> properties. */ object Flag extends PermissibleValue { val values = List("yes", "no", "on", "off") } /** The directories that contain source files to compile. */ private var origin: Option[Path] = None /** The directory to put the compiled files in. */ private var destination: Option[File] = None /** The class path to use for this compilation. */ private var classpath: Option[Path] = None /** The source path to use for this compilation. */ private var sourcepath: Option[Path] = None /** The boot class path to use for this compilation. */ private var bootclasspath: Option[Path] = None /** The external extensions path to use for this compilation. */ private var extdirs: Option[Path] = None /** The character encoding of the files to compile. */ private var encoding: Option[String] = None /** The window title of the generated HTML documentation. */ private var windowtitle: Option[String] = None /** The document title of the generated HTML documentation. */ private var doctitle: Option[String] = None /** The user-specified stylesheet file. */ private var stylesheetfile: Option[String] = None /** The user-specified header/footer and top/bottom texts. */ private var pageheader: Option[String] = None private var pagefooter: Option[String] = None private var pagetop : Option[String] = None private var pagebottom: Option[String] = None /** Instruct the compiler to use additional parameters */ private var addParams: String = "" /** Instruct the compiler to generate deprecation information. */ private var deprecation: Boolean = false /** Instruct the compiler to generate unchecked information. */ private var unchecked: Boolean = false/*============================================================================*\** Properties setters **\*============================================================================*/ /** Sets the <code>srcdir</code> attribute. Used by Ant. * * @param input The value of <code>origin</code>. */ def setSrcdir(input: Path) = if (origin.isEmpty) origin = Some(input) else origin.get.append(input) /** Sets the <code>origin</code> as a nested src Ant parameter. * * @return An origin path to be configured. */ def createSrc(): Path = { if (origin.isEmpty) origin = Some(new Path(getProject())) origin.get.createPath() } /** Sets the <code>origin</code> as an external reference Ant parameter. * * @param input A reference to an origin path. */ def setSrcref(input: Reference) = createSrc().setRefid(input) /** Sets the <code>destdir</code> attribute. Used by Ant. * * @param input The value of <code>destination</code>. */ def setDestdir(input: File) = destination = Some(input) /** Sets the <code>classpath</code> attribute. Used by Ant. * * @param input The value of <code>classpath</code>. */ def setClasspath(input: Path) = if (classpath.isEmpty) classpath = Some(input) else classpath.get.append(input) /** Sets the <code>classpath</code> as a nested classpath Ant parameter. * * @return A class path to be configured. */ def createClasspath(): Path = { if (classpath.isEmpty) classpath = Some(new Path(getProject())) classpath.get.createPath() } /** Sets the <code>classpath</code> as an external reference Ant parameter. * * @param input A reference to a class path. */ def setClasspathref(input: Reference) = createClasspath().setRefid(input) /** Sets the <code>sourcepath</code> attribute. Used by Ant. * * @param input The value of <code>sourcepath</code>. */ def setSourcepath(input: Path) = if (sourcepath.isEmpty) sourcepath = Some(input) else sourcepath.get.append(input) /** Sets the <code>sourcepath</code> as a nested sourcepath Ant parameter. * * @return A source path to be configured. */ def createSourcepath(): Path = { if (sourcepath.isEmpty) sourcepath = Some(new Path(getProject())) sourcepath.get.createPath() } /** Sets the <code>sourcepath</code> as an external reference Ant parameter. * * @param input A reference to a source path. */ def setSourcepathref(input: Reference) = createSourcepath().setRefid(input) /** Sets the <code>bootclasspath</code> attribute. Used by Ant. * * @param input The value of <code>bootclasspath</code>. */ def setBootclasspath(input: Path) = if (bootclasspath.isEmpty) bootclasspath = Some(input) else bootclasspath.get.append(input) /** Sets the <code>bootclasspath</code> as a nested sourcepath Ant * parameter. * * @return A source path to be configured. */ def createBootclasspath(): Path = { if (bootclasspath.isEmpty) bootclasspath = Some(new Path(getProject())) bootclasspath.get.createPath() } /** Sets the <code>bootclasspath</code> as an external reference Ant * parameter. * * @param input A reference to a source path. */ def setBootclasspathref(input: Reference) = createBootclasspath().setRefid(input) /** Sets the external extensions path attribute. Used by Ant. * * @param input The value of <code>extdirs</code>. */ def setExtdirs(input: Path): Unit = if (extdirs.isEmpty) extdirs = Some(input) else extdirs.get.append(input) /** Sets the <code>extdirs</code> as a nested sourcepath Ant parameter. * * @return An extensions path to be configured. */ def createExtdirs(): Path = { if (extdirs.isEmpty) extdirs = Some(new Path(getProject())) extdirs.get.createPath() } /** Sets the <code>extdirs</code> as an external reference Ant parameter. * * @param input A reference to an extensions path. */ def setExtdirsref(input: Reference) = createExtdirs().setRefid(input) /** Sets the <code>encoding</code> attribute. Used by Ant. * * @param input The value of <code>encoding</code>. */ def setEncoding(input: String): Unit = encoding = Some(input) /** Sets the <code>windowtitle</code> attribute. * * @param input The value of <code>windowtitle</code>. */ def setWindowtitle(input: String): Unit = windowtitle = Some(input) /** Sets the <code>doctitle</code> attribute. * * @param input The value of <code>doctitle</code>. */ def setDoctitle(input: String): Unit = doctitle = Some(input) /** Sets the <code>stylesheetfile</code> attribute. * * @param input The value of <code>stylesheetfile</code>. */ def setStylesheetfile(input: String): Unit = stylesheetfile = Some(input) /** Sets the <code>header</code> attribute. * * @param input The value of <code>header</code>. */ def setHeader(input: String): Unit = pageheader = Some(input) /** Sets the <code>footer</code> attribute. * * @param input The value of <code>footer</code>. */ def setFooter(input: String): Unit = pagefooter = Some(input)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?