diff --git a/docs.json b/docs.json
index ae901ed5..0c4e76e0 100644
--- a/docs.json
+++ b/docs.json
@@ -995,7 +995,7 @@
{
"group": "Dify 社区版",
"pages": [
- "ja-jp/getting-started/install-self-hosted/readme",
+ "ja-jp/getting-started/install-self-hosted/README",
"ja-jp/getting-started/install-self-hosted/docker-compose",
"ja-jp/getting-started/install-self-hosted/local-source-code",
"ja-jp/getting-started/install-self-hosted/bt-panel",
@@ -1014,7 +1014,7 @@
{
"group": "モデル",
"pages": [
- "ja-jp/guides/model-configuration/readme",
+ "ja-jp/guides/model-configuration/README",
"ja-jp/guides/model-configuration/new-provider",
"ja-jp/guides/model-configuration/predefined-model",
"ja-jp/guides/model-configuration/customizable-model",
@@ -1026,7 +1026,7 @@
{
"group": "アプリ・オーケストレーション",
"pages": [
- "ja-jp/guides/application-orchestrate/readme",
+ "ja-jp/guides/application-orchestrate/README",
"ja-jp/guides/application-orchestrate/creating-an-application",
{
"group": "チャットボット",
@@ -1080,7 +1080,7 @@
{
"group": "エラー処理",
"pages": [
- "ja-jp/guides/workflow/error-handling/readme",
+ "ja-jp/guides/workflow/error-handling/README",
"ja-jp/guides/workflow/error-handling/predefined-node-failure-logic",
"ja-jp/guides/workflow/error-handling/error-type"
]
@@ -1103,7 +1103,7 @@
{
"group": "ナレッジベース",
"pages": [
- "ja-jp/guides/knowledge-base/readme",
+ "ja-jp/guides/knowledge-base/README",
{
"group": "ナレッジベース作成",
"pages": [
diff --git a/scripts/contributing_in_page.py b/scripts/contributing_in_page.py
new file mode 100644
index 00000000..07bb095a
--- /dev/null
+++ b/scripts/contributing_in_page.py
@@ -0,0 +1,183 @@
+import os
+
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+def generate_contributing_section(repo_owner, repo_name, target_dir_relative, filename, language):
+ repo_url = f"https://github.com/{repo_owner}/{repo_name}"
+ if language == "zh":
+ contributing_section = f"""
+{{/*
+Contributing Section
+DO NOT edit this section!
+It will be automatically generated by the script.
+*/}}
+
+
+
+ 通过直接提交修改来帮助改进文档内容
+
+
+ 发现错误或有改进建议?请提交问题反馈
+
+
+"""
+ elif language == "en":
+ contributing_section = f"""
+{{/*
+Contributing Section
+DO NOT edit this section!
+It will be automatically generated by the script.
+*/}}
+
+
+
+ Help improve our documentation by contributing directly
+
+
+ Found an error or have suggestions? Let us know
+
+
+"""
+ elif language == "jp":
+ contributing_section = f"""
+{{/*
+Contributing Section
+DO NOT edit this section!
+It will be automatically generated by the script.
+*/}}
+
+
+
+ 直接貢献することでドキュメントの改善にご協力ください
+
+
+ エラーを見つけたり提案がありますか?お知らせください
+
+
+"""
+ else:
+ raise ValueError("Unsupported language. Supported languages are 'zh', 'en', and 'jp'.")
+
+ return contributing_section
+
+def append_content_to_files(
+ target_dir_relative, repo_owner, repo_name, language, base_dir=BASE_DIR, file_extension=".mdx"
+):
+ target_path = os.path.join(base_dir, target_dir_relative)
+
+
+ if not os.path.isdir(target_path):
+ print(f"Error: Directory '{target_path}' not found.")
+ return
+ fix_md_endings(target_dir_relative, base_dir, file_extension)
+ appended_count = 0
+ error_count = 0
+ for filename in os.listdir(target_path):
+ if filename.endswith(file_extension):
+ filepath = os.path.join(target_path, filename)
+ try:
+ # Open in text append mode to write
+ with open(filepath, "a", encoding="utf-8") as f:
+ f.write(generate_contributing_section(repo_owner, repo_name, target_dir_relative, filename, language))
+ appended_count += 1
+ except (IOError, OSError) as e:
+ print(f"Error processing file {filepath}: {e}")
+ error_count += 1
+ print(
+ f"Finished processing directory '{target_path}'. "
+ f"Appended to {appended_count} files. Encountered {error_count} errors."
+ )
+
+def remove_contributing_section(target_dir_relative, base_dir=BASE_DIR, file_extension=".mdx"):
+ import re
+ target_path = os.path.join(base_dir, target_dir_relative)
+ if not os.path.isdir(target_path):
+ print(f"Error: Directory '{target_path}' not found.")
+ return
+ removed_count = 0
+ error_count = 0
+ for filename in os.listdir(target_path):
+ if filename.endswith(file_extension):
+ filepath = os.path.join(target_path, filename)
+ try:
+ with open(filepath, "r", encoding="utf-8") as f:
+ content = f.read()
+ pattern = re.compile(r"\{/\*[\s\S]*?Contributing Section[\s\S]*?", re.DOTALL)
+ new_content = re.sub(pattern, "", content, count=1)
+ if new_content != content:
+ with open(filepath, "w", encoding="utf-8") as f:
+ f.write(new_content)
+ removed_count += 1
+ except (IOError, OSError) as e:
+ print(f"Error processing file {filepath}: {e}")
+ error_count += 1
+ fix_md_endings(target_dir_relative, base_dir, file_extension)
+ print(f"Removed from {removed_count} files. Encountered {error_count} errors.")
+
+def fix_md_endings(target_dir_relative, base_dir=BASE_DIR, file_extension=".mdx"):
+ target_path = os.path.join(base_dir, target_dir_relative)
+ if not os.path.isdir(target_path):
+ print(f"Error: Directory '{target_path}' not found.")
+ return
+ fixed_count = 0
+ error_count = 0
+ for filename in os.listdir(target_path):
+ if filename.endswith(file_extension):
+ filepath = os.path.join(target_path, filename)
+ try:
+ with open(filepath, "r", encoding="utf-8") as f:
+ content = f.read()
+ processed_content = content.replace("\r\n", "\n")
+ processed_content = processed_content.rstrip()
+ processed_content += "\n"
+ if processed_content != content:
+ with open(filepath, "w", encoding="utf-8") as f:
+ f.write(processed_content)
+ fixed_count += 1
+ except (IOError, OSError) as e:
+ print(f"Error processing file {filepath}: {e}")
+ error_count += 1
+ print(f"Fixed line endings and trailing lines in {fixed_count} files. Encountered {error_count} errors.")
+
+if __name__ == "__main__":
+ # test
+ target_dir_relative = "test"
+ language = "zh" # "zh", "en", "jp"
+ repo_name = "dify-docs-plugin-dev"
+ repo_owner = "alterxyz"
+ append_content_to_files(
+ target_dir_relative="plugin_dev_en",
+ repo_owner="alterxyz",
+ repo_name="dify-docs-plugin-dev",
+ language="en"
+ )
+ append_content_to_files(
+ target_dir_relative="plugin_dev_zh",
+ repo_owner="alterxyz",
+ repo_name="dify-docs-plugin-dev",
+ language="zh"
+ )
\ No newline at end of file