Skip to content

Commit 3baf40a

Browse files
committed
Add java docs
1 parent 0dac94b commit 3baf40a

File tree

7 files changed

+72
-8
lines changed

7 files changed

+72
-8
lines changed

build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ tasks {
5454
test {
5555
useJUnitPlatform()
5656
}
57+
dokkaHtml {
58+
dokkaSourceSets {
59+
named("main") {
60+
moduleName.set("Plugin Debug")
61+
includes.from("module.md")
62+
}
63+
}
64+
}
65+
dokkaJavadoc {
66+
dokkaSourceSets {
67+
named("main") {
68+
moduleName.set("Plugin Debug")
69+
includes.from("module.md")
70+
71+
}
72+
}
73+
}
5774
}
5875

5976
kotlin {

module.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Package dev.themeinerlp.plugindebug
2+
Contains the main files to create a debug upload

src/main/kotlin/dev/themeinerlp/plugindebug/DebugBuilder.kt

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ import kotlin.io.path.fileSize
1414
import kotlin.io.path.writeText
1515
import kotlin.jvm.optionals.getOrNull
1616

17+
/**
18+
* Simple builder to collect debug files and upload them to a custom bytebin server
19+
* Ex:
20+
* <pre class="prettyprint">
21+
* DebugBuilder.builder("https://bytebin.lucko.me/")...
22+
* </pre>
23+
*/
1724
class DebugBuilder private constructor(private val uploadServer: String) {
1825
private val fileToUpload: MutableList<DebugFile> = mutableListOf()
1926
private var maxPartFileSize: Long = 2_097_152
@@ -27,12 +34,19 @@ class DebugBuilder private constructor(private val uploadServer: String) {
2734
.setLenient()
2835
.create()
2936

30-
37+
/**
38+
* Add a debug file RAW into the debug zip
39+
*/
3140
fun addFile(file: DebugFile): DebugBuilder {
3241
fileToUpload.add(file)
3342
return this
3443
}
35-
44+
/**
45+
* Add a debug file RAW into the debug zip
46+
* @param filePath to collect into the zip
47+
* @param fileType to display in the frontend
48+
* @param uiTabName to display tn the frontend
49+
*/
3650
fun addFile(
3751
filePath: Path,
3852
fileType: FileType,
@@ -42,28 +56,45 @@ class DebugBuilder private constructor(private val uploadServer: String) {
4256
return this
4357
}
4458

45-
59+
/**
60+
* Add a text as a file into the debug zip
61+
* @param text to collect into the zip
62+
* @param uiTabName to display tn the frontend
63+
*/
4664
fun addText(text: String, uiTabName: String): DebugBuilder {
4765
val textFile = Files.createTempFile(tempPrefix, ".txt")
4866
textFile.writeText(text)
4967
fileToUpload.add(DebugFile(textFile, FileType.TEXT, uiTabName))
5068
return this
5169
}
52-
70+
/**
71+
* Add a json string as a file into the debug zip
72+
* @param json to collect into the zip
73+
* @param uiTabName to display tn the frontend
74+
*/
5375
fun addJson(json: String, uiTabName: String): DebugBuilder {
5476
val textFile = Files.createTempFile(tempPrefix, ".json")
5577
textFile.writeText(json)
5678
fileToUpload.add(DebugFile(textFile, FileType.JSON, uiTabName))
5779
return this
5880
}
59-
60-
fun addYAML(json: String, uiTabName: String): DebugBuilder {
81+
/**
82+
* Add a yaml string as a file into the debug zip
83+
* @param yaml to collect into the zip
84+
* @param uiTabName to display tn the frontend
85+
*/
86+
fun addYAML(yaml: String, uiTabName: String): DebugBuilder {
6187
val textFile = Files.createTempFile(tempPrefix, ".yml")
62-
textFile.writeText(json)
88+
textFile.writeText(yaml)
6389
fileToUpload.add(DebugFile(textFile, FileType.YAML, uiTabName))
6490
return this
6591
}
66-
92+
/**
93+
* Upload all collected files in a zip with a debug.json to a custom bytebin server.
94+
* @throws IllegalStateException when the zip file is bigger than 2mb(binary)
95+
* @throws IllegalStateException when no code was returned
96+
* @return an object with the given server and the uploaded code
97+
*/
6798
@Throws(IllegalStateException::class)
6899
fun upload(): DebugUploadResult {
69100
val tempFolder = Files.createTempDirectory(tempPrefix)
@@ -95,6 +126,10 @@ class DebugBuilder private constructor(private val uploadServer: String) {
95126
}
96127

97128
companion object {
129+
/**
130+
* Creates a builder instance with the given bytebin server
131+
* @param uploadServer bytebin server base url
132+
*/
98133
@JvmStatic
99134
fun builder(uploadServer: String): DebugBuilder = DebugBuilder(uploadServer)
100135
}

src/main/kotlin/dev/themeinerlp/plugindebug/DebugFile.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package dev.themeinerlp.plugindebug
22

33
import java.nio.file.Path
44

5+
/**
6+
* Just a simple placeholder to referenced to the file and there to displaying file type and also the menu tab on den ui
7+
*/
58
class DebugFile(
69
val filePath: Path,
710
val fileType: FileType,

src/main/kotlin/dev/themeinerlp/plugindebug/DebugUploadResult.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package dev.themeinerlp.plugindebug
22

3+
/**
4+
* Result after uploaded the zip file to a bytepin server
5+
*/
36
class DebugUploadResult(
47
val code: String,
58
val uploadServer: String

src/main/kotlin/dev/themeinerlp/plugindebug/FileType.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package dev.themeinerlp.plugindebug
22

3+
/**
4+
* File type for parsing in the frontend
5+
*/
36
enum class FileType {
47
LOG,
58
YAML,

src/main/kotlin/dev/themeinerlp/plugindebug/constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@file:JvmName("Constants")
12
package dev.themeinerlp.plugindebug
23

34
val PRIVACY_REGEX =

0 commit comments

Comments
 (0)