diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-12 03:25:39 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-12 03:25:39 +0400 |
commit | d627d2cfdfebcddd63669734efb82dfc66e7c7fe (patch) | |
tree | f0c60789cc4b529b86a6ba028bb2bd8a749d9b4c /src/Model/Sections.kt | |
parent | 7bc3513935588467d4f848bbe40539664fdbdcf9 (diff) | |
download | dokka-d627d2cfdfebcddd63669734efb82dfc66e7c7fe.tar.gz dokka-d627d2cfdfebcddd63669734efb82dfc66e7c7fe.tar.bz2 dokka-d627d2cfdfebcddd63669734efb82dfc66e7c7fe.zip |
Convert string doc to structured DocumentationContent
Diffstat (limited to 'src/Model/Sections.kt')
-rw-r--r-- | src/Model/Sections.kt | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Model/Sections.kt b/src/Model/Sections.kt new file mode 100644 index 00000000..733c0d2f --- /dev/null +++ b/src/Model/Sections.kt @@ -0,0 +1,43 @@ +package org.jetbrains.dokka + +import org.jetbrains.jet.lang.descriptors.* +import org.jetbrains.jet.lang.resolve.BindingContext + +fun BindingContext.getDocumentation(descriptor: DeclarationDescriptor): DocumentationContent { + val docText = getDocumentationElements(descriptor).map { it.extractText() }.join("\n") + return DocumentationContent(docText, listOf()) +} + +class DocumentationContentSection(val label: String, val text: String) { + +} + +class DocumentationContent(val summary: String, val sections: List<DocumentationContentSection>) { + + override fun equals(other: Any?): Boolean { + if (other !is DocumentationContent) + return false + if (summary != other.summary) + return false + if (sections.size != other.sections.size) + return false + for (index in sections.indices) + if (sections[index] != other.sections[index]) + return false + + return true + } + + override fun hashCode(): Int { + return summary.hashCode() + sections.map { it.hashCode() }.sum() + } + + override fun toString(): String { + return "$summary | " + sections.joinToString() + } + + class object { + val Empty = DocumentationContent("", listOf()) + } +} + |