diff options
author | michelou <michelou@epfl.ch> | 2006-06-07 09:07:33 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-06-07 09:07:33 +0000 |
commit | 0ab820501a2cd3a3fac90fdd4dea1a432d49de9e (patch) | |
tree | 56e186baec4f829c94886180b280de13cbea1fbc /docs/man/src | |
parent | 95ff3d2928f8d1dc2a7a5e77595b80088496eeba (diff) | |
download | scala-0ab820501a2cd3a3fac90fdd4dea1a432d49de9e.tar.gz scala-0ab820501a2cd3a3fac90fdd4dea1a432d49de9e.tar.bz2 scala-0ab820501a2cd3a3fac90fdd4dea1a432d49de9e.zip |
added Scala project to build HTML and man pages
Diffstat (limited to 'docs/man/src')
-rw-r--r-- | docs/man/src/man/EmitHtml.scala | 347 | ||||
-rw-r--r-- | docs/man/src/man/EmitManPage.scala | 163 | ||||
-rw-r--r-- | docs/man/src/man/ManPage.scala | 68 | ||||
-rw-r--r-- | docs/man/src/man/man1/Command.scala | 45 | ||||
-rw-r--r-- | docs/man/src/man/man1/scala.scala | 146 | ||||
-rw-r--r-- | docs/man/src/man/man1/scalac.scala | 313 | ||||
-rw-r--r-- | docs/man/src/man/man1/scaladoc.scala | 108 | ||||
-rw-r--r-- | docs/man/src/man/man1/scalaint.scala | 67 | ||||
-rw-r--r-- | docs/man/src/man/man1/scalascript.scala | 100 |
9 files changed, 1357 insertions, 0 deletions
diff --git a/docs/man/src/man/EmitHtml.scala b/docs/man/src/man/EmitHtml.scala new file mode 100644 index 0000000000..d0257e0144 --- /dev/null +++ b/docs/man/src/man/EmitHtml.scala @@ -0,0 +1,347 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + * Adapted from Lex Spoon's sbaz manual + */ +//$Id: $ + +package man + +object EmitHtml { + import scala.xml.{Node, NodeBuffer, NodeSeq, XML} + import ManPage._ + + val out = Console + + def escape(text: String) = + text.replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + +/* */ + def emitSection(section: Section, depth: int): Unit = { + def emitText(text: AbstractText): Unit = + text match { + case seq:SeqText => + seq.components.foreach(emitText) + + case Text(text) => + out.print(escape(text)) + + case MDash => + out.print("—") + + case NDash => + out.print("–") + + case Bold(text) => + out.print("<b>") + emitText(text) + out.print("</b>") + + case Italic(text) => + out.print("<i>") + emitText(text) + out.print("</i>") + + case Emph(text) => + out.print("<em>") + emitText(text) + out.print("</em>") + + case Mono(text) => + out.print("<code>") + emitText(text) + out.print("</code>") + + case Quote(text) => + out.print("\"") + emitText(text) + out.print("\"") + + case DefinitionList(definitions @ _*) => + out.println("<ins><dl>") + for (val d <- definitions) { + out.println("<dt>") + emitText(d.term) + out.println("\n</dt>") + out.println("<dd>") + emitText(d.description) + out.println("</dd>") + } + out.println("</dl></ins>") + + case Link(label, url) => + out.print("<a href=\"" + url + "\">") + emitText(label) + out.print("</a>") + + case _ => + error("unknown text node " + text) + } + + def emitParagraph(para: Paragraph): Unit = + para match { + case TextParagraph(text) => + out.println("<p>") + emitText(text) + out.println("</p>") + + case BlockQuote(text) => + out.println("<blockquote><p>") + emitText(text) + out.println("</p></blockquote>") + + case CodeSample(text) => + out.print("<pre>") + out.print(escape(text)) + out.println("</pre>") + + case lst:BulletList => + out.println("<ul>") + for (val item <- lst.items) { + out.print("<li>") + emitText(item) + out.println("</li>") + } + out.println("</ul>") + + case lst:NumberedList => + out.println("<ol>") + for(val item <- lst.items) { + out.print("<li>") + emitText(item) + } + out.println("</ol>") + + case TitledPara(title, text) => + out.println("<p><strong>" + escape(title) + "</strong></p>") + emitText(text) + + case EmbeddedSection(sect) => + emitSection(sect, depth + 1) + + case _ => + error("unknown paragraph node " + para) + } + + val name = section.title.replaceAll("\\p{Space}", "_").toLowerCase() + out.println("\n<h" + depth + " id=\"" + name + "\">" + + section.title + + "</h" + depth + ">") + section.paragraphs.foreach(emitParagraph) + } + + private def emit3columns(col1: String, col2: String, col3: String) = { + out.println("<div style=\"float:left;\">") + out.println(col1) + out.println("</div>") + out.println("<div style=\"float:right;\">") + out.println(col3) + out.println("</div>") + out.println("<div style=\"text-align:center;\">") + out.println(col2) + out.println("</div>") + } + + private def emitHeader(col1: String, col2: String, col3: String) = { + out.println("<!-- header -->") + out.println("<div style=\"margin: 0 0 2em 0;\">") + emit3columns(col1, col2, col3) + out.println("</div>") + } + + private def emitFooter(col1: String, col2: String, col3: String) = { + out.println("<!-- footer -->") + out.println("<div style=\"margin: 2em 0 0 0;\">") + emit3columns(col1, col2, col3) + out.println("</div>") + } + + def emitDocument(document: Document, addDocType: Boolean) = { + if (addDocType) { + out.println("<?xml version=\"1.1\" encoding=\"" + document.encoding + "\"?>") + out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">") + } + out.println("<html xml:lang=\"en\">") + + out.println("<head>") + out.println("<title>" + document.title + " man page</title>") + out.println("<meta http-equiv=\"Content-Language\" content=\"en\"/>") + out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + + document.encoding + "\"/>") + out.println("<meta name=\"Author\" content=\"" + document.author + "\"/>") + out.println("<style type=\"text/css\">") + out.println(" <!--") + out.println(" blockquote, pre { margin:1em 4em 1em 4em; }") + out.println(" p { margin:0 2em 0 2em; text-align:justify; }") + out.println(" //-->") + out.println("</style>") + out.println("</head>") + + out.println("<body>") + val name = document.title + "(" + document.category.id + ")" + emitHeader(name, "" + document.category, name) + + document.sections.foreach(s => emitSection(s, 3)) + + emitFooter("version " + document.version, document.date, name) + + out.println("</body>") + out.println("</html>") + } +/* */ +/* + private def group(ns: Iterable[NodeSeq]): NodeSeq = { + val zs = new NodeBuffer + for (val z <- ns) { zs &+ z } + zs + } + + def emitSection(section: Section, depth: int): NodeSeq = { + def emitText(text: AbstractText): NodeSeq = text match { + case seq:SeqText => + group(seq.components.toList.map(item => emitText(item))) + + case Text(text) => + scala.xml.Text(escape(text)) + + case MDash => + scala.xml.Text("—") + + case NDash => + scala.xml.Text("–") + + case Bold(text) => + <b>{emitText(text)}</b> + + case Italic(text) => + <i>{emitText(text)}</i> + + case Emph(text) => + <em>{emitText(text)}</em> + + case Mono(text) => + <code>{emitText(text)}</code> + + case Quote(text) => + emitText("\"" & text & "\"") + + case DefinitionList(definitions @ _*) => + <ins><dl> + {definitions.toList.map(d => + <dt>{emitText(d.term)}</dt> + <dd>{emitText(d.description)}</dd> + )} + </dl></ins> + + case Link(label, url) => + <a href={url}>{emitText(label)}</a> + + case _ => + error("unknown text node " + text) + } + + def emitParagraph(para: Paragraph): NodeSeq = para match { + case TextParagraph(text) => + <p>{emitText(text)}</p> + + case BlockQuote(text) => + <blockquote>{emitText(text)}</blockquote> + + case CodeSample(text) => + <blockquote><pre>{escape(text)}</pre></blockquote> + + case lst:BulletList => + <ul> + {lst.items.toList.map(item => <li>{emitText(item)}</li>)} + </ul> + + case lst:NumberedList => + <ol> + {lst.items.toList.map(item => <li>{emitText(item)}</li>)} + </ol> + + case TitledPara(title, text) => + <p><strong>{escape(title)}</strong></p> + {emitText(text)} + + case EmbeddedSection(sect) => + {emitSection(sect, depth + 1)} + + case _ => + error("unknown paragraph node " + para) + } + + val name = section.title.replaceAll("\\p{Space}", "_").toLowerCase() + <h3 id={name}>{section.title}</h3>.concat( + group(section.paragraphs.toList.map(p => emitParagraph(p)))) + } + + private def emit3columns(col1: String, col2: String, col3: String): NodeSeq = + <div style="float:left;">{col1}</div> + <div style="float:right;">{col3}</div> + <div style="text-align:center;">{col2}</div> + <div style="clear:both;"></div> + + private def emitHeader(col1: String, col2: String, col3: String): NodeSeq = + <div style="margin: 0 0 2em 0;"> + {emit3columns(col1, col2, col3)} + </div> + + private def emitFooter(col1: String, col2: String, col3: String): NodeSeq = { + scala.xml.Comment("footer") + <div style="margin: 2em 0 0 0;"> + {emit3columns(col1, col2, col3)} + </div> + } + + def emitDocument(document: Document, addDocType: Boolean) = { + val name = document.title + "(" + document.category.id + ")" + val doc = + <html xml:lang="en"> + <head> + <title>{document.title}</title> + <meta http-equiv="Content-Language" content="en"/> + <meta http-equiv="Content-Type" content={"text/html; charset=" + document.encoding}/> + <meta name="Author" content={document.author}/> + <style type="text/css"> + {" blockquote, pre { margin:1em 4em 1em 4em; }\n" + + " p { margin:1em 2em 1em 2em; text-align:justify; }\n"} + </style> + </head> + <body> + {emitHeader(name, "" + document.category, name)} + {document.sections.map(s => emitSection(s, 2))} + {emitFooter("version " + document.version, document.date, name)} + </body> + </html> + out.println(doc) +/* + val w = new java.io.StringWriter + val id = scala.xml.dtd.PublicID("PUBLIC", null) + val dtd = null //scala.xml.dtd.DEFAULT(true, "") + val doctype = scala.xml.dtd.DocType("html", id, null) //List(dtd)) + XML.write(w, doc, document.encoding, true/ *xmlDecl* /, doctype) + out.println(w.toString()) +*/ + } +*/ + def main(args: Array[String]) = { + if (args.length < 1) { + System.err.println("usage: EmitHtml <classname> [ -short ]") + exit(1) + } + try { + val cl = ClassLoader.getSystemClassLoader() + val clasz = cl.loadClass("man.man1." + args(0)) + val meth = clasz.getDeclaredMethod("manpage", Array[Class]()) + val doc = meth.invoke(null, Array[Object]()).asInstanceOf[Document] + val addDocType = (args.length > 1 && "-doctype".equals(args(1))) + emitDocument(doc, addDocType) + } catch { + case e: Exception => + System.err.println(e.getMessage()) + } + } +} diff --git a/docs/man/src/man/EmitManPage.scala b/docs/man/src/man/EmitManPage.scala new file mode 100644 index 0000000000..1cc05ef8e2 --- /dev/null +++ b/docs/man/src/man/EmitManPage.scala @@ -0,0 +1,163 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + * Adapted from Lex Spoon's sbaz manual + */ +//$Id: $ + +package man + +// For help on man pages see: +// - http://www.linuxfocus.org/English/November2003/article309.shtml +// - http://www.schweikhardt.net/man_page_howto.html + +object EmitManPage { + import ManPage._ + + val out = Console + + def escape(text: String) = + text.replaceAll("-", "\\-") + + def emitSection(section: Section, depth: int): Unit = { + def emitText(text: AbstractText): Unit = + text match { + case seq:SeqText => + seq.components.foreach(emitText) + + case Text(text) => + out.print(escape(text)) + + case NDash | MDash => + out.print("\\-") + + case Bold(text) => + out.print("\\fB") + emitText(text) + out.print("\\fR") + + case Italic(text) => + out.print("\\fI") + emitText(text) + out.print("\\fR") + + case Emph(text) => + out.print("\\fI") + emitText(text) + out.print("\\fI") + + case Mono(text) => + out.print("") + emitText(text) + out.print("") + + case Quote(text) => + out.print("\"") + emitText(text) + out.print("\"") + + case DefinitionList(definitions @ _*) => + var n = definitions.length + for (val d <- definitions) { + out.println(".TP") + emitText(d.term) + out.println + emitText(d.description) + if (n > 1) { out.println; n = n - 1 } + } + + case Link(label, url) => + emitText(label) + + case _ => + error("unknown text node " + text) + } + + def emitParagraph(para: Paragraph): Unit = + para match { + case TextParagraph(text) => + out.println(".PP") + emitText(text) + out.println + + case BlockQuote(text) => + out.println(".TP") + emitText(text) + out.println + + case CodeSample(text) => + out.println("\n.nf") + out.print(text) + out.println(".fi") + + case lst:BulletList => + out.println("<ul>") + for(val item <- lst.items) { + out.print("<li>") + emitText(item) + } + out.println("</ul>") + + case lst:NumberedList => + out.println("<ol>") + for(val item <- lst.items) { + out.print("<li>") + emitText(item) + } + out.println("</ol>") + + case TitledPara(title, text) => + out.println("<p><strong>" + escape(title) + "</strong>") + emitText(text) + + case EmbeddedSection(sect) => + emitSection(sect, depth+1) + + case _ => + error("unknown paragraph node " + para) + } + + out.println(".\\\"") + out.println(".\\\" ############################## " + section.title + " ###############################") + out.println(".\\\"") + val tag = if (depth > 1) ".SS" else ".SH" + val title = + if (section.title.indexOf(" ") > 0) "\"" + section.title + "\"" + else section.title + out.println(tag + " " + title) + + section.paragraphs.foreach(emitParagraph) + } + + def emitDocument(doc: Document) = { + out.println(".\\\" ##########################################################################") + out.println(".\\\" # __ #") + out.println(".\\\" # ________ ___ / / ___ Scala 2 On-line Manual Pages #") + out.println(".\\\" # / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL #") + out.println(".\\\" # __\\ \\/ /__/ __ |/ /__/ __ | #") + out.println(".\\\" # /____/\\___/_/ |_/____/_/ | | http://scala.epfl.ch/ #") + out.println(".\\\" # |/ #") + out.println(".\\\" ##########################################################################") + out.println(".\\\"") + out.println(".\\\" Process this file with nroff -man scala.1") + out.println(".\\\"") + out.println(".TH " + doc.title + " " + doc.category.id + + " \"" + doc.date + "\" \"version " + doc.version + + "\" \"" + doc.category + "\"") + + doc.sections.foreach(s => emitSection(s, 1)) + } + + def main(args: Array[String]) = + try { + val cl = ClassLoader.getSystemClassLoader() + val clasz = cl.loadClass("man.man1." + args(0)) + val meth = clasz.getDeclaredMethod("manpage", Array[Class]()) + val doc = meth.invoke(null, Array[Object]()).asInstanceOf[Document] + emitDocument(doc) + } catch { + case e: Exception => + System.err.println(e.getMessage()) + } + +} diff --git a/docs/man/src/man/ManPage.scala b/docs/man/src/man/ManPage.scala new file mode 100644 index 0000000000..38d26c7938 --- /dev/null +++ b/docs/man/src/man/ManPage.scala @@ -0,0 +1,68 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + * Adapted from Lex Spoon's sbaz manual + */ +//$Id: $ + +package man + +object ManPage { + abstract class AbstractText { + def &(more: AbstractText) = SeqText(this, more) + } + + case class SeqText(components: AbstractText*) extends AbstractText + case class Text(text: String) extends AbstractText + case object MDash extends AbstractText + case object NDash extends AbstractText + case class Bold(contents: AbstractText) extends AbstractText + case class Italic(contents: AbstractText) extends AbstractText + case class Emph(contents: AbstractText) extends AbstractText + case class Mono(contents: AbstractText) extends AbstractText + case class Quote(contents: AbstractText) extends AbstractText + implicit def str2text(str: String) = Text(str) + + case class Definition(term: AbstractText, description: AbstractText) + case class DefinitionList(definitions: Definition*) extends AbstractText + case class Link(label: AbstractText, url: String) extends AbstractText + + case class DefnItem(header: String, text: AbstractText) + + abstract class Paragraph + case class TextParagraph(text: AbstractText) extends Paragraph + case class CodeSample(text: String) extends Paragraph + case class BlockQuote(text: AbstractText) extends Paragraph + implicit def text2para(text: AbstractText): Paragraph = TextParagraph(text) + implicit def str2para(str: String) = text2para(str2text(str)) + + case class BulletList(items: AbstractText*) extends Paragraph + case class NumberedList(items: AbstractText*) extends Paragraph + case class TitledPara(title: String, text: AbstractText) extends Paragraph + + case class EmbeddedSection(section: Section) extends Paragraph + implicit def section2Para(section: Section) = EmbeddedSection(section) + + case class Section(title: String, paragraphs: Paragraph*) + + object Category extends Enumeration { + val USER_COMMANDS = Value(1, "USER COMMANDS") + val SYSTEM_CALLS = Value(2, "SYSTEM CALLS") + val SUBROUTINES = Value(3, "SUBROUTINES") + val DEVICES = Value(4, "DEVICES") + val FILE_FORMATS = Value(5, "FILE FORMAT DESCRIPTIONS") + val GAMES = Value(6, "GAMES") + val MISCELLANEOUS = Value(7, "MISCELLANEOUS") + } + + abstract class Document { + import Category._ + var title: String = "" + var author: String = "" + var date: String = "" + var version: String = "" + var category: Value = USER_COMMANDS + var encoding: String = "iso-8859-1" + var sections: List[Section] = Nil + } +} diff --git a/docs/man/src/man/man1/Command.scala b/docs/man/src/man/man1/Command.scala new file mode 100644 index 0000000000..bfb6944e72 --- /dev/null +++ b/docs/man/src/man/man1/Command.scala @@ -0,0 +1,45 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +trait Command { + import ManPage._ + + protected val cn: String + val command = cn.substring(cn.lastIndexOf(".") + 1, cn.length() - 1) + + protected def MBold(contents: AbstractText) = Mono(Bold(contents)) + protected def MItalic(contents: AbstractText) = Mono(Italic(contents)) + + protected def CmdLine(opts: AbstractText) = + MBold(command) & Mono(" " & opts) + + protected def CmdOption(opt: String, params: AbstractText) = + Mono(Bold(NDash & opt) & " " & params & " ") + + protected def CmdOption(opt: String): AbstractText = + CmdOption(opt, "") + + protected def Argument(arg: String): AbstractText = + "<" & Italic(arg) & ">" + + def authors = Section("AUTHOR", + + "Written by Stephane Micheloud.") + + def copyright = Section("COPYRIGHT", + + "This is free software; see the distribution for copying conditions. " & + "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A " & + "PARTICULAR PURPOSE.") + + def bugs = Section("REPORTING BUGS", + + "Report bugs to " & Mono("<scala@listes.epfl.ch>") & ".") + + def manpage: Document +} diff --git a/docs/man/src/man/man1/scala.scala b/docs/man/src/man/man1/scala.scala new file mode 100644 index 0000000000..29dde567de --- /dev/null +++ b/docs/man/src/man/man1/scala.scala @@ -0,0 +1,146 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +object scala extends Command { + import ManPage._ + + protected val cn = new Error().getStackTrace()(0).getClassName() + + val name = Section("NAME", + + MBold(command) & " " & NDash & " Launcher for the " & + Link("Scala 2", "http://scala.epfl.ch/") & " language") + + val synopsis = Section("SYNOPSIS", + + CmdLine(" [ " & Argument("options") & " ] " & + Argument("class file") & " [ " & Argument("args") & " ]")) + + val parameters = Section("PARAMETERS", + + DefinitionList( + Definition( + Mono(Argument("options")), + "Command line options. See " & Link(Bold("OPTIONS"), "#options") & + " below."), + Definition( + Mono(Argument("class file")), + "Name of the class to be invoked."), + Definition( + Mono(Argument("args")), + "Program arguments passed to the main function."))) + + val description = Section("DESCRIPTION", + + "The " & MBold(command) & " utility launches a Scala application. " & + "It does this by starting a Java runtime environment, loading a " & + "specified class, and invoking that class's " & Bold("main") & + " method. The method must have the following signature:", + + BlockQuote(Mono(Bold("def") & " main(args: Array[String]): Unit")), + + "The method must return a " & Bold("Unit") & " value, and it must " & + "accept a " & Bold("String") & " array as a parameter. By default, " & + "the first non-option argument is the name of the class to be invoked. "& + "A fully-qualified class name should be used.", + + "The Scala runtime searches for the startup class, and other classes " & + "used, in three sets of locations: the bootstrap class path, the " & + "installed extensions, and the user class path.") + + val options = Section("OPTIONS", + + "The launcher has a set of standard options that are supported on the " & + "current runtime environment and will be supported in future releases. " & + "An additional set of non-standard options are specific to the current " & + "virtual machine implementation and are subject to change in the future. " & + "Non-standard options begin with " & CmdOption("X") & ".", + + Section("Standard Options", + DefinitionList( + Definition( + CmdOption("cp") & "| " & CmdOption("classpath", Argument("path")), + "Specify where to find user class files (on Unix-based systems " & + "a colon-separated list of paths, on Windows-based systems, a " & + "semicolon-separate list of paths)."), + Definition( + CmdOption("D", Argument("name") & "=" & Argument("value")), + "Set a system property."), + Definition( + CmdOption("verbose", "[:class|gc|jni]"), + "Enable verbose output."), + Definition( + CmdOption("showversion"), + "Print product version and continue."), + Definition( + CmdOption("version"), + "Print product version and exit."), + Definition( + CmdOption("help"), + "Print this help message."))), + + Section("Non-Standard Options", + "Same options as the " & MBold("java") & " command.")) + + val environment = Section("ENVIRONMENT", + + DefinitionList( + Definition( + MBold("JAVACMD"), + "Specify the " & MBold("java") & " command to be used " & + "for running the Scala commands"))) + + val examples = Section("EXAMPLES", + + DefinitionList( + Definition( + "Execute a Scala program generated in the current directory", + CmdLine("hello.HelloWorld")), + Definition( + "Execute a Scala program generated in a user-defined " & + "directory " & Bold("classes"), + CmdLine(CmdOption("classpath", "classes") & "hello.HelloWorld")), + Definition( + "Execute a Scala program using a user-defined " & MBold("java") & " " & + "command", + MBold("env JAVACMD") & Mono("=/usr/local/bin/cacao ") & + CmdLine(CmdOption("classpath", "classes") & "hello.HelloWorld")))) + + val exitStatus = Section("EXIT STATUS", + + MBold(command) & " returns a zero exit status if it succeeds. " & + "Non zero is returned in case of failure.") + + val seeAlso = Section("SEE ALSO", + + Link(Bold("scalac") & "(1)", "scalac.html") & ", " & + Link(Bold("scaladoc") & "(1)", "scaladoc.html") & ", " & + Link(Bold("scalaint") & "(1)", "scalaint.html") & ", " & + Link(Bold("scalascript") & "(1)", "scalascript.html")) + + def manpage = new Document { + title = command + date = "April 29, 2005" + author = "Stephane Micheloud" + version = "0.1" + sections = List( + name, + synopsis, + parameters, + description, + options, + environment, + examples, + exitStatus, + authors, + bugs, + copyright, + seeAlso) + } +} + diff --git a/docs/man/src/man/man1/scalac.scala b/docs/man/src/man/man1/scalac.scala new file mode 100644 index 0000000000..21af878758 --- /dev/null +++ b/docs/man/src/man/man1/scalac.scala @@ -0,0 +1,313 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +object scalac extends Command { + import ManPage._ + + protected val cn = new Error().getStackTrace()(0).getClassName() + + val name = Section("NAME", + + MBold(command) & " " & NDash & " Compiler for the " & + Link("Scala 2", "http://scala.epfl.ch/") & " language") + + val synopsis = Section("SYNOPSIS", + + CmdLine(" [ " & Argument("options") & " ] " & + Argument("source files"))) + + val parameters = Section("PARAMETERS", + + DefinitionList( + Definition( + Mono(Argument("options")), + "Command line options. See " & Link(Bold("OPTIONS"), "#options") & + " below."), + Definition( + Mono(Argument("source files")), + "One or more source files to be compiled (such as " & + Mono("MyClass.scala") & ")."))) + + val description = Section("DESCRIPTION", + + "The " & MBold(command) & " tool reads class and object definitions, " & + "written in the Scala programming language, and compiles them into " & + "bytecode class files.", + + "By default, the compiler puts each class file in the same directory " & + "as its source file. You can specify a separate destination directory " & + "with -d (see " & Link(Bold("OPTIONS"), "#options") & ", below).") + + val options = Section("OPTIONS", + + "The compiler has a set of standard options that are supported on the " & + "current development environment and will be supported in future " & + "releases. An additional set of non-standard options are specific to " & + "the current virtual machine implementation and are subject to change " & + "in the future. Non-standard options begin with " & Bold("-X") & ".", + + Section("Standard Options", + DefinitionList( + Definition( + CmdOption("g"), + "Generate debugging info"), + Definition( + CmdOption("nowarn"), + "Generate no warnings"), + Definition( + CmdOption("verbose"), + "Output messages about what the compiler is doing"), + Definition( + CmdOption("classpath", Argument("path")), + "Specify where to find user class files (on Unix-based systems " & + "a colon-separated list of paths, on Windows-based systems, a " & + "semicolon-separate list of paths). This does not override the " & + "built-in (" & Mono("\"boot\"") & ") search path."), + Definition( + CmdOption("sourcepath", Argument("path")), + "Specify where to find input source files."), + Definition( + CmdOption("bootclasspath", Argument("path")), + "Override location of bootstrap class files (where to find the " & + "standard built-in classes, such as \"" & Mono("scala.List") & "\")."), + Definition( + CmdOption("extdirs", Argument("dirs")), + "Override location of installed extensions."), + Definition( + CmdOption("d", Argument("directory")), + "Specify where to place generated class files."), + Definition( + CmdOption("encoding", Argument("encoding")), + "Specify character encoding used by source files."), + Definition( + CmdOption("target:", Argument("target")), + "Specify which backend to use (" & Mono(Italic("jvm-1.5") & ", " & + Italic("jvm-1.4") & ", " & Italic("msil") & ", " & Italic("cldc")) & + ")."), + Definition( + CmdOption("migrate"), + "Assist in migrating from Scala version 1.0."), + Definition( + CmdOption("statistics"), + "Print compiler statistics."), + Definition( + CmdOption("resident"), + "Compiler stays resident, files to compile are read from standard " & + "input."), + Definition( + CmdOption("version"), + "Print product version and exit."), + Definition( + CmdOption("?") & "| " & CmdOption("help"), + "Print a synopsis of standard options."))), + + Section("Non-Standard Options", + DefinitionList( + Definition( + CmdOption("Xinline"), + "Perform inlining when possible."), + Definition( + CmdOption("Xcloselim"), + "Perform closure elimination."), + Definition( + CmdOption("Xshowcls", Argument("class")), + "Show class info."), + Definition( + CmdOption("Xshowobj", Argument("object")), + "Show object info."), + Definition( + CmdOption("Xshowicode"), + "Print the generated ICode."), + Definition( + CmdOption("Xgadt"), + "Enable gadt for classes."), + Definition( + CmdOption("Xlinearizer", Argument("Xlinearizer")), + "Linearizer to use (" & Mono("normal,dfs,rpo") & ")."), + Definition( + CmdOption("Xgenerics"), + "Use generic Java types."))), + + Section("Debug Options", + DefinitionList( + Definition( + CmdOption("debug"), + "Output debugging messages."), + Definition( + CmdOption("explaintypes"), + "Explain type errors in more detail."), + Definition( + CmdOption("uniqid"), + "Print identifiers with unique names (debugging option)."), + Definition( + CmdOption("printtypes"), + "Print tree types (debugging option)."), + Definition( + CmdOption("prompt"), + "Display a prompt after each error (debugging option)."), + Definition( + CmdOption("noimports"), + "Compile without any implicit imports."), + Definition( + CmdOption("nopredefs"), + "Compile without any implicit predefined values."), + Definition( + CmdOption("skip:", Argument("phases")), + "Skip " & Argument("phases") & " (see below)."), + Definition( + CmdOption("check:", Argument("phases")), + "Check the tree after " & Argument("phases") & " (see below)."), + Definition( + CmdOption("print:", Argument("phases")), + "Print out program after " & Argument("phases") & " (see below)."), + Definition( + CmdOption("printer:", Argument("printer")), + "Printer to use."), + Definition( + CmdOption("print-file", Argument("file")), + "Specify file in which to print trees."), + Definition( + CmdOption("graph:", Argument("phases")), + "Graph the program after " & Argument("phases") & " (see below)."), + Definition( + CmdOption("stop:", Argument("phases")), + "Stop after first phase in " & Argument("phases") & " (see below)."), + Definition( + CmdOption("log:", Argument("phases")), + "Log operations in " & Argument("phases") & " (see below)."))), + + Section("Compilation Phases", + DefinitionList( + Definition( + MItalic("initial"), + "initializing compiler"), + Definition( + MItalic("parse"), + "parse source files"), + Definition( + MItalic("namer"), + "create symbols"), + Definition( + MItalic("analyze"), + "name and type analysis"), + Definition( + MItalic("refcheck"), + "reference checking"), + Definition( + MItalic("uncurry"), + "uncurry function types and applications"), + Definition( + MItalic("transmatch"), + "translate match expressions"), + Definition( + MItalic("lambdalift"), + "lambda lifter"), + Definition( + MItalic("typesasvalues"), + "represent types as values"), + Definition( + MItalic("addaccessors"), + "add accessors for constructor arguments"), + Definition( + MItalic("explicitouterclasses"), + "make links from inner classes to enclosing one explicit"), + Definition( + MItalic("addconstructors"), + "add explicit constructor for each class"), + Definition( + MItalic("tailcall"), + "add tail-calls"), + Definition( + MItalic("wholeprog"), + "perform whole program analysis"), + Definition( + MItalic("addinterfaces"), + "add one interface per class"), + Definition( + MItalic("expandmixins"), + "expand mixins by code copying"), + Definition( + MItalic("boxing"), + "makes boxing explicit"), + Definition( + MItalic("erasure"), + "type eraser"), + Definition( + MItalic("icode"), + "generate icode"), + Definition( + MItalic("codegen"), + "enable code generation"), + Definition( + MItalic("terminal"), + "compilation terminated"), + Definition( + MItalic("all"), + "matches all phases")))) + + val environment = Section("ENVIRONMENT", + + DefinitionList( + Definition( + MBold("JAVACMD"), + "Specify the " & MBold("java") & " command to be used " & + "for running the Scala commands"))) + + val examples = Section("EXAMPLES", + + DefinitionList( + Definition( + "Compile a Scala program to the current directory", + CmdLine("HelloWorld")), + Definition( + "Compile a Scala program to the destination directory " & + MBold("classes"), + CmdLine(CmdOption("d", "classes") & "HelloWorld.scala")), + Definition( + "Compile a Scala program using a user-defined " & MBold("java") & " " & + "command", + MBold("env JAVACMD") & Mono("=/usr/local/bin/cacao ") & + CmdLine(CmdOption("d", "classes") & "HelloWorld.scala")), + Definition( + "Compile all Scala files found in the source directory " & + MBold("src") & " to the destination directory " & + MBold("classes"), + CmdLine(CmdOption("d", "classes") & "src/*.scala")))) + + val exitStatus = Section("EXIT STATUS", + + MBold(command) & " returns a zero exist status if it succeeds to " & + "compile the specified input files. Non zero is returned in case " & + "of failure.") + + val seeAlso = Section("SEE ALSO", + + Link(Bold("scala") & "(1)", "scala.html") & ", " & + Link(Bold("scaladoc") & "(1)", "scaladoc.html") & ", " & + Link(Bold("scalaint") & "(1)", "scalaint.html") & ", " & + Link(Bold("scalascript") & "(1)", "scalascript.html")) + + def manpage = new Document { + title = command + date = "April 29, 2005" + author = "Stephane Micheloud" + version = "0.1" + sections = List( + name, + synopsis, + parameters, + options, + environment, + examples, + exitStatus, + authors, + bugs, + copyright, + seeAlso) + } +} diff --git a/docs/man/src/man/man1/scaladoc.scala b/docs/man/src/man/man1/scaladoc.scala new file mode 100644 index 0000000000..feb5d3435d --- /dev/null +++ b/docs/man/src/man/man1/scaladoc.scala @@ -0,0 +1,108 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +object scaladoc extends Command { + import ManPage._ + + protected val cn = new Error().getStackTrace()(0).getClassName() + + val name = Section("NAME", + + MBold(command) & " " & NDash & " Documentation generator for the " & + Link("Scala 2", "http://scala.epfl.ch/") & " language") + + val synopsis = Section("SYNOPSIS", + + CmdLine(" [ " & Argument("options") & " ] " & Argument("source files"))) + + val parameters = Section("PARAMETERS", + + DefinitionList( + Definition( + Mono(Argument("options")), + "Command line options. See " & Link(Bold("OPTIONS"), "#options") & + " below."), + Definition( + Mono(Argument("source files")), + "One or more source files to be compiled (such as " & + Mono("MyClass.scala") & ")."))) + + val description = Section("DESCRIPTION", + + "The " & MBold(command) & " tool reads class and object definitions, " & + "written in the Scala programming language, and generates their API as " & + "HTML files.", + + "By default, the generator puts each HTML file in the same directory as " & + "its source file. You can specify a separate destination directory with " & + CmdOption("d") & "(see " & Link(Bold("OPTIONS"), "#options") & ", below).") + + val options = Section("OPTIONS", + + "The generator has a set of standard options that are supported on the " & + "current development environment and will be supported in future releases.", + + Section("Standard Options", + DefinitionList( + Definition( + CmdOption("d", Argument("directory")), + "Specify where to place generated class files."), + Definition( + CmdOption("version"), + "Print product version and exit."), + Definition( + CmdOption("?") & "| " & CmdOption("help"), + "Print a synopsis of standard options.")))) + + val examples = Section("EXAMPLES", + + DefinitionList( + Definition( + "Generate documentation for a Scala program", + CmdLine("HelloWorld.scala")), + Definition( + "Generation documentation for a Scala program to the destination " & + "directory " & Bold("classes"), + CmdLine(CmdOption("d", "api") & "HelloWorld.scala")), + Definition( + "Generate documentation for all Scala files found in the source " & + "directory " & Bold("src") & " to the destination directory " & + Bold("api"), + CmdLine(CmdOption("d", "api") & "src/*.scala")))) + + val exitStatus = Section("EXIT STATUS", + + MBold(command) & " returns a zero exist status if it succeeds to process " & + "the specified input files. Non zero is returned in case of failure.") + + val seeAlso = Section("SEE ALSO", + + Link("scala(1)", "scala.html") & ", " & + Link("scalac(1)", "scalac.html") & ", " & + Link("scalaint(1)", "scalaint.html") & ", " & + Link("scalascript(1)", "scalascript.html")) + + def manpage = new Document { + title = command + date = "April 29, 2005" + author = "Stephane Micheloud" + version = "0.1" + sections = List( + name, + synopsis, + parameters, + description, + options, + examples, + exitStatus, + authors, + bugs, + copyright, + seeAlso) + } +} diff --git a/docs/man/src/man/man1/scalaint.scala b/docs/man/src/man/man1/scalaint.scala new file mode 100644 index 0000000000..35cb1fec0f --- /dev/null +++ b/docs/man/src/man/man1/scalaint.scala @@ -0,0 +1,67 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +object scalaint extends Command { + import ManPage._ + + protected val cn = new Error().getStackTrace()(0).getClassName() + + val name = Section("NAME", + + MBold(command) & " " & NDash & " Interpreter for the " & + Link("Scala 2", "http://scala.epfl.ch/") & " language") + + val synopsis = Section("SYNOPSIS", + + CmdLine(" [ " & Argument("source file") & " ]")) + + val parameters = Section("PARAMETERS", + + DefinitionList( + Definition( + Mono(Argument("source file")), + "One source file to be interpreted (such as " & + Mono("MyClass.scala") & ")."))) + + val description = Section("DESCRIPTION", + + "The " & MBold(command) & " tool reads class and object definitions, " & + "written in the Scala programming language, and interprets them in an " & + "interactive shell environment.") + + val examples = Section("EXAMPLES", + + DefinitionList( + Definition( + "Interpret a Scala program", + CmdLine("HelloWorld")))) + + val seeAlso = Section("SEE ALSO", + + Link(Bold("scala") & "(1)", "scala.html") & ", " & + Link(Bold("scalac") & "(1)", "scalac.html") & ", " & + Link(Bold("scaladoc") & "(1)", "scaladoc.html") & ", " & + Link(Bold("scalascript") & "(1)", "scalascript.html")) + + def manpage = new Document { + title = command + date = "April 29, 2005" + author = "Stephane Micheloud" + version = "0.1" + sections = List( + name, + synopsis, + parameters, + description, + examples, + authors, + bugs, + copyright, + seeAlso) + } +} diff --git a/docs/man/src/man/man1/scalascript.scala b/docs/man/src/man/man1/scalascript.scala new file mode 100644 index 0000000000..440f0d2b09 --- /dev/null +++ b/docs/man/src/man/man1/scalascript.scala @@ -0,0 +1,100 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL + * @author Stephane Micheloud + */ +//$Id: $ + +package man.man1 + +object scalascript extends Command { + import ManPage._ + + protected val cn = new Error().getStackTrace()(0).getClassName() + + val name = Section("NAME", + + MBold(command) & " " & NDash & " Script runner for the " & + Link("Scala 2", "http://scala.epfl.ch/") & " language") + + val synopsis = Section("SYNOPSIS", + + CmdLine(" [ " & Argument("compiler args...") & " - ] " & + Argument("scriptfile") & " [ " & Argument("script args...") & " ]")) + + val parameters = Section("PARAMETERS", + + DefinitionList( + Definition( + Mono(Argument("compiler args")), + "Compiler arguments, exactly as for " & MBold("scalac") & ". " & + "The compiler arguments, if present, must be terminated by a " & + "bare hyphen."), + Definition( + Mono(Argument("scriptfile")), + "One source file to be interpreted."), + Definition( + Mono(Argument("script args")), + "Arguments to be passed to the script. They will be available " & + "via the " & Mono("argv") & " variable."))) + + val description = Section("DESCRIPTION", + + "The " & MBold(command) & " tool supports writing script files " & + "in Scala. To write a Scala script on Unix, start the file with the " & + "following header:", + + CodeSample( + "#!/bin/sh\n" + + "exec scalascript \"$0\" \"$@\"\n" + + "!#\n"), + + "To write a Scala script as a Microsoft Windows batch file, start " & + "the " & Mono(".bat") & " file with the following header:", + + CodeSample( + "::#!\n" + + "@echo off\n" + + "call scalascript %0 %*\n" + + "goto :eof\n" + + "::!#\n")) + + val examples = Section("EXAMPLES", + + "Here is a complete Scala script for Unix that prints out a " & + "friendly greeting followed by all of the script's arguments:", + + CodeSample( + "#!/bin/sh\n" + + "exec scalascript \"$0\" \"$@\"\n" + + "!#\n" + + "Console.println(\"Hello, world!\")\n" + + "argv.toList foreach Console.println\n")) + + override val authors = Section("AUTHOR", + + "Written by Lex Spoon.") + + val seeAlso = Section("SEE ALSO", + + Link(Bold("scala") & "(1)", "scala.html") & ", " & + Link(Bold("scalac") & "(1)", "scalac.html") & ", " & + Link(Bold("scaladoc") & "(1)", "scaladoc.html") & ", " & + Link(Bold("scalaint") & "(1)", "scalaint.html")) + + def manpage = new Document { + title = command + date = "April 29, 2005" + author = "Stephane Micheloud" + version = "0.1" + sections = List( + name, + synopsis, + parameters, + description, + examples, + authors, + bugs, + copyright, + seeAlso) + } +} |