Skip to content

Commit

Permalink
Merge pull request #21 from tfandkusu/generate_markdown
Browse files Browse the repository at this point in the history
マークダウンファイル作成
  • Loading branch information
tfandkusu authored Aug 12, 2024
2 parents 971cae2 + 5db3caf commit 86f8147
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
- uses: gradle/gradle-build-action@v2
- run: ./gradlew spotlessCheck
- run: ./gradlew test
- run: ./gradlew run --args validate
- name: イベントの検証
run: ./gradlew run --args validate
32 changes: 32 additions & 0 deletions .github/workflows/make_document.yml
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
2 changes: 1 addition & 1 deletion .github/workflows/make_pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: make_pr
name: Android アプリリポジトリにプルリクエストを作成する
on:
push:
branches:
Expand Down
21 changes: 21 additions & 0 deletions actions.md
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 | | |

8 changes: 8 additions & 0 deletions screens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 画面遷移イベント一覧

| 画面名 | Analytics イベント名 | コンバージョンイベント |
| -- | -- | -- |
| ランドマーク一覧画面 | LandmarkList | |
| ランドマーク詳細画面 | LandmarkDetail | |
| 設定画面 | Setting ||
| 情報画面 | Info | |
1 change: 1 addition & 0 deletions src/main/kotlin/com/tfandkusu/ga913yaml/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fun main(args: Array<String>) {
"validate" -> {
val screens = YamlParser.parse()
Validator.validate(screens)
MarkdownGenerator.generate(screens)
}
"make" -> {
val screens = YamlParser.parse()
Expand Down
78 changes: 78 additions & 0 deletions src/main/kotlin/com/tfandkusu/ga913yaml/MarkdownGenerator.kt
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"
}
}

0 comments on commit 86f8147

Please sign in to comment.