-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from tfandkusu/generate_markdown
マークダウンファイル作成
- Loading branch information
Showing
7 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: イベント仕様書の作成 | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
jobs: | ||
make_document: | ||
runs-on: ubuntu-latest | ||
if: ${{ !github.event.pull_request.draft }} | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- uses: gradle/gradle-build-action@v2 | ||
- name: イベント仕様書の作成 | ||
run: ./gradlew run --args validate | ||
- name: イベント仕様書を PUSH する | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
git add . | ||
git commit -m "イベント仕様書の更新" | ||
git push origin HEAD | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: make_pr | ||
name: Android アプリリポジトリにプルリクエストを作成する | ||
on: | ||
push: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 画面内イベント一覧 | ||
|
||
# ランドマーク一覧画面 | ||
|
||
| イベント名 | Analytics イベント名 | パラメータ | コンバージョンイベント | | ||
| -- | -- | -- | -- | | ||
| いいねを付けたランドマークのみを表示するスイッチ | LandmarkListFavoritesOnlySwitch | スイッチの ON/OFF favorites_only: Boolean<br> | | | ||
|
||
# ランドマーク詳細画面 | ||
|
||
| イベント名 | Analytics イベント名 | パラメータ | コンバージョンイベント | | ||
| -- | -- | -- | -- | | ||
| いいねを付ける | LandmarkDetailFavoriteOn | ランドマークの ID id: Long<br>ランドマークの名前 name: String<br> | ○ | | ||
| いいねを解除する | LandmarkDetailFavoriteOff | ランドマークの ID id: Long<br>ランドマークの名前 name: String<br> | | | ||
|
||
# 情報画面 | ||
|
||
| イベント名 | Analytics イベント名 | パラメータ | コンバージョンイベント | | ||
| -- | -- | -- | -- | | ||
| プライバシーポリシーを表示する | InfoPrivacyPolicy | | | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 画面遷移イベント一覧 | ||
|
||
| 画面名 | Analytics イベント名 | コンバージョンイベント | | ||
| -- | -- | -- | | ||
| ランドマーク一覧画面 | LandmarkList | | | ||
| ランドマーク詳細画面 | LandmarkDetail | | | ||
| 設定画面 | Setting | ○ | | ||
| 情報画面 | Info | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/kotlin/com/tfandkusu/ga913yaml/MarkdownGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.tfandkusu.ga913yaml | ||
|
||
import com.tfandkusu.ga913yaml.model.Parameter | ||
import com.tfandkusu.ga913yaml.model.ParameterType | ||
import com.tfandkusu.ga913yaml.model.Screen | ||
import java.io.File | ||
|
||
object MarkdownGenerator { | ||
fun generate(screens: List<Screen>) { | ||
generateScreensMarkdown(screens) | ||
generateActionsMarkdown(screens) | ||
} | ||
|
||
private fun generateScreensMarkdown(screens: List<Screen>) { | ||
val builder = StringBuilder() | ||
builder.append("# 画面遷移イベント一覧\n\n") | ||
builder.append("| 画面名 | Analytics イベント名 | コンバージョンイベント |\n") | ||
builder.append("| -- | -- | -- |\n") | ||
for (screen in screens) { | ||
builder.append("| ${screen.description} | ${screen.eventName} | ${screen.isConversionEvent.toCircle()} |\n") | ||
} | ||
File("screens.md").writeText(builder.toString()) | ||
} | ||
|
||
private fun generateActionsMarkdown(screens: List<Screen>) { | ||
val builder = StringBuilder() | ||
builder.append("# 画面内イベント一覧\n\n") | ||
for (screen in screens) { | ||
if (screen.actions.isNotEmpty()) { | ||
builder.append("# ${screen.description}\n\n") | ||
builder.append(generateActionsMarkdown(screen)) | ||
builder.append("\n") | ||
} | ||
} | ||
File("actions.md").writeText(builder.toString()) | ||
} | ||
|
||
private fun generateActionsMarkdown(screen: Screen): String { | ||
val builder = StringBuilder() | ||
builder.append("| イベント名 | Analytics イベント名 | パラメータ | コンバージョンイベント |\n") | ||
builder.append("| -- | -- | -- | -- |\n") | ||
for (action in screen.actions) { | ||
builder.append( | ||
"| ${action.description} | ${screen.eventName + action.eventName} | ${ | ||
generateParameterListString( | ||
action.parameters, | ||
) | ||
} | ${action.isConversionEvent.toCircle()} |\n", | ||
) | ||
} | ||
return builder.toString() | ||
} | ||
|
||
private fun generateParameterListString(parameters: List<Parameter>): String { | ||
val builder = StringBuilder() | ||
for (parameter in parameters) { | ||
builder.append("${parameter.description} ${parameter.eventParameterKey}: ${parameter.type.toCamelCase()}<br>") | ||
} | ||
return builder.toString() | ||
} | ||
|
||
private fun Boolean.toCircle(): String = | ||
if (this) { | ||
"○" | ||
} else { | ||
"" | ||
} | ||
|
||
private fun ParameterType.toCamelCase(): String = | ||
when (this) { | ||
ParameterType.STRING -> "String" | ||
ParameterType.INT -> "Int" | ||
ParameterType.LONG -> "Long" | ||
ParameterType.FLOAT -> "Float" | ||
ParameterType.DOUBLE -> "Double" | ||
ParameterType.BOOLEAN -> "Boolean" | ||
} | ||
} |