Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,18 @@ jobs:
uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2
with:
args: --offline --no-progress --root-dir "${{ github.workspace }}" 'apps/rlark/docs/**/*.md'
lycheeVersion: v0.24.2
lycheeVersion: v0.24.2

- name: Build Chinese Read the Docs output
env:
READTHEDOCS_CANONICAL_URL: https://rlark.readthedocs.io/zh-cn/latest/
READTHEDOCS_LANGUAGE: zh-cn
READTHEDOCS_VERSION: latest
run: |
python apps/rlark/docs/rtd_patch.py
mkdocs build --strict --config-file apps/rlark/mkdocs.yml --site-dir "$GITHUB_WORKSPACE/site-rtd-zh"
grep -F 'src="images/logo-zh.png"' site-rtd-zh/index.html
grep -F 'src="images/architecture-zh.svg"' site-rtd-zh/index.html
grep -F 'src="../images/architecture-zh.svg"' site-rtd-zh/architecture/index.html
test -f site-rtd-zh/images/logo-zh.png
test -f site-rtd-zh/images/architecture-zh.svg
17 changes: 17 additions & 0 deletions apps/rlark/docs/rtd_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import re
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit


Expand Down Expand Up @@ -61,4 +62,20 @@
with open(config_path, "w", encoding="utf-8") as config_file:
config_file.write(content)

if lang == "zh":
zh_docs = Path("apps/rlark/docs/zh")
for doc_path in zh_docs.rglob("*.md"):
relative_depth = len(doc_path.relative_to(zh_docs).parent.parts)
source_prefix = "../" * (relative_depth + 1) + "images/"
output_prefix = "../" * relative_depth + "images/"

doc_content = doc_path.read_text(encoding="utf-8")
patched_content = re.sub(
rf"(?P<attribute>\bsrc\s*=\s*[\"']){re.escape(source_prefix)}",
rf"\g<attribute>{output_prefix}",
doc_content,
)
if patched_content != doc_content:
doc_path.write_text(patched_content, encoding="utf-8")

print(f"[i18n] build_only_locale={lang}")
Loading