diff --git a/.buildscript/deploy_website.sh b/.buildscript/deploy_website.sh new file mode 100755 index 00000000..8760f6e4 --- /dev/null +++ b/.buildscript/deploy_website.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e + +REPO="git@github.com:ReactiveCircus/FlowBinding.git" +REMOTE_NAME="origin" +DIR=temp-clone + +if [ -n "${CI}" ]; then + REPO="https://github.com/${GITHUB_REPOSITORY}.git" +fi + +# Clone project into a temp directory +rm -rf $DIR +git clone "$REPO" $DIR +cd $DIR + +# Generate API docs +./gradlew dokka + +# Copy *.md files into docs directory +cp README.md docs/index.md +mkdir -p docs/flowbinding-android && cp flowbinding-android/README.md docs/flowbinding-android/index.md +mkdir -p docs/flowbinding-activity && cp flowbinding-activity/README.md docs/flowbinding-activity/index.md +mkdir -p docs/flowbinding-appcompat && cp flowbinding-appcompat/README.md docs/flowbinding-appcompat/index.md +mkdir -p docs/flowbinding-core && cp flowbinding-core/README.md docs/flowbinding-core/index.md +mkdir -p docs/flowbinding-drawerlayout && cp flowbinding-drawerlayout/README.md docs/flowbinding-drawerlayout/index.md +mkdir -p docs/flowbinding-lifecycle && cp flowbinding-lifecycle/README.md docs/flowbinding-lifecycle/index.md +mkdir -p docs/flowbinding-material && cp flowbinding-material/README.md docs/flowbinding-material/index.md +mkdir -p docs/flowbinding-navigation && cp flowbinding-navigation/README.md docs/flowbinding-navigation/index.md +mkdir -p docs/flowbinding-preference && cp flowbinding-preference/README.md docs/flowbinding-preference/index.md +mkdir -p docs/flowbinding-recyclerview && cp flowbinding-recyclerview/README.md docs/flowbinding-recyclerview/index.md +mkdir -p docs/flowbinding-swiperefreshlayout && cp flowbinding-swiperefreshlayout/README.md docs/flowbinding-swiperefreshlayout/index.md +mkdir -p docs/flowbinding-viewpager2 && cp flowbinding-viewpager2/README.md docs/flowbinding-viewpager2/index.md +cp CHANGELOG.md docs/changelog.md + +# If on CI, configure git remote with access token +if [ -n "${CI}" ]; then + REMOTE_NAME="https://x-access-token:${DEPLOY_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git remote add deploy "$REMOTE_NAME" + git fetch deploy && git fetch deploy gh-pages:gh-pages +fi + +# Build the website and deploy to GitHub Pages +mkdocs gh-deploy --remote-name "$REMOTE_NAME" + +# Delete temp directory +cd .. +rm -rf $DIR diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml new file mode 100644 index 00000000..22e1d636 --- /dev/null +++ b/.github/workflows/deploy-website.yml @@ -0,0 +1,30 @@ +name: Deploy Website + +on: + push: + branches: + - master + paths: + - '**.md' + - 'mkdocs.yml' + +jobs: + deploy-website: + name: Generate API docs and deploy website + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + - run: | + pip3 install mkdocs mkdocs-material mkdocs-minify-plugin pymdown-extensions + .buildscript/deploy_website.sh + env: + CI: true + JAVA_TOOL_OPTIONS: -Xmx3g + GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false -Dkotlin.compiler.execution.strategy=in-process + DEPLOY_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }} diff --git a/.gitignore b/.gitignore index 3fe3a94f..ebdc8948 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ captures/ # External native build folder generated in Android Studio 2.2 and later .externalNativeBuild + +# Docs +site +docs/api diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c7418817..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-slate \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2bf2b6fa..bfa6385e 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ buildscript { classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${versions.detekt}" classpath "com.vanniktech:gradle-maven-publish-plugin:${versions.mavenPublishPlugin}" classpath "io.github.reactivecircus.firestorm:firestorm-gradle-plugin:${versions.firestormGradlePlugin}" + classpath("org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}") } } diff --git a/buildSrc/dependencies.gradle b/buildSrc/dependencies.gradle index 15425691..8321450f 100644 --- a/buildSrc/dependencies.gradle +++ b/buildSrc/dependencies.gradle @@ -3,6 +3,7 @@ rootProject.ext.versions = [ androidLint : '27.0.0-alpha09', mavenPublishPlugin : '0.9.0', firestormGradlePlugin: '0.1.1', + dokka : '0.10.1', kotlin : '1.3.61', detekt : '1.5.1', kotlinx : [ diff --git a/docs/images/reactive_cirrus_logo.png b/docs/images/reactive_cirrus_logo.png new file mode 100644 index 00000000..ab132b9a Binary files /dev/null and b/docs/images/reactive_cirrus_logo.png differ diff --git a/flowbinding-activity/build.gradle b/flowbinding-activity/build.gradle index dff303a0..d3d15d82 100644 --- a/flowbinding-activity/build.gradle +++ b/flowbinding-activity/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-android/build.gradle b/flowbinding-android/build.gradle index e4c3a1a6..e098e268 100644 --- a/flowbinding-android/build.gradle +++ b/flowbinding-android/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-appcompat/build.gradle b/flowbinding-appcompat/build.gradle index 3e3cff99..9c5d56f1 100644 --- a/flowbinding-appcompat/build.gradle +++ b/flowbinding-appcompat/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-common/build.gradle b/flowbinding-common/build.gradle index e04d5e7a..32c41b6f 100644 --- a/flowbinding-common/build.gradle +++ b/flowbinding-common/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-core/build.gradle b/flowbinding-core/build.gradle index 452107e4..c89d8faa 100644 --- a/flowbinding-core/build.gradle +++ b/flowbinding-core/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-drawerlayout/build.gradle b/flowbinding-drawerlayout/build.gradle index 21e59941..33309ced 100644 --- a/flowbinding-drawerlayout/build.gradle +++ b/flowbinding-drawerlayout/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-lifecycle/build.gradle b/flowbinding-lifecycle/build.gradle index b50dd5c4..1ea26e89 100644 --- a/flowbinding-lifecycle/build.gradle +++ b/flowbinding-lifecycle/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-material/build.gradle b/flowbinding-material/build.gradle index 11f88cc0..3f9d6601 100644 --- a/flowbinding-material/build.gradle +++ b/flowbinding-material/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-navigation/build.gradle b/flowbinding-navigation/build.gradle index 107639f3..feaf9776 100644 --- a/flowbinding-navigation/build.gradle +++ b/flowbinding-navigation/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-preference/build.gradle b/flowbinding-preference/build.gradle index f631b300..c9324c35 100644 --- a/flowbinding-preference/build.gradle +++ b/flowbinding-preference/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-recyclerview/build.gradle b/flowbinding-recyclerview/build.gradle index 08300341..b06f0893 100644 --- a/flowbinding-recyclerview/build.gradle +++ b/flowbinding-recyclerview/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-swiperefreshlayout/build.gradle b/flowbinding-swiperefreshlayout/build.gradle index 020920ea..d9b6f97d 100644 --- a/flowbinding-swiperefreshlayout/build.gradle +++ b/flowbinding-swiperefreshlayout/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/flowbinding-viewpager2/build.gradle b/flowbinding-viewpager2/build.gradle index 7723c3d7..9ae112a8 100644 --- a/flowbinding-viewpager2/build.gradle +++ b/flowbinding-viewpager2/build.gradle @@ -4,6 +4,14 @@ plugins { id 'kotlin-android' id 'com.vanniktech.maven.publish' id 'io.github.reactivecircus.firestorm' + id 'org.jetbrains.dokka' +} + +afterEvaluate { project -> + project.tasks.dokka { + outputDirectory = "$rootDir/docs/api" + outputFormat = 'gfm' + } } android { diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..f1b930ab --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,82 @@ +site_name: 'FlowBinding' +site_description: "Kotlin Coroutines Flow binding APIs for Android's platform and unbundled UI widgets, inspired by RxBinding." +site_author: 'Yang Chen' +site_url: 'https://reactivecircus.github.io/FlowBinding' +remote_branch: gh-pages + +repo_name: 'FlowBinding' +repo_url: 'https://github.com/ReactiveCircus/FlowBinding' + +copyright: 'Copyright © 2019 Yang Chen' + +theme: + name: 'material' + language: 'en' + favicon: 'images/reactive_cirrus_logo.png' + logo: 'images/reactive_cirrus_logo.png' + palette: + primary: 'white' + accent: 'white' + font: + text: 'Fira Sans' + code: 'Fira Code' + +extra: + social: + - type: 'github' + link: 'https://github.com/ReactiveCircus/FlowBinding' + +nav: + - 'Overview': index.md + - 'Platform Bindings': flowbinding-android/index.md + - 'AndroidX Activity Bindings': flowbinding-activity/index.md + - 'AndroidX AppCompat Bindings': flowbinding-appcompat/index.md + - 'AndroidX Core Bindings': flowbinding-core/index.md + - 'AndroidX DrawerLayout Bindings': flowbinding-drawerlayout/index.md + - 'AndroidX Lifecycle Bindings': flowbinding-lifecycle/index.md + - 'AndroidX Navigation Component Bindings': flowbinding-navigation/index.md + - 'AndroidX Preference Bindings': flowbinding-preference/index.md + - 'AndroidX RecyclerView Bindings': flowbinding-recyclerview/index.md + - 'AndroidX SwipeRefreshLayout Bindings': flowbinding-swiperefreshlayout/index.md + - 'AndroidX ViewPager2 Bindings': flowbinding-viewpager2/index.md + - 'Material Components Bindings': flowbinding-material/index.md + - 'Change Log': changelog.md + - 'API': + - 'flowbinding-activity': api/flowbinding-activity/index.md + - 'flowbinding-android': api/flowbinding-android/index.md + - 'flowbinding-appcompat': api/flowbinding-appcompat/index.md + - 'flowbinding-common': api/flowbinding-common/index.md + - 'flowbinding-core': api/flowbinding-core/index.md + - 'flowbinding-drawerlayout': api/flowbinding-drawerlayout/index.md + - 'flowbinding-lifecycle': api/flowbinding-lifecycle/index.md + - 'flowbinding-material': api/flowbinding-material/index.md + - 'flowbinding-navigation': api/flowbinding-navigation/index.md + - 'flowbinding-preference': api/flowbinding-preference/index.md + - 'flowbinding-recyclerview': api/flowbinding-recyclerview/index.md + - 'flowbinding-swiperefreshlayout': api/flowbinding-swiperefreshlayout/index.md + - 'flowbinding-viewpager2': api/flowbinding-viewpager2/index.md + +markdown_extensions: + - admonition + - smarty + - codehilite: + guess_lang: false + linenums: True + - footnotes + - meta + - toc: + permalink: true + - pymdownx.betterem: + smart_enable: all + - pymdownx.caret + - pymdownx.details + - pymdownx.inlinehilite + - pymdownx.magiclink + - pymdownx.smartsymbols + - pymdownx.superfences + - tables + +plugins: + - search + - minify: + minify_html: true