Skip to content

Commit

Permalink
Gradle extension KDoc's
Browse files Browse the repository at this point in the history
  • Loading branch information
ermadmi78 committed Aug 31, 2021
1 parent aecc2dc commit 6b8d164
Show file tree
Hide file tree
Showing 2 changed files with 510 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,117 @@ import org.gradle.api.file.FileCollection
annotation class Kobby

/**
* Kobby Kotlin Gradle Plugin project extension
* Kobby Plugin Configuration
*/
fun Project.kobby(configure: KobbyExtension.() -> Unit) =
extensions.configure(KobbyExtension::class.java, configure)

/**
* Created on 20.12.2020
*
* @author Dmitry Ermakov ([email protected])
* Kobby Plugin Configuration
*/
@Kobby
open class KobbyExtension {
internal val schemaExtension = lazy { KobbySchemaExtension() }
internal val kotlinExtension = lazy { KobbyKotlinExtension() }

/** DSL schema configuration */
/** Schema location and parsing rules configuration */
fun schema(action: Action<KobbySchemaExtension>) {
action.execute(schemaExtension.value)
}

/** Kotlin DSL generator configuration */
/** Configuration of Kotlin DSL generation */
fun kotlin(action: Action<KobbyKotlinExtension>) {
action.execute(kotlinExtension.value)
}

override fun toString(): String {
return "KobbyExtension(schemaExtension=$schemaExtension, kotlinExtension=$kotlinExtension)"
}
}

/**
* Schema location and parsing rules configuration
*/
@Kobby
open class KobbySchemaExtension {
/**
* GraphQL schema files to generate Kobby DSL.
*
* By default, all "`**`/`*`.graphqls" files in "src/main/resources"
*/
var files: FileCollection? = null

internal var scanExtension = lazy { KobbySchemaScanExtension() }
internal var directiveExtension = lazy { KobbySchemaDirectiveExtension() }

/** Configuration of schema files location scanning */
fun scan(action: Action<KobbySchemaScanExtension>) {
action.execute(scanExtension.value)
}

/** Configuration of Kobby GraphQL directives parsing */
fun directive(action: Action<KobbySchemaDirectiveExtension>) {
action.execute(directiveExtension.value)
}

override fun toString(): String {
return "KobbySchemaExtension(" +
"files=$files, " +
"scanExtension=$scanExtension, " +
"directiveExtension=$directiveExtension" +
")"
}
}

/**
* Configuration of schema files location scanning
*/
@Kobby
open class KobbySchemaScanExtension {
/**
* Root directory to scan schema files
*
* Default: "src/main/resources"
*/
var dir: String? = null

/**
* ANT style include patterns to scan schema files
*
* Default: listOf("`**`/`*`.graphqls")
*/
var includes: Iterable<String>? = null
var excludes: Iterable<String>? = null

override fun toString(): String {
return "KobbySchemaScanExtension(dir=$dir, includes=$includes, excludes=$excludes)"
}
/** ANT style exclude patterns to scan schema files */
var excludes: Iterable<String>? = null
}

/**
* Configuration of Kobby GraphQL directives parsing
*/
@Kobby
open class KobbySchemaDirectiveExtension {
/**
* Name of "primaryKey" directive
*
* Default: "primaryKey"
*/
var primaryKey: String? = null

/**
* Name of "required" directive
*
* Default: "required"
*/
var required: String? = null

/**
* Name of "default" directive
*
* Default: "default"
*/
var default: String? = null

/**
* Name of "selection" directive
*
* Default: "selection"
*/
var selection: String? = null
var resolve: String? = null

override fun toString(): String {
return "KobbySchemaDirectiveExtension(" +
"primaryKey=$primaryKey, " +
"required=$required, " +
"default=$default, " +
"selection=$selection, " +
"resolve=$resolve" +
")"
}
/**
* Name of "resolve" directive
*
* Default: "resolve"
*/
var resolve: String? = null
}

Loading

0 comments on commit 6b8d164

Please sign in to comment.