Skip to content

Commit

Permalink
Merge pull request #259 from bearsunday/1page
Browse files Browse the repository at this point in the history
全てのマニュアルをマージしたページをCIでビルド
  • Loading branch information
koriym authored Apr 16, 2024
2 parents 65b3039 + 54b4466 commit f723a30
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run merge_md_files

on:
pull_request:
workflow_dispatch:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Run merge_md_files
run: ruby bin/merge_md_files.rb
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ _site/
.idea
watch
.DS_Store
/manuals/1.0/en/1page.md
/manuals/1.0/ja/1page.md
3 changes: 3 additions & 0 deletions _includes/manuals/1.0/en/contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<li class="nav-item">
<a class="nav-link {% if page.permalink == '/manuals/1.0/en/apidoc.html' %}active{% endif %}" href="/manuals/1.0/en/apidoc.html">API Doc</a>
</li>
<li class="nav-item">
<a class="nav-link {% if page.permalink == '/manuals/1.0/ja/1page.html' %}active{% endif %}" href="/manuals/1.0/ja/1page.html">1 Page</a>
</li>
</ul>
</div>
</nav>
3 changes: 3 additions & 0 deletions _includes/manuals/1.0/ja/contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<li class="nav-item">
<a class="nav-link {% if page.permalink == '/manuals/1.0/ja/apidoc.html' %}active{% endif %}" href="/manuals/1.0/ja/apidoc.html">API Doc</a>
</li>
<li class="nav-item">
<a class="nav-link {% if page.permalink == '/manuals/1.0/ja/1page.html' %}active{% endif %}" href="/manuals/1.0/ja/1page.html">1 Page</a>
</li>
</ul>
</div>
</nav>
45 changes: 45 additions & 0 deletions bin/merge_md_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'fileutils'

def generate_combined_file(language, intro_message)
# マークダウンファイルが存在するフォルダ
source_folder = File.expand_path("../manuals/1.0/#{language}/", __dir__)
# 結合されたファイルの出力先
output_file = "manuals/1.0/#{language}/1page.md"

puts "Does the source folder exist? #{Dir.exist?(source_folder)}"
raise "Source folder does not exist!" unless File.directory?(source_folder)

# ファイルを開く
File.open(output_file, "w") do |combined_file|

# 全体のヘッダーを書き込む
combined_file.write("---\nlayout: docs-#{language}\ntitle: 1 Page Manual\ncategory: Manual\npermalink: /manuals/1.0/#{language}/1page.html\n---\n")

# 追加のメッセージを書き込む
combined_file.write(intro_message + "\n\n")

# 指定フォルダ内のすべての.mdファイルを取得し、ソートする
files = Dir.glob(File.join(source_folder, "*.md")).sort

# 各ファイルを処理する - ヘッダーを削除
files.each do |filepath|
File.open(filepath, "r") do |file|
# ファイル内容を読む
content = file.read

# ヘッダー部分を削除 ("---"で囲まれた部分を削除)
content.gsub!(/---.*?---/m, '')

# 出力ファイルに書き込み
combined_file.write(content + "\n")
end
end

end

puts "Markdown files have been combined into #{output_file}"
end

# 以下の行を使用して関数を2言語で呼び出す
generate_combined_file("ja", "これはBEAR.Sundayの全てのマニュアルを1つに集めたページです。")
generate_combined_file("en", "This is the page that collects all BEAR.Sunday manuals in one place.")
2 changes: 2 additions & 0 deletions manuals/1.0/ja/resource_renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ permalink: /manuals/1.0/ja/resource_renderer.html

# レンダリングと転送

<img src="https://bearsunday.github.io/images/screen/4r.png" alt="Resource object internal stucture">

ResourceObjectのリクエストメソッドではリソースの表現について関心を持ちません。コンテキストに応じて注入されたレンダラーがリソースの表現を生成します。同じアプリケーションがコンテキストを変えるだけでHTMLで出力されたり、JSONで出力されたりします。

## 遅延評価
Expand Down

0 comments on commit f723a30

Please sign in to comment.