Skip to content

Commit

Permalink
interpret Group annotations present on the enclosing package of eleme…
Browse files Browse the repository at this point in the history
…nts, to avoid duplicating annotations + bump versions
  • Loading branch information
Steanky committed Feb 18, 2023
1 parent bfd4e82 commit 76d6d16
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion autodoc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.github.steanky"
version = "0.1.1"
version = "0.1.2"

val functionalTest: SourceSet by sourceSets.creating

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ abstract class AutodocTask : SourceTask() {
return group.value
}

super.processingEnv.elementUtils.getPackageOf(this)?.getAnnotation(Group::class.java)?.let { group ->
return group.value
}

logger.error("Element $this missing Group annotation")
return ""
}
Expand Down Expand Up @@ -410,10 +414,9 @@ abstract class AutodocTask : SourceTask() {
return "any"
}

collectionType("set", typeUtils, componentType, setType) ?:
return collectionType("set", typeUtils, componentType, setType) ?:
collectionType("list", typeUtils, componentType, collectionType) ?:
mapType(typeUtils, componentType) ?:
return componentType.asElement().simpleName.toString()
mapType(typeUtils, componentType) ?: componentType.asElement().simpleName.toString()
}
TypeKind.TYPEVAR -> {
componentType as TypeVariable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "com.github.steanky"
version = "0.14.0"
version = "0.14.1"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
/**
* When applied to an element type, specifies a group string. This is a general category used for documentation
* purposes.
* <p>
* If applied to a package, the group name will be applied to all element objects present in the package, so long as
* they don't specify their own Group annotation.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
@Target({ElementType.TYPE, ElementType.PACKAGE})
public @interface Group {
/**
* The group string.
Expand Down

0 comments on commit 76d6d16

Please sign in to comment.