Skip to content

Commit 298f6ba

Browse files
committed
[auto] Reflect the changes of main repository.
1 parent 0c09301 commit 298f6ba

File tree

9 files changed

+562
-656
lines changed

9 files changed

+562
-656
lines changed

README.md

Lines changed: 8 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,11 @@
11
# 🐕 qq-tree
22

33
**qq-tree** is a Kotlin library that can construct a tree structure.
4-
- Just copy and paste 🟦 Single-File version [QTreeNode.kt](src-single/QTreeNode.kt) into your project.
5-
- Or you can use 🟩 Split-File Jar version. See [Maven Dependency Section](#-split-file-jar-version-maven-dependency).
6-
- Feel free to fork or copy to your own codebase.
7-
8-
## Example
9-
10-
### output
11-
<p align="center">
12-
<img src="img/001-num-unicode.png" width="203" alt="001-num-unicode.png">
13-
<img src="img/002-num-ascii.png" width="194" alt="002-num-ascii.png">
14-
</p>
15-
<p align="center">
16-
<img src="img/003-walk-tree.png" width="443" alt="003-walk-tree.png">
17-
</p>
18-
<p align="center">
19-
<img src="img/004-string-tree.png" width="250" alt="004-string-tree.png">
20-
<img src="img/005-dir-tree.png" width="195" alt="005-dir-tree.png">
21-
</p>
22-
23-
### code
24-
25-
Full Source [QTreeNodeExample.kt](src-example/QTreeNodeExample.kt)
26-
27-
```kotlin
28-
fun main() {
29-
// First, you have to create the root node.
30-
val root = QTreeNode(0)
31-
32-
val node1 = root add 1
33-
val node2 = root add 2
34-
val node3 = node2 add 3
35-
val node4 = node2 add 4
36-
val node5 = node4 add 5
37-
val node6 = node4 add 6
38-
val node7 = node2 add 7
39-
40-
val unicodeTree = root.tree(color = QShColor.GREEN, style = QTreeStyle.UNICODE)
41-
42-
println(unicodeTree)
43-
44-
val asciiTree = root.tree(color = QShColor.BLUE, style = QTreeStyle.ASCII)
45-
46-
println(asciiTree)
47-
48-
println()
49-
50-
val depthFirstResult = root.descendantsList(QSearchAlgo.DepthFirst).toString()
51-
52-
println("DepthFirst : $depthFirstResult") // [0, 1, 2, 3, 4, 5, 6, 7]
534

54-
val breadthFirstResult = root.descendantsList(QSearchAlgo.BreadthFirst).toString()
55-
56-
println("BreadthFirst : $breadthFirstResult") // [0, 1, 2, 3, 4, 7, 5, 6]
57-
58-
println()
59-
60-
// node can store anything
61-
val rootA = QTreeNode("A")
62-
val nodeB = rootA add "B"
63-
val nodeC = nodeB add "C"
64-
val nodeD = nodeB add "D"
65-
val nodeE = nodeD add "E"
66-
val nodeF = nodeE add "F"
67-
val nodeG = nodeC add "G"
68-
69-
val textTree = rootA.tree(color = QShColor.CYAN, style = QTreeStyle.UNICODE)
70-
71-
println(textTree)
72-
73-
// You can implement QLazyNode for more complicated situations.
74-
class QFileNode(override val value: Path) : QLazyTreeNode<Path> {
75-
override fun hasChildNodesToFill(): Boolean {
76-
return value.isDirectory()
77-
}
78-
79-
override fun fillChildNodes(): List<QFileNode> = Files.walk(value, 1).filter {
80-
it != value
81-
}.map {
82-
QFileNode(it)
83-
}.toList()
84-
85-
override fun toTreeNodeString(): String {
86-
return value.name
87-
}
88-
}
89-
90-
val rootDir = Paths.get("rsc-test/root-dir").toAbsolutePath()
5+
- Just copy and paste 🟦 Single-File version [QTreeNode.kt](src-single/QTreeNode.kt) into your project.- Or you can use 🟩 Split-File Jar version. See [Maven Dependency Section](#-split-file-jar-version-maven-dependency).
6+
- Feel free to fork or copy to your own codebase.
917

92-
val fileTree = QFileNode(rootDir).fillTree(maxDepth = 2).tree()
938

94-
println(fileTree)
95-
}
96-
```
97-
98-
Please see [QTreeNodeTest.kt](src-test-split/nyab/util/QTreeNodeTest.kt) for more code examples.
99-
Single-File version [src-test-single/QTreeNodeTest.kt](src-test-single/QTreeNodeTest.kt) is a self-contained source code that includes a runnable main function.
100-
You can easily copy and paste it into your codebase.
1019

10210
## 🟦 Single-File version Dependency
10311

@@ -126,7 +34,7 @@ repositories {
12634
}
12735
12836
dependencies {
129-
implementation 'com.github.nyabkun:qq-tree:v2023-05-22'
37+
implementation 'com.github.nyabkun:qq-tree:v2023-05-28'
13038
}
13139
```
13240

@@ -138,7 +46,7 @@ repositories {
13846
}
13947

14048
dependencies {
141-
implementation("com.github.nyabkun:qq-tree:v2023-05-22")
49+
implementation("com.github.nyabkun:qq-tree:v2023-05-28")
14250
}
14351
```
14452

@@ -157,16 +65,14 @@ dependencies {
15765
<dependency>
15866
<groupId>com.github.nyabkun</groupId>
15967
<artifactId>qq-tree</artifactId>
160-
<version>v2023-05-22</version>
68+
<version>v2023-05-28</version>
16169
</dependency>
16270
</dependencies>
16371
```
16472

16573
## How did I create this library
16674

167-
I created this library by developing a program within my own codebase that automatically resolves dependencies at the method or property level, extracts necessary code elements, and generates a compact, self-contained, single-file library.
168-
169-
The program uses [PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) to resolve dependencies for function calls and references to classes.
170-
171-
Although my original repository is currently disorganized, I have been gradually extracting and publishing small libraries. I also plan to prepare the original repository for publication in the future
75+
- I developed [qq-compact-lib](https://github.com/nyabkun/qq-compact-lib) that resolves dependencies and generates compact, self-contained libraries.
76+
- It utilizes [PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) to resolve function calls and class references.
77+
- The original repository is currently being organized, and I'm gradually extracting and publishing smaller libraries.
17278

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
v2023-05-22
2-
8a0b25a1ba01b5f4b9c4956d63687a5a55d231a8fa313cfac656fe3e116334433432dd1254fbf89cd8c881f93b13f2691ac4fb0ae661b01556a875dede926d0e
1+
v2023-05-28
2+
f5b4d712c22124fd15407d08997388b76e203043bd70d311e0d99743b371686862e5dc3710e95643d6996905b36afa739d1a85608de21f0974de692eb1475d3b

build.gradle.kts

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ plugins {
2929

3030
group = "com.nyabkun.qol"
3131

32-
version = "v2023-05-22"
32+
version = "v2023-05-28"
3333

3434
repositories {
3535
mavenCentral()
@@ -45,38 +45,37 @@ java {
4545

4646

4747
sourceSets.main {
48-
java.srcDirs("src-split")
48+
java.srcDirs("src-split")
4949

50-
resources.srcDirs("rsc")
51-
}
52-
53-
sourceSets.test {
54-
java.srcDirs("src-test-split")
55-
56-
resources.srcDirs("rsc-test")
57-
}
58-
59-
sourceSets.register("example") {
60-
java.srcDirs("src-example")
61-
62-
resources.srcDirs("rsc")
63-
64-
val jarFile = "$buildDir/libs/$qMavenArtifactId-$version.jar"
65-
compileClasspath += files(jarFile)
66-
runtimeClasspath += files(jarFile)
67-
}
68-
69-
tasks.getByName("compileExampleKotlin").dependsOn("jar")
70-
71-
val exampleImplementation: Configuration by configurations.getting {
72-
extendsFrom(configurations.implementation.get())
73-
}
50+
resources.srcDirs("rsc")
51+
}
7452

75-
val exampleRuntimeOnly: Configuration by configurations.getting {
76-
extendsFrom(configurations.runtimeOnly.get())
77-
}
53+
sourceSets.test {
54+
java.srcDirs("src-test-split")
7855

79-
sourceSets.register("single") {
56+
resources.srcDirs("rsc-test")
57+
}
58+
59+
sourceSets.register("example") {
60+
java.srcDirs("src-example")
61+
val jarFile = "$buildDir/libs/$qMavenArtifactId-$version.jar"
62+
compileClasspath += files(jarFile)
63+
runtimeClasspath += files(jarFile)
64+
65+
resources.srcDirs("rsc")
66+
}
67+
68+
tasks.getByName("compileExampleKotlin").dependsOn("jar")
69+
70+
val exampleImplementation: Configuration by configurations.getting {
71+
extendsFrom(configurations.implementation.get())
72+
}
73+
74+
val exampleRuntimeOnly: Configuration by configurations.getting {
75+
extendsFrom(configurations.runtimeOnly.get())
76+
}
77+
78+
sourceSets.register("single") {
8079
java.srcDirs("src-single")
8180
}
8281

@@ -112,13 +111,13 @@ tasks {
112111
enabled = true
113112

114113
archiveBaseName.set(qMavenArtifactId)
115-
114+
116115
from(sourceSets.main.get().output)
117-
116+
118117
manifest {
119118
attributes(
120-
"Implementation-Title" to qMavenArtifactId,
121-
"Implementation-Version" to project.version
119+
"Implementation-Title" to qMavenArtifactId,
120+
"Implementation-Version" to project.version
122121
)
123122
}
124123
}
@@ -128,7 +127,7 @@ tasks {
128127
archiveClassifier.set("sources")
129128
from(sourceSets.main.get().allSource)
130129
}
131-
130+
132131
artifacts {
133132
archives(qSrcJar)
134133
archives(jar)

0 commit comments

Comments
 (0)