diff options
Diffstat (limited to 'src/Model/PackageDocs.kt')
-rw-r--r-- | src/Model/PackageDocs.kt | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Model/PackageDocs.kt b/src/Model/PackageDocs.kt index b5b34942..99da327b 100644 --- a/src/Model/PackageDocs.kt +++ b/src/Model/PackageDocs.kt @@ -5,7 +5,7 @@ import org.intellij.markdown.MarkdownTokenTypes import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import java.io.File -public class PackageDocs(val documentationBuilder: DocumentationBuilder, +public class PackageDocs(val documentationBuilder: DocumentationBuilder?, val linkResolveContext: DeclarationDescriptor?, val logger: DokkaLogger) { public val moduleContent: MutableContent = MutableContent() @@ -13,17 +13,17 @@ public class PackageDocs(val documentationBuilder: DocumentationBuilder, public val packageContent: Map<String, Content> get() = _packageContent - fun parse(path: String) { - val file = File(path) + fun parse(fileName: String) { + val file = File(fileName) if (file.exists()) { val text = file.readText() val tree = parseMarkdown(text) var targetContent: MutableContent = moduleContent tree.children.forEach { if (it.type == MarkdownElementTypes.ATX_1) { - val headingText = it.child(MarkdownTokenTypes.TEXT)?.text + val headingText = it.child(MarkdownTokenTypes.ATX_CONTENT)?.text if (headingText != null) { - targetContent = findTargetContent(headingText) + targetContent = findTargetContent(headingText.trimStart()) } } else { buildContentTo(it, targetContent, { resolveContentLink(it) }) @@ -39,7 +39,7 @@ public class PackageDocs(val documentationBuilder: DocumentationBuilder, return moduleContent } if (heading.startsWith("Package") || heading.startsWith("package")) { - return findOrCreatePackageContent(heading.substring("package".length()).trim()) + return findOrCreatePackageContent(heading.substring("package".length).trim()) } return findOrCreatePackageContent(heading) } @@ -48,7 +48,7 @@ public class PackageDocs(val documentationBuilder: DocumentationBuilder, _packageContent.getOrPut(packageName) { -> MutableContent() } private fun resolveContentLink(href: String): ContentBlock { - if (linkResolveContext != null) { + if (linkResolveContext != null && documentationBuilder != null) { return documentationBuilder.resolveContentLink(linkResolveContext, href) } return ContentExternalLink("#") |