diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-11-20 17:42:45 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-25 16:24:16 +0100 |
commit | 4f59d3df7a0a3525bf3a0dab8617746a4db30f67 (patch) | |
tree | 4946e49ce708e8876c41fb921bcada4da860da30 /plugins/xml/src/main/kotlin/XmlPlugin.kt | |
parent | ca3d34cc9e5be2d9616cfde3d2cac489c07bf102 (diff) | |
download | dokka-4f59d3df7a0a3525bf3a0dab8617746a4db30f67.tar.gz dokka-4f59d3df7a0a3525bf3a0dab8617746a4db30f67.tar.bz2 dokka-4f59d3df7a0a3525bf3a0dab8617746a4db30f67.zip |
XML plugin refactoring
Diffstat (limited to 'plugins/xml/src/main/kotlin/XmlPlugin.kt')
-rw-r--r-- | plugins/xml/src/main/kotlin/XmlPlugin.kt | 65 |
1 files changed, 9 insertions, 56 deletions
diff --git a/plugins/xml/src/main/kotlin/XmlPlugin.kt b/plugins/xml/src/main/kotlin/XmlPlugin.kt index 4a932062..4023e1cc 100644 --- a/plugins/xml/src/main/kotlin/XmlPlugin.kt +++ b/plugins/xml/src/main/kotlin/XmlPlugin.kt @@ -16,78 +16,31 @@ class XmlPlugin : DokkaPlugin() { } } -private const val ANNOTATION = "@usesMathJax" -private const val LIB_PATH = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" - object XmlTransformer : PageNodeTransformer { enum class XMLKind : Kind { Main, XmlList } - override fun invoke(original: ModulePageNode, dokkaContext: DokkaContext): ModulePageNode { - original.findAll { it is ClassPageNode }.forEach { node -> + override fun invoke(input: ModulePageNode, dokkaContext: DokkaContext): ModulePageNode { + input.findAll { it is ClassPageNode }.forEach { node -> val refs = node.documentationNode?.extra?.filterIsInstance<DefaultExtra>()?.filter { it.key == "@attr ref"}.orEmpty() val elementsToAdd = mutableListOf<DocumentationNode<*>>() refs.forEach { ref -> val toFind = DRI.from(ref.value) - original.documentationNode?.dfs { it.dri == toFind }?.let { elementsToAdd.add(it) } + input.documentationNode?.dfs { it.dri == toFind }?.let { elementsToAdd.add(it) } + } + val refTable = group(node.platforms().toSet(), node.dri, XMLKind.XmlList) { + table("XML Attributes", 2, XMLKind.XmlList, elementsToAdd) { + elementsToAdd.map { row(it) } + } } - - val refTable = ContentGroup( - listOf( - ContentHeader( - listOf( - ContentText( - "XML Attributes", - DCI(node.dri, XMLKind.XmlList), - node.platforms().toSet(), emptySet(), emptySet() - ) - ), - 2, - DCI(node.dri, XMLKind.Main), - node.platforms().toSet(), emptySet(), emptySet() - ), - ContentTable( - emptyList(), - elementsToAdd.map { - ContentGroup( - listOf( - ContentDRILink( - listOf( - ContentText( - it.descriptors.first().name.toString(), - DCI(node.dri, XMLKind.Main), - node.platforms().toSet(), emptySet(), emptySet() - ) - ), - it.dri, - DCI(it.dri, XMLKind.XmlList), - it.platformData.toSet(), emptySet(), emptySet() - ), - ContentText( - it.briefDocstring, - DCI(it.dri, XMLKind.XmlList), - it.platformData.toSet(), emptySet(), emptySet() - ) - ), - DCI(node.dri, XMLKind.XmlList), - node.platforms().toSet(), emptySet(), emptySet() - ) - }, - DCI(node.dri, XMLKind.XmlList), - node.platforms().toSet(), emptySet(), emptySet() - ) - ), - DCI(node.dri, XMLKind.XmlList), - node.platforms().toSet(), emptySet(), emptySet() - ) val content = node.content as ContentGroup val children = (node.content as ContentGroup).children node.content = content.copy(children = children + refTable) } - return original + return input } private fun PageNode.findAll(predicate: (PageNode) -> Boolean): Set<PageNode> { |