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

Fix docs #347

Merged
merged 9 commits into from
Aug 18, 2021
Merged

Fix docs #347

merged 9 commits into from
Aug 18, 2021

Conversation

aboedo
Copy link
Member

@aboedo aboedo commented Aug 13, 2021

our docs for purchases-android were pretty broken. They only pointed to the Purchases type, didn't include much information in general or correctly link to the source code.

I believe this was broken during our modularization project, since we shuffled a lot of stuff around but didn't update the dokka configuration.

This updates dokka to the latest version (as of writing), updates the format, and uses the Multi-Module setup from dokka so that we can link stuff nicely even if it's separated into packages.

Before After
Screen Shot 2021-08-13 at 3 01 33 PM image

I've already published the new version, you can see it in action in https://sdk.revenuecat.com/android/index.html.

Also, I absolutely suck at gradle, please point out if there are better ways to do things.

@aboedo aboedo self-assigned this Aug 13, 2021
@@ -132,7 +132,7 @@ jobs:
- android/restore-build-cache
- run:
name: Dokka
command: ./gradlew dokka
command: ./gradlew dokkaHtmlMultiModule
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new command for generating stuff in a modularized setup

classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.0"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.32"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the reason the docs look so much nicer now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see they have fixed that horrible layout haha

Comment on lines +74 to +79
apply plugin: 'org.jetbrains.dokka'

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(file("docs"))
includes.from("README.md")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the parent config

docs/index.html Outdated
Comment on lines 1 to 6
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=purchases/index.html" />
</head>
<body>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this should have been versioned in the first place, but not looking to change that right now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I created this docs/index.html to redirect to purchases/index.html. This was so accessing https://sdk.revenuecat.com/android/ would redirect to https://sdk.revenuecat.com/android/purchases/index.html. Dokka was creating the files in purchases because their multi module support was horrible. I think we can un-version it now because dokka is creating an index.html where we want it to be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh interesting, makes sense. I'll kill it then

Copy link
Member Author

@aboedo aboedo Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 24 to 41
dokkaSourceSets {
configureEach {
reportUndocumented.set(true)
includeNonPublic.set(false)
skipDeprecated.set(true)

externalDocumentationLink {
url.set(uri("https://developer.android.com/reference/package-list").toURL())
}
sourceLink {
localDirectory.set(file("src/main/java"))
remoteUrl.set(uri("https://github.com/revenuecat/purchases-android/blob/master/public/src/main/java").toURL())
remoteLineSuffix.set("#L")
}
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done in each package that has at least one public type

@@ -31,55 +32,23 @@ dependencies {
testImplementation 'org.assertj:assertj-core:3.13.2'
}

apply plugin: 'com.vanniktech.maven.publish'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the original problem: we still had dokka set up for the purchases module, but a lot of stuff lives in public now

@aboedo aboedo requested a review from a team August 13, 2021 18:17
skipDeprecated = true
// Allows linking to documentation of the project's dependencies (generated with Javadoc or Dokka)
// Repeat for multiple links
externalDocumentationLink {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we confirm the trailing slash is not required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually never got this to work. Does this work in the new version? I was looking for an example but I can't find it. I think we don't have any public link to the billing client anymore and everything is in the google module

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to remove it, I kept it around for the sake of having everything that we had before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I would keep it the same it was before

}

tasks.dokkaHtmlPartial.configure {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to pull the common configuration stuff out somehow, but i'm also not great at gradle...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be extracted to a file like library.gradle and call it dokka.gradle. Then apply the file doing:

apply from: "$rootProject.projectDir/dokka.gradle"

But there's one thing that changes: the source directory. It is src/main/java for public and src/main/kotlin for purchases. I am not sure how to change that part in each of the modules. Maybe setting just that part in the module's gradle inherits everything from the dokka.gradle and changes that part for the module. Something like:

apply from: "$rootProject.projectDir/dokka.gradle"
...
dokkaSourceSets {
         configureEach {
             sourceLink {
                 localDirectory.set(file("src/main/java"))
                 remoteUrl.set(uri("https://github.com/revenuecat/purchases-android/blob/main/public/src/main/java").toURL())
             }
         }
     }

We should move everything to src/main/kotlin although not a priority at all.

As an example. I found the arrow project does it this way https://github.com/arrow-kt/arrow/blob/ee319ace7df8dd05001406b3727aa3ed90188e07/arrow-libs/gradle/apidoc-creation.gradle

They have a apidoc-creation.gradle, and they do " ${relativeProjectPath('src/main/kotlin')}" to figure out the relative path of the source files. Then they apply the gradle file in each of the modules https://github.com/arrow-kt/arrow/blob/2569ece084a0ace0a77c0ed126b452babe69d52b/arrow-libs/core/arrow-annotations/build.gradle#L7. They have a gradle property https://github.com/arrow-kt/arrow/blob/main/arrow-libs/gradle.properties#L80 pointing to that file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, I think that's the intent of the dokkaHtmlPartial clauses.
I started by trying to have as much stuff in a single file as possible but kept running into issues, so I ended up going with this path for the sake of not spending too much time on this.

I can give it another shot if you think it's important to do now, otherwise we can add it to the backlog

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's important to do right now 🙂

@aboedo aboedo merged commit 22a548b into main Aug 18, 2021
@aboedo aboedo deleted the fix_docs branch August 18, 2021 14:16
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

Successfully merging this pull request may close these issues.

3 participants