From f6e0e4fc2e779af83f2e4a27402991a107d727e4 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Thu, 22 Dec 2016 14:44:56 +0100 Subject: Make dottydoc main available for Java instances --- doc-tool/src/dotty/tools/dottydoc/DottyDoc.scala | 2 +- doc-tool/src/dotty/tools/dottydoc/Main.scala | 5 +++ .../dotty/tools/dottydoc/api/java/Dottydoc.java | 9 +++-- .../dotty/tools/dottydoc/api/scala/Dottydoc.scala | 45 +++++++++++----------- 4 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 doc-tool/src/dotty/tools/dottydoc/Main.scala (limited to 'doc-tool') diff --git a/doc-tool/src/dotty/tools/dottydoc/DottyDoc.scala b/doc-tool/src/dotty/tools/dottydoc/DottyDoc.scala index 0dea96134..b7d3e4d58 100644 --- a/doc-tool/src/dotty/tools/dottydoc/DottyDoc.scala +++ b/doc-tool/src/dotty/tools/dottydoc/DottyDoc.scala @@ -49,7 +49,7 @@ class DocFrontEnd extends FrontEnd { unit.isJava } -abstract class DocDriver extends Driver { +class DocDriver extends Driver { import scala.collection.JavaConverters._ override def setup(args: Array[String], rootCtx: Context): (List[String], Context) = { diff --git a/doc-tool/src/dotty/tools/dottydoc/Main.scala b/doc-tool/src/dotty/tools/dottydoc/Main.scala new file mode 100644 index 000000000..f158bdbfc --- /dev/null +++ b/doc-tool/src/dotty/tools/dottydoc/Main.scala @@ -0,0 +1,5 @@ +package dotty.tools +package dottydoc + +/** Main runnable for DottyDoc */ +object Main extends DocDriver diff --git a/doc-tool/src/dotty/tools/dottydoc/api/java/Dottydoc.java b/doc-tool/src/dotty/tools/dottydoc/api/java/Dottydoc.java index 1bdfe0488..d10e145a8 100644 --- a/doc-tool/src/dotty/tools/dottydoc/api/java/Dottydoc.java +++ b/doc-tool/src/dotty/tools/dottydoc/api/java/Dottydoc.java @@ -30,20 +30,21 @@ import java.net.URL; * The tool can also generate JSON from the created index using "toJson(index)" * or directly using "createJsonIndex" */ -public class Dottydoc extends DocDriver { +public class Dottydoc { + private DocDriver driver = new DocDriver(); /** Creates index from compiler arguments */ public Map createIndex(String[] args) { - return compiledDocsJava(args); + return driver.compiledDocsJava(args); } /** Creates JSON from compiler arguments */ public String createJsonIndex(String[] args) { - return indexToJsonJava(createIndex(args)); + return driver.indexToJsonJava(createIndex(args)); } public String toJson(Map index) { - return indexToJsonJava(index); + return driver.indexToJsonJava(index); } /** Creates a documentation from the given parameters */ diff --git a/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala b/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala index 15db81a95..37f97040b 100644 --- a/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala +++ b/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala @@ -7,29 +7,28 @@ import dotty.tools.dottydoc.util.OutputWriter import scala.collection.Map import java.net.URL -/** - * The Dottydoc API is fairly simple. The tool creates an index by calling: - * "createIndex" with the same argument list as you would the compiler - e.g: - * - * {{{ - * val array: Array[String] = Array( - * "-language:Scala2" - * ) - * - * val index: Map[String, Package] = createIndex(array) - * }}} - * - * Once the index has been generated, the tool can also build a documentation - * API given a Mustache template and a flat resources structure (i.e. absolute - * paths to each resource, which will be put in the same directory). - * - * {{{ - * buildDocs("path/to/output/dir", templateURL, resources, index) - * }}} - * - * The tool can also generate JSON from the created index using "indexToJson" - * or directly using "createJsonIndex" - */ +/** The Dottydoc API is fairly simple. The tool creates an index by calling: + * `createIndex` with the same argument list as you would the compiler - e.g: + * + * ```scala + * val array: Array[String] = Array( + * "-language:Scala2" + * ) + * + * val index: Map[String, Package] = createIndex(array) + * ``` + * + * Once the index has been generated, the tool can also build a documentation + * API given a Mustache template and a flat resources structure (i.e. absolute + * paths to each resource, which will be put in the same directory). + * + * ```scala + * buildDocs("path/to/output/dir", templateURL, resources, index) + * ``` + * + * The tool can also generate JSON from the created index using `indexToJson` + * or directly using `createJsonIndex` + */ trait Dottydoc extends DocDriver { /** Creates index from compiler arguments */ def createIndex(args: Array[String]): Map[String, Package] = -- cgit v1.2.3