aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-01-31 10:49:25 +0100
committerAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-02-04 12:10:59 +0100
commit3a13b81f2aebc255bec5e48b276c86b2d4ee16a2 (patch)
tree8aa55f2b725e247f6661386ffca4220c6a2c6125 /core
parentec8e0aa7dbdc74c381dfe9c012711a895ccac6d4 (diff)
downloaddokka-3a13b81f2aebc255bec5e48b276c86b2d4ee16a2.tar.gz
dokka-3a13b81f2aebc255bec5e48b276c86b2d4ee16a2.tar.bz2
dokka-3a13b81f2aebc255bec5e48b276c86b2d4ee16a2.zip
Handles errors and fixes minor bugs
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt2
-rw-r--r--core/src/main/kotlin/plugability/DefaultExtensions.kt2
-rw-r--r--core/src/main/kotlin/renderers/FileWriter.kt12
-rw-r--r--core/src/main/kotlin/utilities/DokkaLogging.kt11
4 files changed, 17 insertions, 10 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index add7eedb..138bd70d 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -163,7 +163,7 @@ class DokkaGenerator(
if (severity == CompilerMessageSeverity.ERROR) {
seenErrors = true
}
- logger.error(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location))
+ logger.info(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location))
}
override fun hasErrors() = seenErrors
diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt
index 91ab9cb8..e4a47ee1 100644
--- a/core/src/main/kotlin/plugability/DefaultExtensions.kt
+++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt
@@ -27,7 +27,7 @@ internal object DefaultExtensions {
CoreExtensions.documentationToPageTranslator -> DefaultDocumentationToPageTranslator
CoreExtensions.renderer -> renderer.get(fullContext)
CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext)
- CoreExtensions.outputWriter -> FileWriter(fullContext.configuration.outputDir, "")
+ CoreExtensions.outputWriter -> FileWriter(fullContext, "")
CoreExtensions.fileExtension -> ".html"
else -> null
}.let { listOfNotNull( it ) as List<T> }
diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt
index 996fadc8..3cb3b5b5 100644
--- a/core/src/main/kotlin/renderers/FileWriter.kt
+++ b/core/src/main/kotlin/renderers/FileWriter.kt
@@ -1,27 +1,29 @@
package org.jetbrains.dokka.renderers
+import org.jetbrains.dokka.plugability.DokkaContext
import java.io.File
import java.io.IOException
import java.net.URI
import java.nio.file.*
-class FileWriter(val root: String, override val extension: String) : OutputWriter {
+class FileWriter(val context: DokkaContext, override val extension: String): OutputWriter {
private val createdFiles: MutableSet<String> = mutableSetOf()
private val jarUriPrefix = "jar:file:"
-
+ private val root = context.configuration.outputDir
override fun write(path: String, text: String, ext: String) {
if (createdFiles.contains(path)) {
- println("ERROR. An attempt to write $root/$path several times!")
+ context.logger.error("An attempt to write ${root}/$path several times!")
return
}
createdFiles.add(path)
try {
+// println("Writing $root/$path$ext")
val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile()
dir.mkdirsOrFail()
Files.write(Paths.get(root, "$path$ext"), text.lines())
- } catch (e: Throwable) {
- println("Failed to write $this. ${e.message}")
+ } catch (e : Throwable) {
+ context.logger.error("Failed to write $this. ${e.message}")
e.printStackTrace()
}
}
diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt
index 6eb7867b..9fe15d59 100644
--- a/core/src/main/kotlin/utilities/DokkaLogging.kt
+++ b/core/src/main/kotlin/utilities/DokkaLogging.kt
@@ -10,6 +10,7 @@ interface DokkaLogger {
object DokkaConsoleLogger : DokkaLogger {
var warningCount: Int = 0
+ var errorCount: Int = 0
override fun debug(message: String)= println(message)
@@ -19,11 +20,15 @@ object DokkaConsoleLogger : DokkaLogger {
override fun warn(message: String) = println("WARN: $message").also { warningCount++ }
- override fun error(message: String) = println("ERROR: $message")
+ override fun error(message: String) = println("ERROR: $message").also { errorCount++ }
fun report() {
- if (warningCount > 0) {
- println("generation completed with $warningCount warnings")
+ if (warningCount > 0 || errorCount > 0) {
+ println("generation completed with $warningCount warning" +
+ (if(warningCount == 1) "" else "s") +
+ " and $errorCount error" +
+ if(errorCount == 1) "" else "s"
+ )
} else {
println("generation completed successfully")
}