Skip to content

Commit

Permalink
Add github action to generate and deploy API docs for kotlin bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Oct 21, 2024
1 parent df2e152 commit 92fca51
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 9 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Generate API docs and deploy them to Github Pages

on:
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest
# queued. However, do NOT cancel in-progress runs as we want to allow these production deployments
# to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Cache gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Setup gradle
uses: gradle/[email protected]

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Build docs for the rust library
run: cargo doc --package ouisync --lib --no-deps

- name: Build docs for the kotlin bindings
working-directory: bindings/kotlin
run: ./gradlew lib:dokkaHtml

- name: Prepare the files
run: |
mkdir -p _site
cp -r target/doc _site/rust
cp -r bindings/kotlin/build/lib/dokka/html _site/kotlin
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions bindings/kotlin/lib/docs/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The entry point to Ouisync is the [Session](org.equalitie.ouisync.lib.Session) c
(org.equalitie.ouisync.lib.Session.Companion.create) it near the start of the app and make effort
to [close](org.equalitie.ouisync.lib.Session.close) it on app shutdown. Afterwards, use the
[Repository](org.equalitie.ouisync.lib.Repository) class to create and manage your Ouisync
repositories and use the [File](org.equalitie.ouisync.lib.File) and [Directory]
(org.equalitie.ouisync.lib.Directory) classes to access the repository content.
repositories and use the [File](org.equalitie.ouisync.lib.File) and [Directory](org.equalitie.ouisync.lib.Directory)
classes to access the repository content.

See also the [example app](https://github.com/equalitie/ouisync/tree/master/bindings/kotlin/example).
14 changes: 7 additions & 7 deletions lib/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ impl Repository {
/// closed.
///
/// To restore a disabled mode the repo must first be put into that mode using
/// [set_credentials] where the `Credentials` must be obtained from `AccessSecrets` with at
/// least the mode one wants to restore.
/// [Self::set_credentials()] where the `Credentials` must be obtained from `AccessSecrets` with
/// at least the mode one wants to restore.
///
/// If `read` or `write` is `None` then no change is made to that mode. If both are `None` then
/// this function is a no-op.
Expand Down Expand Up @@ -320,7 +320,7 @@ impl Repository {

/// Gets the current credentials of this repository.
///
/// See also [set_credentials].
/// See also [Self::set_credentials()].
pub fn credentials(&self) -> Credentials {
self.shared.credentials.read().unwrap().clone()
}
Expand Down Expand Up @@ -408,19 +408,19 @@ impl Repository {
///
/// # Move/rename the repo db
///
/// 1. Obtain the current credentials with [credentials] and keep them locally.
/// 1. Obtain the current credentials with [Self::credentials()] and keep them locally.
/// 2. Close the repo.
/// 3. Rename the repo database files(s).
/// 4. Open the repo from its new location in blind mode.
/// 5. Restore the credentials from step 1 with [set_credentials].
/// 5. Restore the credentials from step 1 with [Self::set_credentials()].
///
/// # Restore access
///
/// 1. Get the `AccessSecrets` the repository was originally created from (e.g., by extracting
/// them from the original `ShareToken`).
/// 2. Construct `Credentials` using this access secrets and a random writer id.
/// 3. Restore the credentials with [set_credentials].
/// 4. Enable/change the access with [set_access].
/// 3. Restore the credentials with [Self::set_credentials()].
/// 4. Enable/change the access with [Self::set_access()].
pub async fn set_credentials(&self, credentials: Credentials) -> Result<()> {
// Check the credentials are actually for this repository
let expected_id = {
Expand Down

0 comments on commit 92fca51

Please sign in to comment.