dokka: suppressedFiles / perPackageOption: suppress do not work with Java sources
Neither suppression option results in the specified package hierarchy or file path hierarchy being excluded from documentation when the project being documented is written in Java. Both options appear to have no effect.
Expected behaviour Suppressed packages (and their subpackages), and suppressed file paths, are excluded from documentation.
To Reproduce Apply the below configuration stanzas to a project written in Java. Configure Dokka with the kotlin-as-java-plugin.
Dokka configuration
// Tried this
perPackageOption {
prefix = "com.example.exampleapp.internal"
suppress = true
}
// Also tried
suppressedFiles = ["src/main/java/com/example/exampleapp/internal"]
I also tried the newer syntax:
// Tried this
perPackageOption {
prefix.set("com.example.exampleapp.internal")
suppress.set(true)
}
// Also tried
suppressedFiles.setFrom(files("src/main/java/com/example/exampleapp/internal"))
Installation
- Operating system: macOS
- Build tool: Gradle v6.6
- Dokka version: 1.4.0
Additional context
- I have not tested this with a Kotlin project yet, but I assume that this is Java specific or someone would have reported a general issue with these options not working by now.
- I have tried dev builds in the 1.4.10 series and they exhibit the same problem (latest tested: dev-72).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 15 (8 by maintainers)
Having the same issue. Our Android library uses both Java and Kotlin classes. Even the simplest configuration option:
doesn’t work - the internal package is not suppressed.
Tested on
TBH it isn’t a common scenario. Most of the time your public API is what you want to document, apart from the tests, which should have their separate package(s) and then you can just suppress this package. Anyway, suppressing files is not possible (you can probably not document them by manually setting the sourceRoots to the other files, but this is kind of not worth it), you can however suppress a certain class with the
@suppressannotation I believe: https://kotlinlang.org/docs/kotlin-doc.html Javadoc comments don’t support any suppressing whatsoever, so there is an Android plugin for Dokka which adds support for the@hideannotation: http://kotlin.github.io/dokka/1.4.32/user_guide/android-plugin/android-plugin/Thanks for the feedback @robertszuba ! Yeah, I agree that we should have some warnings about that, but I think that those information is not available to us. This is a Gradle configuration and their DSL does not provide any info on which notation was used. I’m also surprised that the old syntax prevented the new one from working correctly, but as I said before, I strongly advise using
ktsfiles, because you’d spot those errors way faster (eg. escaping is highlighted, error messages are more meaningful and so on, I believe that even the old syntax does not compile there. Also you can always mix.ktsand.gradlefiles, so migration shouldn’t be that hard)Thank you so much for the reply! I understand it might not be common scenario, it’s probably more of an architecture decision, but anyway, the
@suppresstag did the magic for me (since my library is purely written in Kotlin), and i’m really happy it worked out.To sum up and help other in this situation, using the dokka version 1.4.30+, you can do it like this:
To supress a whole package (works for both Java and Kotlin classes): Here i show
dokkaHtmlbut you can use any of the other formats, such asdokkaJavadoc.To suppress a file/class: (only for Kotlin docs) Add this to you class documentation.
For javadoc, like @kamildoleglo said, you would need the plugin http://kotlin.github.io/dokka/1.4.32/user_guide/android-plugin/android-plugin/ and use the
@hideannotation instead of@suppress.Hey guys, sorry for bringing this topic up again, but I have been a couple of days trying to suppress packages and files. Only after reading this I was able to suppress a package.
But… What about files/classes?
What if I have only 1 class in the package that I want to suppress documentation and the others not? Has anyone done this successfully?
I’ve tried using
matchingRegex.set("com.example.test.MyClass")and it just won’t work. Apparently it only supresses if the regex matches a package.I’ve searched for a while and couldn’t find any answer for this, I am surprised how no one is talking about it being such a common scenario.