Skip to content

Commit

Permalink
Merge pull request #14 from orangain/dokka
Browse files Browse the repository at this point in the history
Introduce Dokka
  • Loading branch information
orangain committed May 1, 2023
2 parents d0d5421 + b9a5370 commit adcdef0
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 52 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Document

on:
push:
tags:
- "**"
branches:
- main
- dokka

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build document with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: dokkaHtmlMultiModule
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/dokka/htmlMultiModule
destination_dir: ./${{ github.ref_name }}/api
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ build
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/
Expand Down
6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("jvm") version "1.8.21"
id("org.jetbrains.dokka") version "1.8.10"
}

allprojects {
Expand Down
1 change: 1 addition & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
7 changes: 7 additions & 0 deletions ktcodeshift-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
application
// Add support for generating version number from Git status.
id("com.palantir.git-version") version "3.0.0"
id("org.jetbrains.dokka")
}

val gitVersion: groovy.lang.Closure<String> by extra
Expand All @@ -31,6 +32,12 @@ tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

testing {
suites {
// Configure the built-in test suite
Expand Down
2 changes: 1 addition & 1 deletion ktcodeshift-cli/src/test/kotlin/examples/TransformTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package examples

import ktcodeshift.*
import ktcodeshift.testing.testTransform
import kotlin.test.Test

class TransformTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ktcodeshift
package ktcodeshift.testing

import ktcodeshift.*
import kotlin.reflect.KClass
import kotlin.script.experimental.host.UrlScriptSource
import kotlin.test.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ transform { fileInfo ->

println(fqNames)
println("-".repeat(40))
stringBuilder.appendLine("package ktcodeshift")
stringBuilder.appendLine()
stringBuilder.appendLine("import ktast.ast.Node")

fun toFqNameType(type: Node.Type.Simple, nestedNames: List<String>): Node.Type.Simple {
Expand Down
7 changes: 7 additions & 0 deletions ktcodeshift-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
}

dependencies {
Expand All @@ -23,6 +24,12 @@ tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

testing {
suites {
// Configure the built-in test suite
Expand Down
50 changes: 14 additions & 36 deletions ktcodeshift-dsl/src/main/kotlin/ktcodeshift/Builder.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package ktcodeshift

import ktast.ast.Node

fun kotlinFile(
Expand Down Expand Up @@ -74,9 +76,7 @@ fun callConstructorParent(
) = Node.Declaration.Class.Parent.CallConstructor(type = type, typeArgs = typeArgs, args = args, lambda = lambda)

fun delegatedTypeParent(
type: Node.Type.Simple,
byKeyword: Node.Keyword.By = Node.Keyword.By(),
expression: Node.Expression
type: Node.Type.Simple, byKeyword: Node.Keyword.By = Node.Keyword.By(), expression: Node.Expression
) = Node.Declaration.Class.Parent.DelegatedType(type = type, byKeyword = byKeyword, expression = expression)

fun typeParent(type: Node.Type.Simple) = Node.Declaration.Class.Parent.Type(type = type)
Expand All @@ -85,9 +85,7 @@ fun primaryConstructor(
constructorKeyword: Node.Keyword.Constructor? = null,
params: Node.Declaration.Function.Params? = null
) = Node.Declaration.Class.PrimaryConstructor(
modifiers = modifiers,
constructorKeyword = constructorKeyword,
params = params
modifiers = modifiers, constructorKeyword = constructorKeyword, params = params
)

fun classBody(
Expand Down Expand Up @@ -128,8 +126,7 @@ fun functionDeclaration(
)

fun functionParams(
elements: List<Node.Declaration.Function.Param> = listOf(),
trailingComma: Node.Keyword.Comma? = null
elements: List<Node.Declaration.Function.Param> = listOf(), trailingComma: Node.Keyword.Comma? = null
) = Node.Declaration.Function.Params(elements = elements, trailingComma = trailingComma)

fun functionParams(vararg elements: Node.Declaration.Function.Param) = functionParams(elements.toList())
Expand Down Expand Up @@ -278,8 +275,7 @@ fun functionType(
)

fun contextReceivers(
elements: List<Node.Type.Function.ContextReceiver> = listOf(),
trailingComma: Node.Keyword.Comma? = null
elements: List<Node.Type.Function.ContextReceiver> = listOf(), trailingComma: Node.Keyword.Comma? = null
) = Node.Type.Function.ContextReceivers(elements = elements, trailingComma = trailingComma)

fun contextReceivers(vararg elements: Node.Type.Function.ContextReceiver) = contextReceivers(elements.toList())
Expand All @@ -293,19 +289,14 @@ fun functionTypeParam(name: Node.Expression.Name? = null, typeRef: Node.TypeRef)
Node.Type.Function.Param(name = name, typeRef = typeRef)

fun simpleType(
qualifiers: List<Node.Type.Simple.Qualifier> = listOf(),
name: Node.Expression.Name,
typeArgs: Node.TypeArgs? = null
qualifiers: List<Node.Type.Simple.Qualifier> = listOf(), name: Node.Expression.Name, typeArgs: Node.TypeArgs? = null
) = Node.Type.Simple(qualifiers = qualifiers, name = name, typeArgs = typeArgs)

fun qualifier(name: Node.Expression.Name, typeArgs: Node.TypeArgs? = null) =
Node.Type.Simple.Qualifier(name = name, typeArgs = typeArgs)

fun nullableType(
lPar: Node.Keyword.LPar? = null,
modifiers: Node.Modifiers? = null,
type: Node.Type,
rPar: Node.Keyword.RPar? = null
lPar: Node.Keyword.LPar? = null, modifiers: Node.Modifiers? = null, type: Node.Type, rPar: Node.Keyword.RPar? = null
) = Node.Type.Nullable(lPar = lPar, modifiers = modifiers, type = type, rPar = rPar)

fun dynamicType(_unused_: Boolean = false) = Node.Type.Dynamic(_unused_ = _unused_)
Expand All @@ -317,10 +308,7 @@ fun typeArg(modifiers: Node.Modifiers? = null, typeRef: Node.TypeRef? = null, as
Node.TypeArg(modifiers = modifiers, typeRef = typeRef, asterisk = asterisk)

fun typeRef(
lPar: Node.Keyword.LPar? = null,
modifiers: Node.Modifiers? = null,
type: Node.Type,
rPar: Node.Keyword.RPar? = null
lPar: Node.Keyword.LPar? = null, modifiers: Node.Modifiers? = null, type: Node.Type, rPar: Node.Keyword.RPar? = null
) = Node.TypeRef(lPar = lPar, modifiers = modifiers, type = type, rPar = rPar)

fun valueArgs(elements: List<Node.ValueArg> = listOf(), trailingComma: Node.Keyword.Comma? = null) =
Expand Down Expand Up @@ -444,11 +432,7 @@ fun whenExpression(
rPar: Node.Keyword.RPar? = null,
branches: List<Node.Expression.When.Branch> = listOf()
) = Node.Expression.When(
whenKeyword = whenKeyword,
lPar = lPar,
expression = expression,
rPar = rPar,
branches = branches
whenKeyword = whenKeyword, lPar = lPar, expression = expression, rPar = rPar, branches = branches
)

fun conditionalBranch(
Expand Down Expand Up @@ -477,8 +461,7 @@ fun returnExpression(label: String? = null, expression: Node.Expression? = null)
fun continueExpression(label: String? = null) = Node.Expression.Continue(label = label)
fun breakExpression(label: String? = null) = Node.Expression.Break(label = label)
fun collectionLiteralExpression(
expressions: List<Node.Expression> = listOf(),
trailingComma: Node.Keyword.Comma? = null
expressions: List<Node.Expression> = listOf(), trailingComma: Node.Keyword.Comma? = null
) = Node.Expression.CollectionLiteral(expressions = expressions, trailingComma = trailingComma)

fun nameExpression(name: String) = Node.Expression.Name(name = name)
Expand All @@ -502,9 +485,7 @@ fun lambdaArg(
) = Node.Expression.Call.LambdaArg(annotationSets = annotationSets, label = label, expression = expression)

fun arrayAccessExpression(
expression: Node.Expression,
indices: List<Node.Expression> = listOf(),
trailingComma: Node.Keyword.Comma? = null
expression: Node.Expression, indices: List<Node.Expression> = listOf(), trailingComma: Node.Keyword.Comma? = null
) = Node.Expression.ArrayAccess(expression = expression, indices = indices, trailingComma = trailingComma)

fun anonymousFunctionExpression(function: Node.Declaration.Function) =
Expand Down Expand Up @@ -550,9 +531,7 @@ fun typeConstraintList(vararg elements: Node.PostModifier.TypeConstraints.TypeCo
typeConstraintList(elements.toList())

fun typeConstraint(
annotationSets: List<Node.Modifier.AnnotationSet> = listOf(),
name: Node.Expression.Name,
typeRef: Node.TypeRef
annotationSets: List<Node.Modifier.AnnotationSet> = listOf(), name: Node.Expression.Name, typeRef: Node.TypeRef
) = Node.PostModifier.TypeConstraints.TypeConstraint(annotationSets = annotationSets, name = name, typeRef = typeRef)

fun contract(
Expand All @@ -561,8 +540,7 @@ fun contract(
) = Node.PostModifier.Contract(contractKeyword = contractKeyword, contractEffects = contractEffects)

fun contractEffects(
elements: List<Node.PostModifier.Contract.ContractEffect> = listOf(),
trailingComma: Node.Keyword.Comma? = null
elements: List<Node.PostModifier.Contract.ContractEffect> = listOf(), trailingComma: Node.Keyword.Comma? = null
) = Node.PostModifier.Contract.ContractEffects(elements = elements, trailingComma = trailingComma)

fun contractEffects(vararg elements: Node.PostModifier.Contract.ContractEffect) = contractEffects(elements.toList())
Expand Down

0 comments on commit adcdef0

Please sign in to comment.