Skip to content

Commit b237ff9

Browse files
authored
Add writerside documentation (#81)
* Add boilerplate writerside project for docs * Add overview * Add platform configurations * Update github action to publish the documentation on pages * Update README.md
1 parent 356e9ba commit b237ff9

File tree

14 files changed

+470
-153
lines changed

14 files changed

+470
-153
lines changed

.github/workflows/build.yml

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ permissions:
2020
jobs:
2121
check:
2222
runs-on: ubuntu-latest
23+
name: Verify API
2324
permissions:
2425
pull-requests: write
2526
steps:
@@ -63,6 +64,7 @@ jobs:
6364
run: ./gradlew build
6465

6566
release:
67+
name: Release to sonatype
6668
if: ${{ github.event_name != 'pull_request' }}
6769
runs-on: macos-latest
6870
needs:
@@ -83,9 +85,6 @@ jobs:
8385
- name: Setup gradle
8486
uses: gradle/gradle-build-action@v2
8587

86-
- name: Setup Pages
87-
uses: actions/configure-pages@v3
88-
8988
- name: Write secrets to local.properties
9089
if: ${{ github.event_name != 'pull_request' }}
9190
run: |
@@ -102,14 +101,64 @@ jobs:
102101
- name: Release to sonatype
103102
run: ./gradlew publishAllPublicationsToMavenRepository
104103

105-
- name: Generate docs with dokka
104+
documentation:
105+
name: Publish documentation
106+
if: ${{ github.event_name != 'pull_request' }}
107+
runs-on: ubuntu-latest
108+
needs:
109+
- build
110+
environment:
111+
name: github-pages
112+
url: ${{ steps.deployment.outputs.page_url }}
113+
steps:
114+
- uses: actions/checkout@v3
115+
116+
- name: Setup JDK 17
117+
uses: actions/setup-java@v3
118+
with:
119+
java-version: '17'
120+
distribution: 'temurin'
121+
122+
- name: Setup gradle
123+
uses: gradle/gradle-build-action@v2
124+
125+
- name: Setup Pages
126+
uses: actions/configure-pages@v3
127+
128+
- name: Generate api docs with dokka
106129
run: ./gradlew dokkaHtmlMultiModule
107130

108-
- name: Upload artifact
131+
- name: Build Writerside docs using Docker
132+
uses: JetBrains/writerside-github-action@v4
133+
with:
134+
instance: docs/decompose-router
135+
artifact: webHelpKSTORE2-all.zip
136+
docker-version: 232.10275
137+
138+
- name: Upload documentation
139+
uses: actions/upload-artifact@v3
140+
with:
141+
name: docs
142+
path: |
143+
artifacts/webHelpKSTORE2-all.zip
144+
artifacts/report.json
145+
retention-days: 7
146+
147+
- name: Unzip artifact
148+
uses: montudor/action-zip@v1
149+
with:
150+
args: unzip -qq artifacts/webHelpDECOMPOSE-ROUTER2-all.zip -d build/docs
151+
152+
- name: Move dokka api-doc to docs/api
153+
run: |
154+
sudo mkdir -p build/docs/api
155+
sudo mv build/dokka/htmlMultiModule/* build/docs/api
156+
157+
- name: Upload pages
109158
uses: actions/upload-pages-artifact@v1
110159
with:
111-
path: ${{ github.workspace }}/build/dokka/htmlMultiModule
160+
path: ${{ github.workspace }}/build/docs
112161

113162
- name: Release to GitHub Pages
114163
id: deployment
115-
uses: actions/deploy-pages@v1
164+
uses: actions/deploy-pages@v1

README.md

Lines changed: 3 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -28,96 +28,6 @@ A detailed breakdown available in this [Medium article](https://proandroiddev.co
2828
- ☠️ A `SavedStateHandle` to restore state gracefully after the process death. (for Android)
2929
- 🚉 Multiplatform! Supports Android, WearOS, Desktop, iOS and Web
3030

31-
## Adding to your project
32-
33-
Decompose-Router is published on Maven Central
34-
```kotlin
35-
repositories {
36-
mavenCentral()
37-
// or for snapshot builds
38-
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
39-
}
40-
```
41-
42-
Include the dependency in `commonMain`. Latest version [![Maven Central](https://img.shields.io/maven-central/v/io.github.xxfast/decompose-router?color=blue)](https://search.maven.org/search?q=g:io.github.xxfast)
43-
44-
> **Note**
45-
> Check for compatible versions of Compose Multiplatform, Decompose and Essenty in the [Version Catalog](gradle/libs.versions.toml)
46-
47-
<details>
48-
<summary>1. With version catalog</summary>
49-
50-
**libs.version.toml**
51-
```toml
52-
[versions]
53-
# Check in gradle/libs.versions.toml
54-
55-
[libraries]
56-
# For Compose Multiplatform
57-
decompose-router = { module = "io.github.xxfast:decompose-router", version.ref = "decompose-router" }
58-
59-
# For Compose Wear
60-
decompose-router-wear = { module = "io.github.xxfast:decompose-router-wear", version.ref = "decompose-router" }
61-
62-
# You will need to also bring in decompose and essenty
63-
decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose" }
64-
decompose-compose-multiplatform = { module = "com.arkivanov.decompose:extensions-compose-jetbrains", version.ref = "decompose" }
65-
essenty-parcelable = { module = "com.arkivanov.essenty:parcelable", version.ref = "essenty" }
66-
```
67-
68-
**build.gradle.kts**
69-
```kotlin
70-
sourceSets {
71-
// For Compose Multiplatform
72-
val commonMain by getting {
73-
dependencies {
74-
implementation(libs.decompose.router)
75-
76-
// You will probably need to also bring in decompose and essenty
77-
implementation(libs.decompose)
78-
implementation(libs.decompose.compose.multiplatform)
79-
implementation(libs.essenty.parcelable)
80-
}
81-
}
82-
83-
// For Compose Wear
84-
val androidMain by getting {
85-
dependencies {
86-
implementation(libs.decompose.router.wear)
87-
}
88-
}
89-
}
90-
```
91-
</details>
92-
93-
<details>
94-
<summary>2. Without version catalog</summary>
95-
96-
**build.gradle.kts**
97-
```kotlin
98-
sourceSets {
99-
// For Compose Multiplatform
100-
val commonMain by getting {
101-
dependencies {
102-
implementation("io.github.xxfast:decompose-router:${versions.decompose-router}")
103-
104-
// You will need to also bring in decompose and essenty
105-
implementation("com.arkivanov.decompose:decompose:${versions.decompose}")
106-
implementation("com.arkivanov.decompose:extensions-compose-jetbrains:${versions.decompose}")
107-
implementation("com.arkivanov.essenty:parcelable:${versions.essenty}")
108-
}
109-
}
110-
111-
// For Compose Wear
112-
val androidMain by getting {
113-
dependencies {
114-
implementation("io.github.xxfast:decompose-router-wear:${versions.decompose-router}")
115-
}
116-
}
117-
}
118-
```
119-
</details>
120-
12131
## At a glance
12232

12333
```kotlin
@@ -166,51 +76,11 @@ class DetailInstance(savedState: SavedStateHandle, detail: String) : InstanceKee
16676
}
16777
```
16878

169-
## Platform configurations 🚉
170-
171-
### Android / WearOS
172-
173-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/src/androidMain/kotlin/io/github/xxfast/decompose/router/app/MainActivity.kt#L15-L30
174-
175-
### Desktop
176-
177-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/src/desktopMain/kotlin/io/github/xxfast/decompose/router/app/Application.kt#L17-L36
178-
179-
### iOS
180-
181-
Make sure to create your root router context outside of `ComposeUIViewController`'s composable lambda and pass it in to `LocalRouterContext`
182-
183-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/src/iosMain/kotlin/io/github/xxfast/decompose/router/app/Application.kt#L39-L59
184-
185-
> [!IMPORTANT]
186-
> You will need to tie root `RouterContext`'s lifecycle to an `AppDelegate`.
187-
188-
<details>
189-
<summary>Kotlin app delegate</summary>
190-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/src/iosMain/kotlin/io/github/xxfast/decompose/router/app/AppDelegate.kt#L18-L52
191-
</details>
192-
193-
<details>
194-
<summary>SwiftUI App / Swift UIKit AppDelegat</summary>
195-
196-
#### UIKitAppDelegate
197-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/ios/ios/UIKitAppDelegate.swift#L5-L29
198-
199-
#### SwiftUIApp
200-
201-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/ios/ios/SwiftUIApp.swift#L12-L55
202-
Read more on the docs [here](https://arkivanov.github.io/Decompose/getting-started/quick-start/#ios-with-swiftui)
203-
204-
> [!NOTE]
205-
> To invoke decompose router's `defaultRouterContext()` from swift, you will need to export decompose-router from your shared module
206-
> https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/build.gradle.kts#L25-L36
207-
</details>
208-
209-
### Web
79+
### Installation and Usage
21080

211-
https://github.com/xxfast/Decompose-Router/blob/98e6d62ed067c01f10d73c769a73fe1d7afbf49d/app/src/jsMain/kotlin/io/github/xxfast/decompose/router/app/Application.kt#L12-L26
81+
Documentation [here](https://xxfast.github.io/Decompose-Router/)
21282

213-
</details>
83+
API Reference [here](https://xxfast.github.io/Decompose-Router//docs/)
21484

21585
## Licence
21686

app/ios/ios/SwiftUIApp.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99
import SwiftUI
1010
import app
1111

12-
class DefaultRouterHolder : ObservableObject {
13-
let defaultRouterContext: RouterContext = DefaultRouterContextKt.defaultRouterContext()
14-
15-
deinit {
16-
// Destroy the root component before it is deallocated
17-
defaultRouterContext.destroy()
18-
}
19-
}
20-
21-
class AppDelegate: NSObject, UIApplicationDelegate {
22-
let holder: DefaultRouterHolder = DefaultRouterHolder()
23-
}
24-
2512
@main
2613
struct SwiftUIApp: App {
2714
@UIApplicationDelegateAdaptor var delegate: AppDelegate
@@ -44,6 +31,21 @@ struct SwiftUIApp: App {
4431
}
4532
}
4633

34+
class DefaultRouterHolder : ObservableObject {
35+
let defaultRouterContext: RouterContext = DefaultRouterContextKt.defaultRouterContext()
36+
37+
deinit {
38+
// Destroy the root component before it is deallocated
39+
defaultRouterContext.destroy()
40+
}
41+
}
42+
43+
class AppDelegate: NSObject, UIApplicationDelegate {
44+
let holder: DefaultRouterHolder = DefaultRouterHolder()
45+
}
46+
47+
48+
4749
struct HomeView: UIViewControllerRepresentable {
4850
let routerContext: RouterContext
4951

docs/c.list

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE categories
3+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
4+
<categories>
5+
<category id="wrs" name="Writerside documentation" order="1"/>
6+
<category id="external" name="External resources" order="1"/>
7+
</categories>

docs/cfg/buildprofiles.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
5+
<variables></variables>
6+
<build-profile instance="d">
7+
<variables>
8+
<noindex-content>false</noindex-content>
9+
<color-preset>soft</color-preset>
10+
<primary-color>blue</primary-color>
11+
<header-logo>decompose_router.svg</header-logo>
12+
</variables>
13+
</build-profile>
14+
15+
</buildprofiles>

docs/decompose-router.tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE instance-profile
3+
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">
4+
5+
<instance-profile id="decompose-router"
6+
name="decompose-router"
7+
start-page="overview.md">
8+
9+
<toc-element topic="overview.md"/>
10+
<toc-element topic="installation.md" toc-title="Installation">
11+
</toc-element>
12+
<toc-element topic="platform-configurations.md"/>
13+
</instance-profile>

0 commit comments

Comments
 (0)