aboutsummaryrefslogtreecommitdiff
path: root/doc-tool
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-01-24 18:26:15 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-01-31 14:35:42 +0100
commit483ac5340db262adb5efcf747a97dc9f25bc0208 (patch)
treed18b2dd3b610564768ffd809b6f77023fe24ae7a /doc-tool
parent866e364dde76aa5df42548bf72d2f5c4d200535b (diff)
downloaddotty-483ac5340db262adb5efcf747a97dc9f25bc0208.tar.gz
dotty-483ac5340db262adb5efcf747a97dc9f25bc0208.tar.bz2
dotty-483ac5340db262adb5efcf747a97dc9f25bc0208.zip
Fix javadoc indentation style parsing
Diffstat (limited to 'doc-tool')
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala22
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/DocDriver.scala4
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala10
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala42
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala2
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/comment/CommentRegex.scala2
-rw-r--r--doc-tool/test/CommentCleanerTest.scala83
7 files changed, 124 insertions, 41 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala b/doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala
index 081883597..708c26cc0 100644
--- a/doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/DocCompiler.scala
@@ -7,17 +7,17 @@ import dotc.core.Phases.Phase
import dotc.Compiler
/** Custom Compiler with phases for the documentation tool
- *
- * The idea here is to structure `dottydoc` around the new infrastructure. As
- * such, dottydoc will itself be a compiler. It will, however, produce a format
- * that can be used by other tools or web-browsers.
- *
- * Example:
- * 1. Use the existing FrontEnd to typecheck the code being fed to dottydoc,
- * wihtout discarding AnyVal interfaces
- * 2. Create an AST that is serializable
- * 3. Serialize to JS object
- */
+ *
+ * The idea here is to structure `dottydoc` around the new infrastructure. As
+ * such, dottydoc will itself be a compiler. It will, however, produce a format
+ * that can be used by other tools or web-browsers.
+ *
+ * Example:
+ * 1. Use the existing FrontEnd to typecheck the code being fed to dottydoc,
+ * wihtout discarding AnyVal interfaces
+ * 2. Create an AST that is serializable
+ * 3. Serialize to JS object
+ */
class DocCompiler extends Compiler {
override def phases: List[List[Phase]] = List(
List(new DocFrontEnd),
diff --git a/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala b/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala
index e5a2cc266..ba7edb4b6 100644
--- a/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala
@@ -12,8 +12,8 @@ import dotc.core.Comments.ContextDoc
import staticsite.Site
/** `DocDriver` implements the main entry point to the Dotty documentation
- * tool. It's methods are used by the external scala and java APIs.
- */
+ * tool. It's methods are used by the external scala and java APIs.
+ */
class DocDriver extends Driver {
import _root_.java.util.{ Map => JMap }
import model.java._
diff --git a/doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala b/doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala
index 30c5e3e87..606fd0fc6 100644
--- a/doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/DocFrontEnd.scala
@@ -6,11 +6,11 @@ import dotc.core.Contexts.Context
import dotc.CompilationUnit
/** `DocFrontEnd` uses the Dotty `FrontEnd` without discarding the AnyVal
- * interfaces for Boolean, Int, Char, Long, Byte etc.
- *
- * It currently still throws away Java sources by overriding
- * `discardAfterTyper`.
- */
+ * interfaces for Boolean, Int, Char, Long, Byte etc.
+ *
+ * It currently still throws away Java sources by overriding
+ * `discardAfterTyper`.
+ */
class DocFrontEnd extends FrontEnd {
override protected def discardAfterTyper(unit: CompilationUnit)(implicit ctx: Context) =
unit.isJava
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 1d0891bc2..9d00b08a3 100644
--- a/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/api/scala/Dottydoc.scala
@@ -7,27 +7,27 @@ 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:
- *
- * ```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`
- */
+ * `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] =
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala
index 27b0ff977..30b3b0de0 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentCleaner.scala
@@ -20,6 +20,6 @@ trait CommentCleaner {
SafeTags.replaceAllIn(javadoclessComment, { mtch =>
_root_.java.util.regex.Matcher.quoteReplacement(safeTagMarker + mtch.matched + safeTagMarker)
})
- markedTagComment.lines.toList map (cleanLine(_))
+ markedTagComment.lines.toList map (cleanLine)
}
}
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentRegex.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentRegex.scala
index 2d75b0c66..faefd19a7 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentRegex.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/CommentRegex.scala
@@ -11,7 +11,7 @@ object Regexes {
* one leading whitespace and all trailing whitespace
*/
val CleanCommentLine =
- new Regex("""(?:\s*\*\s?)?(.*)""")
+ new Regex("""(?:\s*\*\s?\s?)?(.*)""")
/** Dangerous HTML tags that should be replaced by something safer,
* such as wiki syntax, or that should be dropped
diff --git a/doc-tool/test/CommentCleanerTest.scala b/doc-tool/test/CommentCleanerTest.scala
new file mode 100644
index 000000000..5cf5614c4
--- /dev/null
+++ b/doc-tool/test/CommentCleanerTest.scala
@@ -0,0 +1,83 @@
+package dotty.tools
+package dottydoc
+
+import org.junit.Test
+import org.junit.Assert._
+
+import model.comment.CommentCleaner
+
+class CommentCleanerTest extends CommentCleaner {
+ @Test def simpleOneliner = {
+ assertEquals(List("lol"), clean("/** lol */"))
+ }
+
+ @Test def multiline = {
+ val docstring = clean {
+ """|/** First
+ | * Second
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List("First", "Second", ""), docstring)
+ }
+
+ @Test def multilineBad = {
+ val docstring = clean {
+ """|/** First
+ | * Second
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List("First", " Second", ""), docstring)
+ }
+
+ @Test def multilineWorse = {
+ val docstring = clean {
+ """|/** First
+ | * Second
+ | * Third
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List("First", " Second", "Third", ""), docstring)
+ }
+
+ @Test def multilineFirstNoSpace = {
+ val docstring = clean {
+ """|/**First
+ | * Second
+ | * Third
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List("First", " Second", "Third", ""), docstring)
+ }
+
+ @Test def multilineFirstTwoSpaces = {
+ val docstring = clean {
+ """|/** First
+ | * Second
+ | * Third
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List("First", " Second", "Third", ""), docstring)
+ }
+
+ @Test def multilineFirstThreeSpaces = {
+ val docstring = clean {
+ """|/** First
+ | * Second
+ | * Third
+ | */
+ |""".stripMargin
+ }
+
+ assertEquals(List(" First", " Second", "Third", ""), docstring)
+ }
+}