diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-04 19:39:39 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-01-04 19:39:39 +0100 |
commit | 3b3c2841674d9b7044494d16d4396662d273f1f9 (patch) | |
tree | 268f6d3085b05da702d5d61eff505000cd9ea36a /core/src | |
parent | 0260b37dd051fc5d728820fa20b0ad7d94c33c0f (diff) | |
download | dokka-3b3c2841674d9b7044494d16d4396662d273f1f9.tar.gz dokka-3b3c2841674d9b7044494d16d4396662d273f1f9.tar.bz2 dokka-3b3c2841674d9b7044494d16d4396662d273f1f9.zip |
cleanup: remove redundant 'public' modifiers
Diffstat (limited to 'core/src')
26 files changed, 174 insertions, 172 deletions
diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index a5e35a0e..b0c39ee5 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -57,7 +57,7 @@ import java.io.File * $messageCollector: required by compiler infrastructure and will receive all compiler messages * $body: optional and can be used to configure environment without creating local variable */ -public class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { +class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val configuration = CompilerConfiguration(); init { @@ -119,14 +119,14 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector) : Dispo /** * Classpath for this environment. */ - public val classpath: List<File> + val classpath: List<File> get() = configuration.jvmClasspathRoots /** * Adds list of paths to classpath. * $paths: collection of files to add */ - public fun addClasspath(paths: List<File>) { + fun addClasspath(paths: List<File>) { configuration.addJvmClasspathRoots(paths) } @@ -134,14 +134,14 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector) : Dispo * Adds path to classpath. * $path: path to add */ - public fun addClasspath(path: File) { + fun addClasspath(path: File) { configuration.addJvmClasspathRoot(path) } /** * List of source roots for this environment. */ - public val sources: List<String> + val sources: List<String> get() = configuration.get(CommonConfigurationKeys.CONTENT_ROOTS) ?.filterIsInstance<KotlinSourceRoot>() ?.map { it.path } ?: emptyList() @@ -150,25 +150,25 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector) : Dispo * Adds list of paths to source roots. * $list: collection of files to add */ - public fun addSources(list: List<String>) { + fun addSources(list: List<String>) { list.forEach { configuration.add(CommonConfigurationKeys.CONTENT_ROOTS, contentRootFromPath(it)) } } - public fun addRoots(list: List<ContentRoot>) { + fun addRoots(list: List<ContentRoot>) { configuration.addAll(CommonConfigurationKeys.CONTENT_ROOTS, list) } /** * Disposes the environment and frees all associated resources. */ - public override fun dispose() { + override fun dispose() { Disposer.dispose(this) } } -public fun contentRootFromPath(path: String): ContentRoot { +fun contentRootFromPath(path: String): ContentRoot { val file = File(path) return if (file.extension == "java") JavaSourceRoot(file, null) else KotlinSourceRoot(path) } diff --git a/core/src/main/kotlin/Formats/FormatDescriptor.kt b/core/src/main/kotlin/Formats/FormatDescriptor.kt index 0c7ca794..e384f223 100644 --- a/core/src/main/kotlin/Formats/FormatDescriptor.kt +++ b/core/src/main/kotlin/Formats/FormatDescriptor.kt @@ -3,7 +3,7 @@ package org.jetbrains.dokka.Formats import org.jetbrains.dokka.* import kotlin.reflect.KClass -public interface FormatDescriptor { +interface FormatDescriptor { val formatServiceClass: KClass<out FormatService>? val outlineServiceClass: KClass<out OutlineFormatService>? val generatorServiceClass: KClass<out Generator> diff --git a/core/src/main/kotlin/Formats/FormatService.kt b/core/src/main/kotlin/Formats/FormatService.kt index 73e54956..aa4e925c 100644 --- a/core/src/main/kotlin/Formats/FormatService.kt +++ b/core/src/main/kotlin/Formats/FormatService.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka * * [HtmlFormatService] – outputs documentation to HTML format * * [MarkdownFormatService] – outputs documentation in Markdown format */ -public interface FormatService { +interface FormatService { /** Returns extension for output files */ val extension: String diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index d513e41f..f78439ba 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -6,11 +6,11 @@ import java.io.File import java.nio.file.Path import java.nio.file.Paths -public open class HtmlFormatService @Inject constructor(@Named("folders") locationService: LocationService, - signatureGenerator: LanguageService, - val templateService: HtmlTemplateService) +open class HtmlFormatService @Inject constructor(@Named("folders") locationService: LocationService, + signatureGenerator: LanguageService, + val templateService: HtmlTemplateService) : StructuredFormatService(locationService, signatureGenerator, "html"), OutlineFormatService { - override public fun formatText(text: String): String { + override fun formatText(text: String): String { return text.htmlEscape() } diff --git a/core/src/main/kotlin/Formats/HtmlTemplateService.kt b/core/src/main/kotlin/Formats/HtmlTemplateService.kt index ae42a31b..13587b05 100644 --- a/core/src/main/kotlin/Formats/HtmlTemplateService.kt +++ b/core/src/main/kotlin/Formats/HtmlTemplateService.kt @@ -2,12 +2,12 @@ package org.jetbrains.dokka import java.nio.file.Path -public interface HtmlTemplateService { +interface HtmlTemplateService { fun appendHeader(to: StringBuilder, title: String?, basePath: Path) fun appendFooter(to: StringBuilder) companion object { - public fun default(css: String? = null): HtmlTemplateService { + fun default(css: String? = null): HtmlTemplateService { return object : HtmlTemplateService { override fun appendFooter(to: StringBuilder) { to.appendln("</BODY>") diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt index 870347ab..f869bc75 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka import com.google.inject.Inject -public class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService, +class KotlinWebsiteFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator, "html") { private var needHardLineBreaks = false @@ -13,7 +13,7 @@ public class KotlinWebsiteFormatService @Inject constructor(locationService: Loc to.appendln("layout: api") } - override public fun formatBreadcrumbs(items: Iterable<FormatLink>): String { + override fun formatBreadcrumbs(items: Iterable<FormatLink>): String { items.drop(1) if (items.count() > 1) { @@ -25,7 +25,7 @@ public class KotlinWebsiteFormatService @Inject constructor(locationService: Loc return "" } - override public fun formatCode(code: String): String = if (code.length > 0) "<code>$code</code>" else "" + override fun formatCode(code: String): String = if (code.length > 0) "<code>$code</code>" else "" override fun formatStrikethrough(text: String): String = "<s>$text</s>" @@ -106,7 +106,7 @@ public class KotlinWebsiteFormatService @Inject constructor(locationService: Loc to.appendln("\n</td>") } - override public fun appendBlockCode(to: StringBuilder, line: String, language: String) { + override fun appendBlockCode(to: StringBuilder, line: String, language: String) { if (language.isNotEmpty()) { super.appendBlockCode(to, line, language) } else { diff --git a/core/src/main/kotlin/Formats/MarkdownFormatService.kt b/core/src/main/kotlin/Formats/MarkdownFormatService.kt index 07202b7e..4e16b1a8 100644 --- a/core/src/main/kotlin/Formats/MarkdownFormatService.kt +++ b/core/src/main/kotlin/Formats/MarkdownFormatService.kt @@ -3,16 +3,16 @@ package org.jetbrains.dokka import com.google.inject.Inject -public open class MarkdownFormatService +open class MarkdownFormatService @Inject constructor(locationService: LocationService, signatureGenerator: LanguageService, linkExtension: String = "md") : StructuredFormatService(locationService, signatureGenerator, "md", linkExtension) { - override public fun formatBreadcrumbs(items: Iterable<FormatLink>): String { + override fun formatBreadcrumbs(items: Iterable<FormatLink>): String { return items.map { formatLink(it) }.joinToString(" / ") } - override public fun formatText(text: String): String { + override fun formatText(text: String): String { return text.htmlEscape() } @@ -27,19 +27,19 @@ public open class MarkdownFormatService return text.htmlEscape() } - override public fun formatCode(code: String): String { + override fun formatCode(code: String): String { return "`$code`" } - override public fun formatUnorderedList(text: String): String = text + "\n" - override public fun formatOrderedList(text: String): String = text + "\n" + override fun formatUnorderedList(text: String): String = text + "\n" + override fun formatOrderedList(text: String): String = text + "\n" override fun formatListItem(text: String, kind: ListKind): String { val itemText = if (text.endsWith("\n")) text else text + "\n" return if (kind == ListKind.Unordered) "* $itemText" else "1. $itemText" } - override public fun formatStrong(text: String): String { + override fun formatStrong(text: String): String { return "**$text**" } @@ -55,7 +55,7 @@ public open class MarkdownFormatService return "[$text]($href)" } - override public fun appendLine(to: StringBuilder, text: String) { + override fun appendLine(to: StringBuilder, text: String) { to.appendln(text) } @@ -63,19 +63,19 @@ public open class MarkdownFormatService // no anchors in Markdown } - override public fun appendParagraph(to: StringBuilder, text: String) { + override fun appendParagraph(to: StringBuilder, text: String) { to.appendln() to.appendln(text) to.appendln() } - override public fun appendHeader(to: StringBuilder, text: String, level: Int) { + override fun appendHeader(to: StringBuilder, text: String, level: Int) { appendLine(to) appendLine(to, "${"#".repeat(level)} $text") appendLine(to) } - override public fun appendBlockCode(to: StringBuilder, line: String, language: String) { + override fun appendBlockCode(to: StringBuilder, line: String, language: String) { appendLine(to) to.appendln("``` ${language}") to.appendln(line) diff --git a/core/src/main/kotlin/Formats/OutlineService.kt b/core/src/main/kotlin/Formats/OutlineService.kt index 6626cf51..3c31ba57 100644 --- a/core/src/main/kotlin/Formats/OutlineService.kt +++ b/core/src/main/kotlin/Formats/OutlineService.kt @@ -5,14 +5,14 @@ import java.io.File /** * Service for building the outline of the package contents. */ -public interface OutlineFormatService { +interface OutlineFormatService { fun getOutlineFileName(location: Location): File - public fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder) - public fun appendOutlineLevel(to: StringBuilder, body: () -> Unit) + fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder) + fun appendOutlineLevel(to: StringBuilder, body: () -> Unit) /** Appends formatted outline to [StringBuilder](to) using specified [location] */ - public fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { + fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { for (node in nodes) { appendOutlineHeader(location, node, to) if (node.members.any()) { diff --git a/core/src/main/kotlin/Generation/ConsoleGenerator.kt b/core/src/main/kotlin/Generation/ConsoleGenerator.kt index 803a16e4..301f86b9 100644 --- a/core/src/main/kotlin/Generation/ConsoleGenerator.kt +++ b/core/src/main/kotlin/Generation/ConsoleGenerator.kt @@ -1,9 +1,9 @@ package org.jetbrains.dokka -public class ConsoleGenerator(val signatureGenerator: LanguageService, val locationService: LocationService) { +class ConsoleGenerator(val signatureGenerator: LanguageService, val locationService: LocationService) { val IndentStep = " " - public fun generate(node: DocumentationNode, indent: String = "") { + fun generate(node: DocumentationNode, indent: String = "") { println("@${locationService.location(node).path}") generateHeader(node, indent) //generateDetails(node, indent) @@ -11,7 +11,7 @@ public class ConsoleGenerator(val signatureGenerator: LanguageService, val locat generateLinks(node, indent) } - public fun generateHeader(node: DocumentationNode, indent: String = "") { + fun generateHeader(node: DocumentationNode, indent: String = "") { println(indent + signatureGenerator.render(node)) val docString = node.content.toString() if (!docString.isEmpty()) @@ -19,19 +19,19 @@ public class ConsoleGenerator(val signatureGenerator: LanguageService, val locat println() } - public fun generateMembers(node: DocumentationNode, indent: String = "") { + fun generateMembers(node: DocumentationNode, indent: String = "") { val items = node.members.sortedBy { it.name } for (child in items) generate(child, indent + IndentStep) } - public fun generateDetails(node: DocumentationNode, indent: String = "") { + fun generateDetails(node: DocumentationNode, indent: String = "") { val items = node.details for (child in items) generate(child, indent + " ") } - public fun generateLinks(node: DocumentationNode, indent: String = "") { + fun generateLinks(node: DocumentationNode, indent: String = "") { val items = node.links if (items.isEmpty()) return diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt index e3d1d1fe..86ebd6b7 100644 --- a/core/src/main/kotlin/Generation/FileGenerator.kt +++ b/core/src/main/kotlin/Generation/FileGenerator.kt @@ -6,7 +6,7 @@ import java.io.FileOutputStream import java.io.IOException import java.io.OutputStreamWriter -public class FileGenerator @Inject constructor(val locationService: FileLocationService) : Generator { +class FileGenerator @Inject constructor(val locationService: FileLocationService) : Generator { @set:Inject(optional = true) var outlineService: OutlineFormatService? = null @set:Inject(optional = true) lateinit var formatService: FormatService diff --git a/core/src/main/kotlin/Generation/Generator.kt b/core/src/main/kotlin/Generation/Generator.kt index ac10a6a5..83ddd04f 100644 --- a/core/src/main/kotlin/Generation/Generator.kt +++ b/core/src/main/kotlin/Generation/Generator.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka -public interface Generator { +interface Generator { fun buildPages(nodes: Iterable<DocumentationNode>) fun buildOutlines(nodes: Iterable<DocumentationNode>) fun buildSupportFiles() diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt index 1a6ffb98..e4ed3962 100644 --- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt +++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt @@ -5,7 +5,7 @@ import org.intellij.markdown.MarkdownTokenTypes import org.intellij.markdown.html.entities.EntityConverter import java.util.* -public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock, inline: Boolean = false): MutableContent { +fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock, inline: Boolean = false): MutableContent { val result = MutableContent() if (inline) { buildInlineContentTo(tree, result, linkResolver) @@ -16,7 +16,7 @@ public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlo return result } -public fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) { +fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) { // println(tree.toTestString()) val nodeStack = ArrayDeque<ContentBlock>() nodeStack.push(target) @@ -129,7 +129,7 @@ public fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver private fun keepWhitespace(node: ContentNode) = node is ContentParagraph || node is ContentSection -public fun buildInlineContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) { +fun buildInlineContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (String) -> ContentBlock) { val inlineContent = tree.children.singleOrNull { it.type == MarkdownElementTypes.PARAGRAPH }?.children ?: listOf(tree) inlineContent.forEach { buildContentTo(it, target, linkResolver) diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 6551ded6..7ac5c020 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -33,13 +33,13 @@ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection -public data class DocumentationOptions(val outputDir: String, - val outputFormat: String, - val includeNonPublic: Boolean = false, - val reportUndocumented: Boolean = true, - val skipEmptyPackages: Boolean = true, - val skipDeprecated: Boolean = false, - val sourceLinks: List<SourceLinkDefinition>) +data class DocumentationOptions(val outputDir: String, + val outputFormat: String, + val includeNonPublic: Boolean = false, + val reportUndocumented: Boolean = true, + val skipEmptyPackages: Boolean = true, + val skipDeprecated: Boolean = false, + val sourceLinks: List<SourceLinkDefinition>) private fun isSamePackage(descriptor1: DeclarationDescriptor, descriptor2: DeclarationDescriptor): Boolean { val package1 = DescriptorUtils.getParentOfType(descriptor1, PackageFragmentDescriptor::class.java) diff --git a/core/src/main/kotlin/Languages/JavaLanguageService.kt b/core/src/main/kotlin/Languages/JavaLanguageService.kt index 7e40beff..8be9f13e 100644 --- a/core/src/main/kotlin/Languages/JavaLanguageService.kt +++ b/core/src/main/kotlin/Languages/JavaLanguageService.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.LanguageService.RenderMode /** * Implements [LanguageService] and provides rendering of symbols in Java language */ -public class JavaLanguageService : LanguageService { +class JavaLanguageService : LanguageService { override fun render(node: DocumentationNode, renderMode: RenderMode): ContentNode { return ContentText(when (node.kind) { Kind.Package -> renderPackage(node) @@ -44,19 +44,19 @@ public class JavaLanguageService : LanguageService { } } - public fun getArrayElementType(node: DocumentationNode): DocumentationNode? = when (node.name) { + fun getArrayElementType(node: DocumentationNode): DocumentationNode? = when (node.name) { "Array" -> node.details(Kind.Type).singleOrNull()?.let { et -> getArrayElementType(et) ?: et } ?: DocumentationNode("Object", node.content, DocumentationNode.Kind.ExternalClass) "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> DocumentationNode(node.name.removeSuffix("Array").toLowerCase(), node.content, DocumentationNode.Kind.Type) else -> null } - public fun getArrayDimension(node: DocumentationNode): Int = when (node.name) { + fun getArrayDimension(node: DocumentationNode): Int = when (node.name) { "Array" -> 1 + (node.details(DocumentationNode.Kind.Type).singleOrNull()?.let { getArrayDimension(it) } ?: 0) "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> 1 else -> 0 } - public fun renderType(node: DocumentationNode): String { + fun renderType(node: DocumentationNode): String { return when (node.name) { "Unit" -> "void" "Int" -> "int" diff --git a/core/src/main/kotlin/Locations/FoldersLocationService.kt b/core/src/main/kotlin/Locations/FoldersLocationService.kt index 89b34ed1..83e1cf6a 100644 --- a/core/src/main/kotlin/Locations/FoldersLocationService.kt +++ b/core/src/main/kotlin/Locations/FoldersLocationService.kt @@ -4,8 +4,9 @@ import com.google.inject.Inject import com.google.inject.name.Named import java.io.File -public fun FoldersLocationService(root: String): FoldersLocationService = FoldersLocationService(File(root), "") -public class FoldersLocationService @Inject constructor(@Named("outputDir") val rootFile: File, val extension: String) : FileLocationService { +class FoldersLocationService @Inject constructor(@Named("outputDir") val rootFile: File, val extension: String) : FileLocationService { + constructor(root: String): this(File(root), "") + override val root: Location get() = FileLocation(rootFile) diff --git a/core/src/main/kotlin/Locations/LocationService.kt b/core/src/main/kotlin/Locations/LocationService.kt index 80bc0236..63c236ed 100644 --- a/core/src/main/kotlin/Locations/LocationService.kt +++ b/core/src/main/kotlin/Locations/LocationService.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka import java.io.File -public interface Location { +interface Location { val path: String get fun relativePathTo(other: Location, anchor: String? = null): String } @@ -15,7 +15,7 @@ public interface Location { * $file: [File] for this location * $path: [String] representing path of this location */ -public data class FileLocation(val file: File): Location { +data class FileLocation(val file: File): Location { override val path : String get() = file.path @@ -41,7 +41,7 @@ public data class FileLocation(val file: File): Location { * * [SingleFolderLocationService] – all documentation is generated into single folder using fully qualified names * for file names. */ -public interface LocationService { +interface LocationService { fun withExtension(newExtension: String) = this fun location(node: DocumentationNode): Location = location(node.path.map { it.name }, node.members.any()) @@ -56,7 +56,7 @@ public interface LocationService { } -public interface FileLocationService: LocationService { +interface FileLocationService: LocationService { override fun withExtension(newExtension: String): FileLocationService = this override fun location(node: DocumentationNode): FileLocation = location(node.path.map { it.name }, node.members.any()) @@ -64,7 +64,7 @@ public interface FileLocationService: LocationService { } -public fun identifierToFilename(path: String): String { +fun identifierToFilename(path: String): String { val escaped = path.replace('<', '-').replace('>', '-') val lowercase = escaped.replace("[A-Z]".toRegex()) { matchResult -> "-" + matchResult.value.toLowerCase() } return if (lowercase == "index") "--index--" else lowercase diff --git a/core/src/main/kotlin/Locations/SingleFolderLocationService.kt b/core/src/main/kotlin/Locations/SingleFolderLocationService.kt index e313ac28..1b4fdc28 100644 --- a/core/src/main/kotlin/Locations/SingleFolderLocationService.kt +++ b/core/src/main/kotlin/Locations/SingleFolderLocationService.kt @@ -4,8 +4,9 @@ import com.google.inject.Inject import com.google.inject.name.Named import java.io.File -public fun SingleFolderLocationService(root: String): SingleFolderLocationService = SingleFolderLocationService(File(root), "") -public class SingleFolderLocationService @Inject constructor(@Named("outputDir") val rootFile: File, val extension: String) : FileLocationService { +class SingleFolderLocationService @Inject constructor(@Named("outputDir") val rootFile: File, val extension: String) : FileLocationService { + constructor(root: String): this(File(root), "") + override fun withExtension(newExtension: String): FileLocationService = SingleFolderLocationService(rootFile, newExtension) diff --git a/core/src/main/kotlin/Markdown/MarkdownProcessor.kt b/core/src/main/kotlin/Markdown/MarkdownProcessor.kt index 99caddc4..46b72c03 100644 --- a/core/src/main/kotlin/Markdown/MarkdownProcessor.kt +++ b/core/src/main/kotlin/Markdown/MarkdownProcessor.kt @@ -24,7 +24,7 @@ fun MarkdownNode.visit(action: (MarkdownNode, () -> Unit) -> Unit) { } } -public fun MarkdownNode.toTestString(): String { +fun MarkdownNode.toTestString(): String { val sb = StringBuilder() var level = 0 visit { node, visitChildren -> diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt index 6556b09e..1bf1da48 100644 --- a/core/src/main/kotlin/Model/Content.kt +++ b/core/src/main/kotlin/Model/Content.kt @@ -1,14 +1,14 @@ package org.jetbrains.dokka -public interface ContentNode { +interface ContentNode { val textLength: Int } -public object ContentEmpty : ContentNode { +object ContentEmpty : ContentNode { override val textLength: Int get() = 0 } -public open class ContentBlock() : ContentNode { +open class ContentBlock() : ContentNode { val children = arrayListOf<ContentNode>() fun append(node: ContentNode) { @@ -35,58 +35,58 @@ enum class IdentifierKind { Other } -public data class ContentText(val text: String) : ContentNode { +data class ContentText(val text: String) : ContentNode { override val textLength: Int get() = text.length } -public data class ContentKeyword(val text: String) : ContentNode { +data class ContentKeyword(val text: String) : ContentNode { override val textLength: Int get() = text.length } -public data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode { +data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode { override val textLength: Int get() = text.length } -public data class ContentSymbol(val text: String) : ContentNode { +data class ContentSymbol(val text: String) : ContentNode { override val textLength: Int get() = text.length } -public data class ContentEntity(val text: String) : ContentNode { +data class ContentEntity(val text: String) : ContentNode { override val textLength: Int get() = text.length } -public object ContentNonBreakingSpace: ContentNode { +object ContentNonBreakingSpace: ContentNode { override val textLength: Int get() = 1 } -public object ContentSoftLineBreak: ContentNode { +object ContentSoftLineBreak: ContentNode { override val textLength: Int get() = 0 } -public object ContentIndentedSoftLineBreak: ContentNode { +object ContentIndentedSoftLineBreak: ContentNode { override val textLength: Int get() = 0 } -public class ContentParagraph() : ContentBlock() -public class ContentEmphasis() : ContentBlock() -public class ContentStrong() : ContentBlock() -public class ContentStrikethrough() : ContentBlock() -public class ContentCode() : ContentBlock() -public class ContentBlockCode(val language: String = "") : ContentBlock() +class ContentParagraph() : ContentBlock() +class ContentEmphasis() : ContentBlock() +class ContentStrong() : ContentBlock() +class ContentStrikethrough() : ContentBlock() +class ContentCode() : ContentBlock() +class ContentBlockCode(val language: String = "") : ContentBlock() -public abstract class ContentNodeLink() : ContentBlock() { +abstract class ContentNodeLink() : ContentBlock() { abstract val node: DocumentationNode? } -public class ContentNodeDirectLink(override val node: DocumentationNode): ContentNodeLink() { +class ContentNodeDirectLink(override val node: DocumentationNode): ContentNodeLink() { override fun equals(other: Any?): Boolean = super.equals(other) && other is ContentNodeDirectLink && node.name == other.node.name @@ -94,7 +94,7 @@ public class ContentNodeDirectLink(override val node: DocumentationNode): Conten children.hashCode() * 31 + node.name.hashCode() } -public class ContentNodeLazyLink(val linkText: String, val lazyNode: () -> DocumentationNode?): ContentNodeLink() { +class ContentNodeLazyLink(val linkText: String, val lazyNode: () -> DocumentationNode?): ContentNodeLink() { override val node: DocumentationNode? get() = lazyNode() override fun equals(other: Any?): Boolean = @@ -104,7 +104,7 @@ public class ContentNodeLazyLink(val linkText: String, val lazyNode: () -> Docum children.hashCode() * 31 + linkText.hashCode() } -public class ContentExternalLink(val href : String) : ContentBlock() { +class ContentExternalLink(val href : String) : ContentBlock() { override fun equals(other: Any?): Boolean = super.equals(other) && other is ContentExternalLink && href == other.href @@ -112,13 +112,13 @@ public class ContentExternalLink(val href : String) : ContentBlock() { children.hashCode() * 31 + href.hashCode() } -public class ContentUnorderedList() : ContentBlock() -public class ContentOrderedList() : ContentBlock() -public class ContentListItem() : ContentBlock() +class ContentUnorderedList() : ContentBlock() +class ContentOrderedList() : ContentBlock() +class ContentListItem() : ContentBlock() -public class ContentHeading(val level: Int) : ContentBlock() +class ContentHeading(val level: Int) : ContentBlock() -public class ContentSection(public val tag: String, public val subjectName: String?) : ContentBlock() { +class ContentSection(val tag: String, val subjectName: String?) : ContentBlock() { override fun equals(other: Any?): Boolean = super.equals(other) && other is ContentSection && tag == other.tag && subjectName == other.subjectName @@ -126,7 +126,7 @@ public class ContentSection(public val tag: String, public val subjectName: Stri children.hashCode() * 31 * 31 + tag.hashCode() * 31 + (subjectName?.hashCode() ?: 0) } -public object ContentTags { +object ContentTags { val Description = "Description" val SeeAlso = "See Also" } @@ -163,10 +163,10 @@ fun ContentBlock.link(to: DocumentationNode, body: ContentBlock.() -> Unit) { append(block) } -public open class Content(): ContentBlock() { - public open val sections: List<ContentSection> get() = emptyList() - public open val summary: ContentNode get() = ContentEmpty - public open val description: ContentNode get() = ContentEmpty +open class Content(): ContentBlock() { + open val sections: List<ContentSection> get() = emptyList() + open val summary: ContentNode get() = ContentEmpty + open val description: ContentNode get() = ContentEmpty fun findSectionByTag(tag: String): ContentSection? = sections.firstOrNull { tag.equals(it.tag, ignoreCase = true) } @@ -182,9 +182,9 @@ public open class Content(): ContentBlock() { } } -public open class MutableContent() : Content() { +open class MutableContent() : Content() { private val sectionList = arrayListOf<ContentSection>() - public override val sections: List<ContentSection> + override val sections: List<ContentSection> get() = sectionList fun addSection(tag: String?, subjectName: String?): ContentSection { @@ -193,9 +193,9 @@ public open class MutableContent() : Content() { return section } - public override val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty + override val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty - public override val description: ContentNode by lazy { + override val description: ContentNode by lazy { val descriptionNodes = children.drop(1) if (descriptionNodes.isEmpty()) { ContentEmpty diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt index 52881f65..35933aee 100644 --- a/core/src/main/kotlin/Model/DocumentationNode.kt +++ b/core/src/main/kotlin/Model/DocumentationNode.kt @@ -2,73 +2,73 @@ package org.jetbrains.dokka import java.util.* -public open class DocumentationNode(val name: String, - content: Content, - val kind: DocumentationNode.Kind) { +open class DocumentationNode(val name: String, + content: Content, + val kind: DocumentationNode.Kind) { private val references = LinkedHashSet<DocumentationReference>() var content: Content = content private set - public val summary: ContentNode get() = content.summary + val summary: ContentNode get() = content.summary - public val owner: DocumentationNode? + val owner: DocumentationNode? get() = references(DocumentationReference.Kind.Owner).singleOrNull()?.to - public val details: List<DocumentationNode> + val details: List<DocumentationNode> get() = references(DocumentationReference.Kind.Detail).map { it.to } - public val members: List<DocumentationNode> + val members: List<DocumentationNode> get() = references(DocumentationReference.Kind.Member).map { it.to } - public val inheritedMembers: List<DocumentationNode> + val inheritedMembers: List<DocumentationNode> get() = references(DocumentationReference.Kind.InheritedMember).map { it.to } - public val extensions: List<DocumentationNode> + val extensions: List<DocumentationNode> get() = references(DocumentationReference.Kind.Extension).map { it.to } - public val inheritors: List<DocumentationNode> + val inheritors: List<DocumentationNode> get() = references(DocumentationReference.Kind.Inheritor).map { it.to } - public val overrides: List<DocumentationNode> + val overrides: List<DocumentationNode> get() = references(DocumentationReference.Kind.Override).map { it.to } - public val links: List<DocumentationNode> + val links: List<DocumentationNode> get() = references(DocumentationReference.Kind.Link).map { it.to } - public val hiddenLinks: List<DocumentationNode> + val hiddenLinks: List<DocumentationNode> get() = references(DocumentationReference.Kind.HiddenLink).map { it.to } - public val annotations: List<DocumentationNode> + val annotations: List<DocumentationNode> get() = references(DocumentationReference.Kind.Annotation).map { it.to } - public val deprecation: DocumentationNode? + val deprecation: DocumentationNode? get() = references(DocumentationReference.Kind.Deprecation).singleOrNull()?.to // TODO: Should we allow node mutation? Model merge will copy by ref, so references are transparent, which could nice - public fun addReferenceTo(to: DocumentationNode, kind: DocumentationReference.Kind) { + fun addReferenceTo(to: DocumentationNode, kind: DocumentationReference.Kind) { references.add(DocumentationReference(this, to, kind)) } - public fun addAllReferencesFrom(other: DocumentationNode) { + fun addAllReferencesFrom(other: DocumentationNode) { references.addAll(other.references) } - public fun updateContent(body: MutableContent.() -> Unit) { + fun updateContent(body: MutableContent.() -> Unit) { if (content !is MutableContent) { content = MutableContent() } (content as MutableContent).body() } - public fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind } - public fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind } - public fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind } - public fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind } + fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind } + fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind } + fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind } + fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind } - public fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single() - public fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single() - public fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single() + fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single() + fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single() + fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single() - public fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind } - public fun allReferences(): Set<DocumentationReference> = references + fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind } + fun allReferences(): Set<DocumentationReference> = references - public override fun toString(): String { + override fun toString(): String { return "$kind:$name" } - public enum class Kind { + enum class Kind { Unknown, Package, @@ -121,7 +121,7 @@ public open class DocumentationNode(val name: String, } } -public class DocumentationModule(name: String, content: Content = Content.Empty) +class DocumentationModule(name: String, content: Content = Content.Empty) : DocumentationNode(name, content, DocumentationNode.Kind.Module) { } diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt index 898c92d7..99a1f434 100644 --- a/core/src/main/kotlin/Model/DocumentationReference.kt +++ b/core/src/main/kotlin/Model/DocumentationReference.kt @@ -2,8 +2,8 @@ package org.jetbrains.dokka import com.google.inject.Singleton -public data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReference.Kind) { - public enum class Kind { +data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReference.Kind) { + enum class Kind { Owner, Member, InheritedMember, diff --git a/core/src/main/kotlin/Model/PackageDocs.kt b/core/src/main/kotlin/Model/PackageDocs.kt index 044c73d8..5ebf2119 100644 --- a/core/src/main/kotlin/Model/PackageDocs.kt +++ b/core/src/main/kotlin/Model/PackageDocs.kt @@ -8,13 +8,13 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor import java.io.File @Singleton -public class PackageDocs +class PackageDocs @Inject constructor(val linkResolver: DeclarationLinkResolver?, val logger: DokkaLogger) { - public val moduleContent: MutableContent = MutableContent() + val moduleContent: MutableContent = MutableContent() private val _packageContent: MutableMap<String, MutableContent> = hashMapOf() - public val packageContent: Map<String, Content> + val packageContent: Map<String, Content> get() = _packageContent fun parse(fileName: String, linkResolveContext: LazyPackageDescriptor?) { diff --git a/core/src/main/kotlin/Utilities/Html.kt b/core/src/main/kotlin/Utilities/Html.kt index ce3a1982..a5a93d9e 100644 --- a/core/src/main/kotlin/Utilities/Html.kt +++ b/core/src/main/kotlin/Utilities/Html.kt @@ -5,4 +5,4 @@ package org.jetbrains.dokka * Replaces symbols reserved in HTML with their respective entities. * Replaces & with &, < with < and > with > */ -public fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">") +fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">") diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt index 7a5aff79..6c29d1cd 100644 --- a/core/src/main/kotlin/Utilities/ServiceLocator.kt +++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt @@ -9,8 +9,8 @@ data class ServiceDescriptor(val name: String, val category: String, val descrip class ServiceLookupException(message: String) : Exception(message) -public object ServiceLocator { - public fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { +object ServiceLocator { + fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { val descriptor = lookupDescriptor(category, implementationName) val loadedClass = javaClass.classLoader.loadClass(descriptor.className) val constructor = loadedClass.constructors @@ -66,7 +66,7 @@ public object ServiceLocator { } } -public inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String): T = lookup(T::class.java, category, implementationName) +inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String): T = lookup(T::class.java, category, implementationName) private val ZipEntry.fileName: String get() = name.substringAfterLast("/", name) diff --git a/core/src/main/kotlin/ant/dokka.kt b/core/src/main/kotlin/ant/dokka.kt index d78980f8..713bd193 100644 --- a/core/src/main/kotlin/ant/dokka.kt +++ b/core/src/main/kotlin/ant/dokka.kt @@ -1,12 +1,12 @@ package org.jetbrains.dokka.ant +import org.apache.tools.ant.BuildException +import org.apache.tools.ant.Project import org.apache.tools.ant.Task import org.apache.tools.ant.types.Path import org.apache.tools.ant.types.Reference -import org.apache.tools.ant.BuildException -import org.apache.tools.ant.Project -import org.jetbrains.dokka.DokkaLogger import org.jetbrains.dokka.DokkaGenerator +import org.jetbrains.dokka.DokkaLogger import org.jetbrains.dokka.SourceLinkDefinition import java.io.File @@ -19,48 +19,48 @@ class AntLogger(val task: Task): DokkaLogger { class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) class DokkaAntTask(): Task() { - public var moduleName: String? = null - public var outputDir: String? = null - public var outputFormat: String = "html" + var moduleName: String? = null + var outputDir: String? = null + var outputFormat: String = "html" - public var skipDeprecated: Boolean = false + var skipDeprecated: Boolean = false - public val compileClasspath: Path = Path(getProject()) - public val sourcePath: Path = Path(getProject()) - public val samplesPath: Path = Path(getProject()) - public val includesPath: Path = Path(getProject()) + val compileClasspath: Path = Path(getProject()) + val sourcePath: Path = Path(getProject()) + val samplesPath: Path = Path(getProject()) + val includesPath: Path = Path(getProject()) - public val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf() + val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf() - public fun setClasspath(classpath: Path) { + fun setClasspath(classpath: Path) { compileClasspath.append(classpath) } - public fun setClasspathRef(ref: Reference) { + fun setClasspathRef(ref: Reference) { compileClasspath.createPath().refid = ref } - public fun setSrc(src: Path) { + fun setSrc(src: Path) { sourcePath.append(src) } - public fun setSrcRef(ref: Reference) { + fun setSrcRef(ref: Reference) { sourcePath.createPath().refid = ref } - public fun setSamples(samples: Path) { + fun setSamples(samples: Path) { samplesPath.append(samples) } - public fun setSamplesRef(ref: Reference) { + fun setSamplesRef(ref: Reference) { samplesPath.createPath().refid = ref } - public fun setInclude(include: Path) { + fun setInclude(include: Path) { includesPath.append(include) } - public fun createSourceLink(): AntSourceLinkDefinition { + fun createSourceLink(): AntSourceLinkDefinition { val def = AntSourceLinkDefinition() antSourceLinks.add(def) return def diff --git a/core/src/main/kotlin/main.kt b/core/src/main/kotlin/main.kt index c0a24caf..91f30bb0 100644 --- a/core/src/main/kotlin/main.kt +++ b/core/src/main/kotlin/main.kt @@ -27,38 +27,38 @@ import kotlin.system.measureTimeMillis class DokkaArguments { @set:Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)") @ValueDescription("<path>") - public var src: String = "" + var src: String = "" @set:Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code") @ValueDescription("<path>=<url>[#lineSuffix]") - public var srcLink: String = "" + var srcLink: String = "" @set:Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)") @ValueDescription("<path>") - public var include: String = "" + var include: String = "" @set:Argument(value = "samples", description = "Source root for samples") @ValueDescription("<path>") - public var samples: String = "" + var samples: String = "" @set:Argument(value = "output", description = "Output directory path") @ValueDescription("<path>") - public var outputDir: String = "out/doc/" + var outputDir: String = "out/doc/" @set:Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") @ValueDescription("<name>") - public var outputFormat: String = "html" + var outputFormat: String = "html" @set:Argument(value = "module", description = "Name of the documentation module") @ValueDescription("<name>") - public var moduleName: String = "" + var moduleName: String = "" @set:Argument(value = "classpath", description = "Classpath for symbol resolution") @ValueDescription("<path>") - public var classpath: String = "" + var classpath: String = "" @set:Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation") - public var nodeprecated: Boolean = false + var nodeprecated: Boolean = false } @@ -69,7 +69,7 @@ private fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition { urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it }) } -public fun main(args: Array<String>) { +fun main(args: Array<String>) { val arguments = DokkaArguments() val freeArgs: List<String> = Args.parse(arguments, args) ?: listOf() val sources = if (arguments.src.isNotEmpty()) arguments.src.split(File.pathSeparatorChar).toList() + freeArgs else freeArgs |