diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-09-14 13:49:54 +0200 |
---|---|---|
committer | Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> | 2020-10-07 02:36:57 +0200 |
commit | ec637955575995011351b106d3a67194d21c4b15 (patch) | |
tree | 5762d6ca0c49cc48dec01240380bc6fd436e81b0 /plugins/base/src/main/kotlin/parsers | |
parent | 7c4301a48af55e156538666b6e645d8d13caae9a (diff) | |
download | dokka-ec637955575995011351b106d3a67194d21c4b15.tar.gz dokka-ec637955575995011351b106d3a67194d21c4b15.tar.bz2 dokka-ec637955575995011351b106d3a67194d21c4b15.zip |
Introduce top-level DocTag
Diffstat (limited to 'plugins/base/src/main/kotlin/parsers')
4 files changed, 25 insertions, 13 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt index 23e59f8b..e7a36d3f 100644 --- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt +++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt @@ -162,6 +162,12 @@ open class MarkdownParser( return linksHandler(linkText, link, linkTitle) } + private fun markdownFileHandler(node: ASTNode) = + DocTagsFromIElementFactory.getInstance( + node.type, + children = node.children.evaluateChildren() + ) + private fun autoLinksHandler(node: ASTNode): DocTag { val link = text.substring(node.startOffset + 1, node.endOffset - 1) @@ -206,11 +212,6 @@ open class MarkdownParser( body = text.substring(node.startOffset, node.endOffset).transform() ) - private fun markdownFileHandler(node: ASTNode) = if (node.children.size == 1) - visitNode(node.children.first()) - else - defaultHandler(node) - private fun strikeThroughHandler(node: ASTNode) = DocTagsFromIElementFactory.getInstance( node.type, children = node.children.evaluateChildrenWithDroppedEnclosingTokens(2) @@ -448,9 +449,9 @@ open class MarkdownParser( KDocKnownTag.SEE -> See( parseStringToDocNode(it.getContent()), it.getSubjectName().orEmpty(), - parseStringToDocNode("[${it.getSubjectName()}]") + (parseStringToDocNode("[${it.getSubjectName()}]")) .let { - val link = it.children[0] + val link = it.children[0].children[0] if (link is DocumentationLink) link.dri else null } diff --git a/plugins/base/src/main/kotlin/parsers/Parser.kt b/plugins/base/src/main/kotlin/parsers/Parser.kt index 894fa82f..228cc88b 100644 --- a/plugins/base/src/main/kotlin/parsers/Parser.kt +++ b/plugins/base/src/main/kotlin/parsers/Parser.kt @@ -18,8 +18,15 @@ abstract class Parser { "author" -> Author(parseStringToDocNode(it.second)) "version" -> Version(parseStringToDocNode(it.second)) "since" -> Since(parseStringToDocNode(it.second)) - "see" -> See(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' '), null) - "param" -> Param(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ')) + "see" -> See( + parseStringToDocNode(it.second.substringAfter(' ')), + it.second.substringBefore(' '), + null + ) + "param" -> Param( + parseStringToDocNode(it.second.substringAfter(' ')), + it.second.substringBefore(' ') + ) "property" -> Property( parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ') @@ -32,7 +39,10 @@ abstract class Parser { it.second.substringBefore(' ') ) "deprecated" -> Deprecated(parseStringToDocNode(it.second)) - "sample" -> Sample(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ')) + "sample" -> Sample( + parseStringToDocNode(it.second.substringAfter(' ')), + it.second.substringBefore(' ') + ) "suppress" -> Suppress(parseStringToDocNode(it.second)) else -> CustomTagWrapper(parseStringToDocNode(it.second), it.first) } diff --git a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt index 58b4b223..b714caec 100644 --- a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt +++ b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt @@ -40,6 +40,7 @@ object DocTagsFromIElementFactory { GFMElementTypes.HEADER -> Th(children, params) GFMElementTypes.ROW -> Tr(children, params) GFMTokenTypes.CELL -> Td(children, params) - else -> CustomDocTag(children, params) + MarkdownElementTypes.MARKDOWN_FILE -> CustomDocTag(children, params, MarkdownElementTypes.MARKDOWN_FILE.name) + else -> CustomDocTag(children, params, type.name) } } diff --git a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt index 124dc3b4..1af4e719 100644 --- a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt +++ b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt @@ -72,6 +72,6 @@ object DocTagsFromStringFactory { "var" -> Var(children, params) "documentationlink" -> DocumentationLink(dri ?: throw NullPointerException("DRI cannot be passed null while constructing documentation link!"), children, params) "hr" -> HorizontalRule - else -> CustomDocTag(children, params) + else -> CustomDocTag(children, params, name) } -}
\ No newline at end of file +} |