Skip to content

Commit 76d6d16

Browse files
committed
interpret Group annotations present on the enclosing package of elements, to avoid duplicating annotations + bump versions
1 parent bfd4e82 commit 76d6d16

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

autodoc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group = "com.github.steanky"
11-
version = "0.1.1"
11+
version = "0.1.2"
1212

1313
val functionalTest: SourceSet by sourceSets.creating
1414

autodoc/src/main/kotlin/com/github/steanky/element/gradle/plugin/autodoc/AutodocTask.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ abstract class AutodocTask : SourceTask() {
173173
return group.value
174174
}
175175

176+
super.processingEnv.elementUtils.getPackageOf(this)?.getAnnotation(Group::class.java)?.let { group ->
177+
return group.value
178+
}
179+
176180
logger.error("Element $this missing Group annotation")
177181
return ""
178182
}
@@ -410,10 +414,9 @@ abstract class AutodocTask : SourceTask() {
410414
return "any"
411415
}
412416

413-
collectionType("set", typeUtils, componentType, setType) ?:
417+
return collectionType("set", typeUtils, componentType, setType) ?:
414418
collectionType("list", typeUtils, componentType, collectionType) ?:
415-
mapType(typeUtils, componentType) ?:
416-
return componentType.asElement().simpleName.toString()
419+
mapType(typeUtils, componentType) ?: componentType.asElement().simpleName.toString()
417420
}
418421
TypeKind.TYPEVAR -> {
419422
componentType as TypeVariable

buildSrc/src/main/kotlin/element.java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = "com.github.steanky"
6-
version = "0.14.0"
6+
version = "0.14.1"
77

88
java {
99
toolchain.languageVersion.set(JavaLanguageVersion.of(17))

core/src/main/java/com/github/steanky/element/core/annotation/document/Group.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
/**
88
* When applied to an element type, specifies a group string. This is a general category used for documentation
99
* purposes.
10+
* <p>
11+
* If applied to a package, the group name will be applied to all element objects present in the package, so long as
12+
* they don't specify their own Group annotation.
1013
*/
1114
@Documented
1215
@Retention(RetentionPolicy.SOURCE)
13-
@Target(ElementType.TYPE)
16+
@Target({ElementType.TYPE, ElementType.PACKAGE})
1417
public @interface Group {
1518
/**
1619
* The group string.

0 commit comments

Comments
 (0)