diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-27 16:58:27 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-27 16:58:27 +0100 |
commit | 8a65a7ab62e4567bbb20cececcad88eb9ac396d9 (patch) | |
tree | 25c75ef3988f4d757cd76a2bc1e48cf38499d430 | |
parent | a9538f2f49e15b04340215d8d670557ced6f132d (diff) | |
download | dokka-8a65a7ab62e4567bbb20cececcad88eb9ac396d9.tar.gz dokka-8a65a7ab62e4567bbb20cececcad88eb9ac396d9.tar.bz2 dokka-8a65a7ab62e4567bbb20cececcad88eb9ac396d9.zip |
handle @code and @literal tags in javadoc
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 6 | ||||
-rw-r--r-- | src/Utilities/Html.kt | 1 | ||||
-rw-r--r-- | test/data/format/javaCodeLiteralTags.java | 8 | ||||
-rw-r--r-- | test/data/format/javaCodeLiteralTags.md | 17 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 6 |
5 files changed, 37 insertions, 1 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index 8a5d8fb9..055d64d3 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -128,6 +128,12 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, valueElement!!.getText() } } + "code", "literal" -> { + val text = StringBuilder() + tag.getDataElements().forEach { text.append(it.getText()) } + val escaped = text.toString().trimLeading().htmlEscape() + if (tag.getName() == "code") "<code>$escaped</code>" else escaped + } else -> tag.getText() } diff --git a/src/Utilities/Html.kt b/src/Utilities/Html.kt index 9630c8cb..ce3a1982 100644 --- a/src/Utilities/Html.kt +++ b/src/Utilities/Html.kt @@ -6,4 +6,3 @@ package org.jetbrains.dokka * Replaces & with &, < with < and > with > */ public fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">") - diff --git a/test/data/format/javaCodeLiteralTags.java b/test/data/format/javaCodeLiteralTags.java new file mode 100644 index 00000000..cf071f07 --- /dev/null +++ b/test/data/format/javaCodeLiteralTags.java @@ -0,0 +1,8 @@ +package test; + +/** + * <p>{@code A<B>C}</p> + * <p>{@literal A<B>C}</p> + */ +class C { +} diff --git a/test/data/format/javaCodeLiteralTags.md b/test/data/format/javaCodeLiteralTags.md new file mode 100644 index 00000000..17438bff --- /dev/null +++ b/test/data/format/javaCodeLiteralTags.md @@ -0,0 +1,17 @@ +[test](test/index) / [test](test/test/index) / [C](test/test/-c) + + +# C + +`open class C` + + +`A<B>C` + + +A<B>C + + + + + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 7253ddb4..2ee4fa46 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -124,4 +124,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun javaCodeLiteralTags() { + verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } |