Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dokka doesn't link to Android SDK classes #169

Closed
jmartinesp opened this issue Jun 6, 2017 · 14 comments
Closed

Dokka doesn't link to Android SDK classes #169

jmartinesp opened this issue Jun 6, 2017 · 14 comments
Assignees

Comments

@jmartinesp
Copy link

Hello, thank you for your great work with this tool!

I was just publishing an Android library written in Kotlin and trying to generate some docs with dokka, resulting in this:

I've tried linking with the Android reference like this:

externalDocumentationLink {
    url = new URL("https://developer.android.com/reference/")
}

Apparently, there are no errors as the build succeeds, but the result is what you see in the image. Every class on the Android SDK is shown as <ERROR CLASS>.

Am I doing something wrong?

@connected-tlip
Copy link

I have the same issue trying to link to RxJava's docs:

externalDocumentationLink {
    url = new URL ("http://reactivex.io/RxJava/1.x/javadoc")
    packageListUrl = new URL ("http://reactivex.io/RxJava/1.x/javadoc/package-list")
}

@semoro
Copy link
Contributor

semoro commented Jun 6, 2017

@Arasthel Hello, please make sure you using

buildscript {
    dependencies {
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.14"
    }
}

and apply plugin: 'org.jetbrains.dokka-android'

@semoro
Copy link
Contributor

semoro commented Jun 6, 2017

@connected-tlip
Could you provide full Dokka task configuration?
Are RxJava added to your dependencies block for the project on which Dokka task are applied?

@jmartinesp
Copy link
Author

It's defined on project-level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-4'
    ext.support_library_version = '25.3.1'
    ext.dokka_version = '0.9.14'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And I have the apply plugin line on the build.gradle of the library module.

@connected-tlip
Copy link

I have everything in the project-level build.gradle, and I'm adding submodules to sourceDirs:

buildscript {
    ext {
        kotlinVersion = '1.1.2-3'
        dokkaVersion = '0.9.14'
    }
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.4.0-alpha7'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}"
    }
}
apply plugin: 'org.jetbrains.dokka'

dokka {
    outputFormat = 'javadoc'
    outputDirectory = "${projectDir}/dokka-generated"
    processConfigurations = []

    sourceDirs += files('ui/src/main/kotlin')
    sourceDirs += files('presentation/src/main/kotlin')

    externalDocumentationLink {
        url = new URL ("http://reactivex.io/RxJava/1.x/javadoc")
        packageListUrl = new URL ("http://reactivex.io/RxJava/1.x/javadoc/package-list")
    }
}

The hope is that I can run dokka on the project level and generate documentation for all the modules combined together.

@semoro
Copy link
Contributor

semoro commented Jun 6, 2017

@connected-tlip It's another issue, please see #157

@semoro
Copy link
Contributor

semoro commented Jun 6, 2017

@Arasthel
How did you run Gradle? Which tasks? I'd use assemble dokka
Can you provide minimal build.gradle of your library?

@jmartinesp
Copy link
Author

jmartinesp commented Jun 6, 2017

This is my library's build.gradle: https://ghostbin.com/paste/3ky2o

I also modified bintrayv1.gradle to tell the task that creates the -javadoc jar to use the /docs folder.

This is the output of executing ./gradlew :spannedgridlayoutmanager:dokkaJavadoc --debug: https://ghostbin.com/paste/fv9bh

@semoro
Copy link
Contributor

semoro commented Jun 7, 2017

@Arasthel
The problem is the type of task, you should use task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) { for Android.
Also, sourceDirs not needed when it set properly.

@semoro
Copy link
Contributor

semoro commented Jun 7, 2017

We need to clarify this in the readme.

@jmartinesp
Copy link
Author

That fixed it! Thanks, everything works as it should now.

@connected-tlip
Copy link

connected-tlip commented Jun 7, 2017

@semoro My issue isn't that I cannot link between different modules, it's that external documentation isn't linking even with externalDocumentationLink

for example,

val statusObservable: Observable<Int>

is showing up as:

val statusObservable: <ERROR CLASS><Int>

@semoro
Copy link
Contributor

semoro commented Jun 7, 2017

@connected-tlip <ERROR CLASS> means that Dokka's Internal Kotlin Compiler unable to detect such class in Dokka's classpath.
It is defined by processConfigurations, so if you set them to empty list, no dependencies will be processed, and all classes that are external to your sourceDirs will be marked <ERROR CLASS>.

Now you can define some custom configuration on your root project and put it in processConfigurations of Dokka.
Other possible (And more elegant) way is to specify full configuration path in processConfigurations, like [ ':subproject:compile' ], but unfortunately it not supported by Dokka yet.

See example project of first way I've attached:
example.tar.gz

@DougSig
Copy link

DougSig commented Oct 31, 2017

I'm using 0.9.15, compiling from source (in order to add services) and running using the jar. What is the right way to add Android SDK links? Right now, I'm running:

java -jar dokka-fatjar.jar $projectsourcedir -format $mycustomformat -output $outputdir -links https://developer.android.com/reference/^https://developer.android.com/reference/package-list^^https://developer.android.com/reference/android/support/^https://developer.android.com/reference/android/support/package-list

...and it's not finding the Android SDK classes. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants