summaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-07 10:14:20 -0700
committerGitHub <noreply@github.com>2026-10-07 10:14:20 -0700
commit8a20d5238855de5479d84e7fd8e84561844e2dc4 (patch)
treebbeab7de6ac8b556911d117989ab4bbc0324ecb5 /.github/workflows
parent81b654d76444d747fdf1d053760e507b50f26e18 (diff)
parentb2862f980f3d78012066ef1cc09d4ad58f886c0f (diff)
downloadSimple-8a20d5238855de5479d84e7fd8e84561844e2dc4.tar.gz
Simple-8a20d5238855de5479d84e7fd8e84561844e2dc4.zip
Merge pull request #262 from com-junkawasaki/docs/japanese-chapters
docs: add Japanese translations for all chapters
Diffstat (limited to '.github/workflows')
-rwxr-xr-x.github/workflows/linearize.sh57
1 files changed, 45 insertions, 12 deletions
diff --git a/.github/workflows/linearize.sh b/.github/workflows/linearize.sh
index 7ce8e52c..f793ac6d 100755
--- a/.github/workflows/linearize.sh
+++ b/.github/workflows/linearize.sh
@@ -17,6 +17,12 @@ git init -q -b main
repo=..
+# The donated Japanese index accompanies the English one when present.
+readmes=(README.md)
+if [[ -f "$repo/README.ja.md" ]]; then
+ readmes+=(README.ja.md)
+fi
+
last_committer_date='0 +0000'
git -C "$repo" ls-tree HEAD --name-only | grep '^chapter' |
@@ -47,7 +53,7 @@ while read -r chapter; do
done <<< "$all_authors"
# Get the first and last dates this chapter was modified.
- root_files=(README.md LICENSE pom.xml .gitignore .dir-locals.el transpile-tests graph print isa build-support)
+ root_files=("${readmes[@]}" LICENSE pom.xml .gitignore .dir-locals.el transpile-tests graph print isa build-support)
author_root_files=()
if [[ $chapter = chapter01 ]]; then
# Only include the commit date of the root files for chapter01.
@@ -65,29 +71,47 @@ while read -r chapter; do
git rm -qr --ignore-unmatch .
cp -R "$repo/$chapter/." .
mkdir -p docs
- mv README.md docs/
+ # Grammar documents now sit beside their chapter README.
+ for doc in docs/*.md; do
+ [[ -f "$doc" ]] || continue
+ sed -Ei 's,\(\.\./README(\.ja)?\.md([#)]),(README\1.md\2,g' "$doc"
+ sed -Ei 's,\(\.\./\.\./(chapter[0-9]+[a-z]?)/docs/,(../\1/,g' "$doc"
+ done
+ # Keep the READMEs and supporting notes together, including Japanese copies.
+ mv *.md docs/
mv docs chapter_docs
+ if [[ -d appendix ]]; then
+ mv appendix chapter_docs/
+ sed -Ei 's,\(\.\./docs/,(../,g' chapter_docs/appendix/*.md
+ fi
rm pom.xml || :
git add .
- # Add the shared files in the root, except for README.md and pom.xml.
+ # Add the shared files in the root, except for the indexes and pom.xml.
root_files=(LICENSE .gitignore .dir-locals.el transpile-tests graph print isa build-support)
cp -R "${root_files[@]/#/"$repo/"}" .
git add "${root_files[@]}"
- # Fix README.md, docs/chapter??/README.md, and pom.xml.
+ # Fix the English/Japanese indexes, chapter READMEs, and pom.xml.
if git rev-parse HEAD >/dev/null 2>/dev/null; then
# Restore the documentation and pom.xml from the previous chapter.
- git diff --staged --diff-filter=D --name-only -- docs README.md pom.xml | xargs git checkout -q HEAD
+ git diff --staged --diff-filter=D --name-only -- docs "${readmes[@]}" pom.xml | xargs git checkout -q HEAD
else
# This is the first commit; setup shared files.
- cp "$repo"/{README.md,pom.xml} .
+ cp "${readmes[@]/#/"$repo/"}" "$repo/pom.xml" .
mkdir docs
# Shared type-domain illustrations are referenced from chapter READMEs.
cp "$repo"/docs/type-*.svg docs/
git add docs/type-*.svg
+ if [[ -f "$repo/docs/japanese-translation.md" ]]; then
+ cp "$repo/docs/japanese-translation.md" docs/
+ git add docs/japanese-translation.md
+ fi
# Remove links to chapters.
sed -Ei 's,\[Chapter ([0-9]+[a-z]?)\]\(chapter0?\1/README\.md\),Chapter \1,' README.md
+ if [[ -f README.ja.md ]]; then
+ sed -Ei 's,\[([^]]+)\]\(chapter[0-9]+[a-z]?/README(\.ja)?\.md\),\1,g' README.ja.md
+ fi
# Change to a JAR and delete the modules, for a single-project structure.
sed -i -e 's,<packaging>pom</packaging>,<packaging>jar</packaging>,' \
-e '/<modules>/,/^$/d' pom.xml
@@ -107,13 +131,22 @@ while read -r chapter; do
git mv chapter_docs "docs/$chapter"
# Restore the link to this chapter.
sed -Ei "s,^\* Chapter $chapter_number: ,* [Chapter $chapter_number](docs/$chapter/README.md): ," README.md
+ if [[ -f README.ja.md ]]; then
+ translated=README.md
+ if [[ -f "docs/$chapter/README.ja.md" ]]; then
+ translated=README.ja.md
+ fi
+ sed -Ei "s,^\* 第${chapter_number}章:,* [第${chapter_number}章](docs/$chapter/$translated):," README.ja.md
+ fi
# Repair links for this chapter.
- sed -Ei 's,\bdocs/,,' "docs/$chapter/README.md"
- sed -Ei 's,\(\.\./isa/,(../../isa/,g' "docs/$chapter/README.md"
- # Source links are chapter-relative in the main tree; sources live at the
- # repository root in a standalone chapter checkout.
- sed -Ei 's,\((\./)?src/,(../../src/,g' "docs/$chapter/README.md"
- git add README.md "docs/$chapter/README.md" pom.xml
+ for doc in "docs/$chapter"/README*.md; do
+ sed -Ei 's,\bdocs/,,g' "$doc"
+ sed -Ei 's,\(\.\./(isa|graph|print)/,(../../\1/,g' "$doc"
+ sed -Ei 's,\(\.\./README(\.ja)?\.md([#)]),(../../README\1.md\2,g' "$doc"
+ # Sources live at the root in a standalone chapter checkout.
+ sed -Ei 's,\((\./)?src/,(../../src/,g' "$doc"
+ done
+ git add "${readmes[@]}" "docs/$chapter" pom.xml
# Create a commit for the chapter, using the metadata.
if [[ ! "$first_author" =~ ^(.*)\ \<(.*)\>$ ]]; then