generated from Kotlin/dokka-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from nomisRev/sv-fix-classpath-sample
Propagate Ank changes to Dokka, and parallelise processor
- Loading branch information
Showing
12 changed files
with
347 additions
and
77 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rootProject.name = "awesome-dokka-plugin" | ||
rootProject.name = "ank-dokka-plugin" | ||
include("sample") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.github.nomisrev.ank | ||
|
||
import org.jetbrains.dokka.model.DModule | ||
import org.jetbrains.dokka.model.doc.CodeBlock | ||
|
||
// Get all codeBlocks => write some dump version | ||
private fun List<DModule>.allCodeBlocks(): List<CodeBlock> = | ||
flatMap { module -> | ||
module.packages.flatMap { `package` -> | ||
`package`.children.flatMap { documentable -> | ||
documentable.documentation.values.flatMap { node -> | ||
node.children.flatMap { tagWrapper -> | ||
tagWrapper.children.mapNotNull { docTag -> | ||
(docTag as? CodeBlock) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun List<DModule>.allSnippets(): List<Snippet> = | ||
flatMap { module -> | ||
module.packages.flatMap { `package` -> | ||
`package`.children.flatMap { documentable -> | ||
documentable.documentation.values.flatMap { node -> | ||
node.children.flatMap { wrapper -> | ||
wrapper.children.mapNotNull { docTag -> | ||
(docTag as? CodeBlock)?.let { code -> | ||
code.params["lang"]?.let { fence -> | ||
fenceRegexStart.matchEntire(fence)?.let { match -> | ||
docTag.asStringOrNull()?.let { rawCode -> | ||
val lang = match.groupValues[1].trim() | ||
val path = SnippetPath(module, `package`, documentable, node, wrapper, code) | ||
Snippet(path, fence, lang, rawCode) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,130 @@ | ||
package com.github.nomisrev.ank | ||
|
||
import arrow.fx.coroutines.parTraverse | ||
import org.jetbrains.dokka.model.DAnnotation | ||
import org.jetbrains.dokka.model.DClass | ||
import org.jetbrains.dokka.model.DClasslike | ||
import org.jetbrains.dokka.model.DEnum | ||
import org.jetbrains.dokka.model.DInterface | ||
import org.jetbrains.dokka.model.DModule | ||
import org.jetbrains.dokka.model.DObject | ||
import org.jetbrains.dokka.model.DPackage | ||
import org.jetbrains.dokka.model.Documentable | ||
import org.jetbrains.dokka.model.SourceSetDependent | ||
import org.jetbrains.dokka.model.doc.Author | ||
import org.jetbrains.dokka.model.doc.CodeBlock | ||
import org.jetbrains.dokka.model.doc.CodeInline | ||
import org.jetbrains.dokka.model.doc.Constructor | ||
import org.jetbrains.dokka.model.doc.CustomDocTag | ||
import org.jetbrains.dokka.model.doc.CustomTagWrapper | ||
import org.jetbrains.dokka.model.doc.Deprecated | ||
import org.jetbrains.dokka.model.doc.Description | ||
import org.jetbrains.dokka.model.doc.DocTag | ||
import org.jetbrains.dokka.model.doc.DocumentationNode | ||
import org.jetbrains.dokka.model.doc.Param | ||
import org.jetbrains.dokka.model.doc.Property | ||
import org.jetbrains.dokka.model.doc.Receiver | ||
import org.jetbrains.dokka.model.doc.Return | ||
import org.jetbrains.dokka.model.doc.Sample | ||
import org.jetbrains.dokka.model.doc.See | ||
import org.jetbrains.dokka.model.doc.Since | ||
import org.jetbrains.dokka.model.doc.Suppress | ||
import org.jetbrains.dokka.model.doc.TagWrapper | ||
import org.jetbrains.dokka.model.doc.Throws | ||
import org.jetbrains.dokka.model.doc.Version | ||
|
||
|
||
/** | ||
* This methods gives you all info available for a detected `CodeBlock`. | ||
* It **does not** filter the list, but if you return a non-null value it will | ||
* update the existing value in the [DModule] | ||
*/ | ||
suspend fun List<DPackage>.parTraverseCodeBlock( | ||
dModule: DModule, | ||
transform: (module: DModule, `package`: DPackage, documentable: Documentable, node: DocumentationNode, wrapper: TagWrapper, CodeBlock) -> CodeBlock? | ||
): List<DPackage> = parTraverse { `package` -> | ||
`package`.copy( | ||
properties = `package`.properties.map { property -> | ||
property.copy(documentation = property.documentation.process(dModule, `package`, property, transform)) | ||
}, | ||
functions = `package`.functions.map { function -> | ||
function.copy(documentation = function.documentation.process(dModule, `package`, function, transform)) | ||
}, | ||
classlikes = `package`.classlikes.map { it.process(dModule, `package`, transform) }, | ||
typealiases = `package`.typealiases.map { typeAlias -> | ||
typeAlias.copy(documentation = typeAlias.documentation.process(dModule, `package`, typeAlias, transform)) | ||
} | ||
) | ||
} | ||
|
||
private fun DClasslike.process( | ||
module: DModule, | ||
`package`: DPackage, | ||
transform: (module: DModule, `package`: DPackage, documentable: Documentable, node: DocumentationNode, wrapper: TagWrapper, CodeBlock) -> CodeBlock? | ||
): DClasslike = | ||
when (this) { | ||
is DClass -> copy(documentation = documentation.process(module, `package`, this, transform)) | ||
is DEnum -> copy(documentation = documentation.process(module, `package`, this, transform)) | ||
is DInterface -> copy(documentation = documentation.process(module, `package`, this, transform)) | ||
is DObject -> copy(documentation = documentation.process(module, `package`, this, transform)) | ||
is DAnnotation -> copy(documentation = documentation.process(module, `package`, this, transform)) | ||
} | ||
|
||
private fun SourceSetDependent<DocumentationNode>.process( | ||
module: DModule, | ||
`package`: DPackage, | ||
documentable: Documentable, | ||
transform: (module: DModule, `package`: DPackage, documentable: Documentable, node: DocumentationNode, wrapper: TagWrapper, code: CodeBlock) -> CodeBlock? | ||
): SourceSetDependent<DocumentationNode> = | ||
mapValues { (_, node) -> node.process(module, `package`, documentable, node, transform) } | ||
|
||
private fun DocumentationNode.process( | ||
module: DModule, | ||
`package`: DPackage, | ||
documentable: Documentable, | ||
node: DocumentationNode, | ||
transform: (module: DModule, `package`: DPackage, documentable: Documentable, node: DocumentationNode, wrapper: TagWrapper, code: CodeBlock) -> CodeBlock? | ||
): DocumentationNode = | ||
copy(children = children.map { | ||
when (it) { | ||
is See -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Param -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Throws -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Sample -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Property -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is CustomTagWrapper -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Description -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Author -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Version -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Since -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Return -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Receiver -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Constructor -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Deprecated -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
is Suppress -> it.copy(root = it.root.process(module, `package`, documentable, node, it, transform)) | ||
} | ||
}) | ||
|
||
private fun DocTag.process( | ||
module: DModule, | ||
`package`: DPackage, | ||
documentable: Documentable, | ||
node: DocumentationNode, | ||
wrapper: TagWrapper, | ||
transform: (module: DModule, `package`: DPackage, documentable: Documentable, node: DocumentationNode, wrapper: TagWrapper, code: CodeBlock) -> CodeBlock? | ||
): DocTag = | ||
when (this) { | ||
is CodeBlock -> transform(module, `package`, documentable, node, wrapper, this) ?: this | ||
is CodeInline -> this | ||
is CustomDocTag -> copy(children = children.map { | ||
it.process( | ||
module, | ||
`package`, | ||
documentable, | ||
node, | ||
wrapper, | ||
transform | ||
) | ||
}) | ||
else -> this | ||
} |
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.