-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize ExternalDocumentableProvider (#3312)
- Loading branch information
1 parent
610b552
commit e63dad0
Showing
17 changed files
with
455 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...n/kotlin/org/jetbrains/dokka/analysis/kotlin/documentable/ExternalDocumentableProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package org.jetbrains.dokka.analysis.kotlin.documentable | ||
|
||
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet | ||
import org.jetbrains.dokka.links.DRI | ||
import org.jetbrains.dokka.model.DClasslike | ||
import org.jetbrains.dokka.model.DClass | ||
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator | ||
|
||
/** | ||
* Helps find external documentables that are not provided by Dokka by default. | ||
* | ||
* By default, Dokka parses and makes available only documentables of the declarations found | ||
* in the user project itself. Meaning, if the project's source code contains a `fun foo()`, | ||
* it must be returned by [SourceToDocumentableTranslator]. However, if the user project | ||
* depends on an external library which has a `fun bar()`, it will __not__ be available and | ||
* documented out of the box. | ||
* | ||
* This provider helps you find documentables for the declarations that are present in | ||
* [DokkaSourceSet.classpath] during runtime, but are not necessarily from the user project itself. | ||
* | ||
* For example, it can help you find a class that comes from a dependency, which can be useful | ||
* if you want to get more information about a supertype of the project's class, | ||
* because [DClass.supertypes] only provides the supertype's DRI, but not its full documentable. | ||
* | ||
* It is expected to work with all languages supported by the analysis implementation, | ||
* meaning it should return Java classes if Java as an input language is supported. | ||
* | ||
* If you query DRIs of local project declarations (not external), it should generally work, although | ||
* it's not guaranteed that the returned value will be 100% equal to that provided by Dokka by default. | ||
* | ||
* Note: because classpath entries consist of compiled code, the returned documentables may have some | ||
* properties set to null or empty, because some information cannot be extracted from it in any way. | ||
* One such example is KDocs, they are present in source code, but not in compiled classes. | ||
*/ | ||
public interface ExternalDocumentableProvider { | ||
|
||
/** | ||
* Returns a valid and fully initialized [DClasslike] if the [dri] points to a class-like | ||
* declaration (annotation, class, enum, interface, object) that can be found among | ||
* [DokkaSourceSet.classpath] entries. | ||
* | ||
* If the [dri] points to a non-class-like declaration (like a function), | ||
* or the declaration cannot be found, it returns `null`. | ||
* | ||
* Note: the implementation is not expected to cache results or return pre-computed values, so | ||
* it may need to analyze parts of the project and instantiate new documentables on every invocation. | ||
* Use this function sparingly, and cache results on your side if you need to. | ||
*/ | ||
public fun getClasslike(dri: DRI, sourceSet: DokkaSourceSet): DClasslike? | ||
} |
28 changes: 0 additions & 28 deletions
28
...main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/ExternalDocumentablesProvider.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.