Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
- Use Dokka HTML format which is better for Kotlin
- Move Model classes to new package so docs are better
  organized
- Hide internal package from generated docs, along with
  OpenApi infrastructure packages
  • Loading branch information
gabrielfeo committed Jan 2, 2023
1 parent 2a57af9 commit 2095bb6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/generated/openapi-generator/api/*
build/generated/openapi-generator/gradle/**/*
build/generated/openapi-generator/docs/*
build/generated/openapi-generator/src/main/AndroidManifest.xml
build/generated/openapi-generator/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/ApiClient.kt
build/generated/openapi-generator/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/infrastructure/ApiClient.kt
build/generated/openapi-generator/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/BuildsApi.kt
build/generated/openapi-generator/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/BuildCacheApi.kt
build/generated/openapi-generator/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/MetaApi.kt
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ api.getBuild(id = "hy5nxbzfjxe5k")
It's recommended to learn about endpoints and their responses through IDE auto-complete. Javadoc
appearing in auto-complete is the full API manual, same as Gradle's online docs.

This library provides a few helper functions on top of the regular API:
This library provides a few extension functions on top of the regular API:

```kotlin
// Regular query to /api/builds, limited to 1000 builds server-side
Expand Down Expand Up @@ -161,11 +161,12 @@ api.getGradleAttributesFlow(since = lastMonth)
your GE instance, decreasing this value should help.
- The script will keep running for an extra ~60s after code finishes, as an [expected behavior
of OkHttp][4], unless you call `shutdown()` (global function).
- All classes are in the same package, so that if you need to make small edits to scripts where
there's no auto-complete, a single wildcard import can be used:
- All classes live in these two packages. If you need to make small edits to scripts where
there's no auto-complete, wildcard imports can be used:

```kotlin
import com.gabrielfeo.gradle.enterprise.api.*
import com.gabrielfeo.gradle.enterprise.api.model.*
```

### Internals
Expand Down
25 changes: 20 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.dokka.DokkaConfiguration.Visibility.PUBLIC
import org.jetbrains.dokka.gradle.DokkaTask

plugins {
val kotlinVersion = "1.7.10"
id("org.jetbrains.kotlin.jvm") version kotlinVersion
Expand All @@ -8,7 +11,7 @@ plugins {
}

group = "com.github.gabrielfeo"
version = "1.0"
version = "0.7"

val downloadApiSpec by tasks.registering {
val geVersion = providers.gradleProperty("gradle.enterprise.version").get()
Expand All @@ -30,9 +33,9 @@ openApiGenerate {
val ignoreFile = project.layout.projectDirectory.file(".openapi-generator-ignore")
ignoreFileOverride.set(ignoreFile.asFile.absolutePath)
apiPackage.set("com.gabrielfeo.gradle.enterprise.api")
modelPackage.set("com.gabrielfeo.gradle.enterprise.api")
packageName.set("com.gabrielfeo.gradle.enterprise.api")
invokerPackage.set("com.gabrielfeo.gradle.enterprise.api")
modelPackage.set("com.gabrielfeo.gradle.enterprise.api.model")
packageName.set("com.gabrielfeo.gradle.enterprise.api.internal")
invokerPackage.set("com.gabrielfeo.gradle.enterprise.api.internal")
additionalProperties.put("library", "jvm-retrofit2")
}

Expand All @@ -52,8 +55,20 @@ java {
}
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.all {
jdkVersion.set(8)
suppressGeneratedFiles.set(false)
documentedVisibilities.set(setOf(PUBLIC))
perPackageOption {
matchingRegex.set(""".*\.internal.*""")
suppress.set(true)
}
}
}

tasks.named<Jar>("javadocJar") {
from(tasks.dokkaJavadoc)
from(tasks.dokkaHtml)
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.gabrielfeo.gradle.enterprise.api

import com.gabrielfeo.gradle.enterprise.api.model.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.*
import retrofit2.HttpException
import retrofit2.await

private const val API_MAX_BUILDS = 1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gabrielfeo.gradle.enterprise.api

import com.gabrielfeo.gradle.enterprise.api.model.*

operator fun List<BuildAttributesValue>.get(name: String): String? {
return find { it.name == name }?.value
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gabrielfeo.gradle.enterprise.api.internal

import com.gabrielfeo.gradle.enterprise.api.auth.HttpBearerAuth
import com.gabrielfeo.gradle.enterprise.api.internal.auth.HttpBearerAuth
import com.gabrielfeo.gradle.enterprise.api.internal.caching.CacheEnforcingInterceptor
import com.gabrielfeo.gradle.enterprise.api.internal.caching.CacheHitLoggingInterceptor
import com.gabrielfeo.gradle.enterprise.api.internal.caching.cache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gabrielfeo.gradle.enterprise.api.internal

import com.gabrielfeo.gradle.enterprise.api.baseUrl
import com.gabrielfeo.gradle.enterprise.api.infrastructure.Serializer
import com.gabrielfeo.gradle.enterprise.api.internal.infrastructure.Serializer
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down

0 comments on commit 2095bb6

Please sign in to comment.