Skip to content

Commit e1dcacb

Browse files
committed
Update documentation
1 parent ce87129 commit e1dcacb

File tree

2 files changed

+91
-41
lines changed

2 files changed

+91
-41
lines changed

README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ described in the [Import](#import) section.
360360

361361
The fields or components of a configuration can be annotated with the `@Comment` annotation. This
362362
annotation takes an array of strings. Each of these strings is written onto a new line as a comment.
363-
Empty strings are written as newlines.
363+
The strings can contain `\n` characters. Empty strings are written as newlines (not as comments).
364364

365365
If a configuration type _C_ that defines comments is used (as a field or component) within another
366366
configuration type, the comments of _C_ are written with the proper indentation. However, if
@@ -620,17 +620,16 @@ This project contains three classes of modules:
620620

621621
## Import
622622

623-
**INFO:** I'm currently looking for an easier way for you to import this library that does not
624-
require authentication with GitHub. Please check
625-
this [issue](https://github.com/Exlll/ConfigLib/issues/12) if you have authentication problems.
623+
To use this library, import it into your project with Maven or Gradle. Examples of how to do that
624+
are at the end of this section within the spoilers. Currently, there are two repositories from
625+
which you can choose: [jitpack.io](https://jitpack.io/#Exlll/ConfigLib) and GitHub (which requires
626+
authentication, see this [issue](https://github.com/Exlll/ConfigLib/issues/12) if you have any
627+
problems).
626628

627-
To use this library, import it into your project with either Maven or Gradle as shown in the two
628-
examples below. This library has additional dependencies (namely, a YAML parser) which are not
629-
exposed by the artifact you import.
630-
631-
This repository provides plugin versions of this library which bundle all its dependencies, so you
632-
don't have to worry about them. Also, these versions make it easier for you to update this library
633-
if you have written multiple plugins that use it.
629+
This library has additional dependencies (namely, a YAML parser) which are not exposed by the
630+
artifact you import. The current repository provides plugin versions of this library which bundle
631+
all its dependencies, so you don't have to worry about them. Also, these versions make it easier for
632+
you to update this library if you have written multiple plugins that use it.
634633

635634
The plugin versions can be downloaded from
636635
the [releases page](https://github.com/Exlll/ConfigLib/releases) where you can identify them by
@@ -642,11 +641,52 @@ Waterfall) or to the dependencies array (for Velocity) of your own plugin.
642641
Alternatively, if you don't want to use an extra plugin, you can shade the `-yaml` version with its
643642
YAML parser yourself.
644643

645-
**NOTE:** If you want serialization support for Bukkit classes like `ItemStack`,
646-
replace `configlib-yaml` with `configlib-paper`
647-
(see [here](#support-for-bukkit-classes-like-itemstack)).
644+
### Import examples
645+
646+
If you want serialization support for Bukkit classes like `ItemStack`, replace `configlib-yaml`
647+
with `configlib-paper` (see [here](#support-for-bukkit-classes-like-itemstack)).
648+
649+
<details>
650+
<summary>Import via <code>jitpack.io</code></summary>
651+
652+
**Maven**
653+
654+
```xml
655+
<repository>
656+
<id>jitpack.io</id>
657+
<url>https://jitpack.io</url>
658+
</repository>
659+
660+
<dependency>
661+
<groupId>com.github.Exlll.ConfigLib</groupId>
662+
<artifactId>configlib-yaml</artifactId>
663+
<version>v4.1.0</version>
664+
</dependency>
665+
```
666+
667+
**Gradle**
648668

649-
#### Maven
669+
```groovy
670+
repositories { maven { url 'https://jitpack.io' } }
671+
672+
dependencies { implementation 'com.github.Exlll.ConfigLib:configlib-yaml:v4.1.0' }
673+
```
674+
675+
```kotlin
676+
repositories { maven { url = uri("https://jitpack.io") } }
677+
678+
dependencies { implementation("com.github.Exlll.ConfigLib:configlib-yaml:v4.1.0") }
679+
```
680+
681+
</details>
682+
683+
<details>
684+
<summary>Import via GitHub</summary>
685+
686+
Importing via GitHub requires authentication. Check
687+
this [issue](https://github.com/Exlll/ConfigLib/issues/12) if you have any trouble with that.
688+
689+
**Maven**
650690

651691
```xml
652692
<repository>
@@ -661,7 +701,7 @@ replace `configlib-yaml` with `configlib-paper`
661701
</dependency>
662702
```
663703

664-
#### Gradle
704+
**Gradle**
665705

666706
```groovy
667707
repositories { maven { url 'https://maven.pkg.github.com/Exlll/ConfigLib' } }
@@ -675,6 +715,8 @@ repositories { maven { url = uri("https://maven.pkg.github.com/Exlll/ConfigLib")
675715
dependencies { implementation("de.exlll:configlib-yaml:4.0.0") }
676716
```
677717

718+
</details>
719+
678720
## Future work
679721

680722
This section contains ideas for upcoming features. If you want any of these to happen any time soon,

configlib-core/src/test/java/de/exlll/configlib/CommentNodeExtractorTest.java

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ record R(@Comment({"Hello", "World"}) int i) {}
7474
void extractSingleCommentMultipleLines() {
7575
@Configuration
7676
class A {
77-
@Comment("""
77+
@Comment(
78+
"""
7879
Hello
79-
World""")
80+
World\
81+
"""
82+
)
8083
int i;
8184
}
8285

@@ -89,18 +92,18 @@ class A {
8992
void extractSingleCommentMultipleLinesTrailingNewlines() {
9093
@Configuration
9194
class A {
92-
93-
@Comment("""
94-
95-
95+
@Comment(
96+
"""
97+
98+
9699
Hello
97-
100+
98101
World
99-
100-
101-
""")
102+
103+
104+
"""
105+
)
102106
int i;
103-
104107
}
105108

106109
Queue<CommentNode> nodes = EXTRACTOR.extractCommentNodes(new A());
@@ -112,14 +115,17 @@ class A {
112115
void extractSingleCommentMultipleLinesInArrayAndNewlineSplit() {
113116
@Configuration
114117
class A {
115-
116-
@Comment({ """
118+
@Comment({
119+
"""
117120
Hello
118-
World""", """
121+
World\
122+
""",
123+
"""
119124
Hi
120-
Again""" })
125+
Again\
126+
"""
127+
})
121128
int i;
122-
123129
}
124130

125131
Queue<CommentNode> nodes = EXTRACTOR.extractCommentNodes(new A());
@@ -131,18 +137,20 @@ class A {
131137
void extractSingleCommentMultipleLinesInArrayAndNewlineSplitWithTrailingNewlines() {
132138
@Configuration
133139
class A {
134-
135-
@Comment({ """
136-
140+
@Comment({
141+
"""
142+
137143
Hello
138144
World
139-
140-
""", """
141-
145+
146+
""",
147+
"""
148+
142149
Hi
143150
Again
144-
145-
""" })
151+
152+
"""
153+
})
146154
int i;
147155

148156
}
@@ -604,4 +612,4 @@ record R(@Comment({"A", "B"}) A a) {}
604612
private static CommentNode cn(List<String> comments, String... elementNames) {
605613
return new CommentNode(comments, List.of(elementNames));
606614
}
607-
}
615+
}

0 commit comments

Comments
 (0)