first commit

This commit is contained in:
dekun
2026-06-10 19:59:27 +08:00
commit d141623070
813 changed files with 61301 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import os
DOCS_DIR = "docs"
# 获取脚本所在的路径
script_dir = os.path.dirname(os.path.abspath(__file__))
work_dir = os.path.join(script_dir, DOCS_DIR)
content = []
for root, _, files in os.walk(work_dir):
for file in files:
if not str(file).endswith(".md"):
continue
path = os.path.join(root, file)
with open(path, "r+") as f:
lines = f.readlines()
if len(lines) == 0:
continue
if lines[0].startswith("---"):
continue
lines.insert(0, "---\nhide:\n - navigation\n---\n")
f.seek(0)
f.writelines(lines)
f.truncate()
+24
View File
@@ -0,0 +1,24 @@
import os
DOCS_DIR = "docs/other"
# 获取脚本所在的路径
script_dir = os.path.dirname(os.path.abspath(__file__))
work_dir = os.path.join(script_dir, DOCS_DIR)
content = []
for root, _, files in os.walk(work_dir):
for file in files:
if not str(file).endswith(".md"):
continue
path = os.path.join(root, file)
with open(path) as f:
lines = f.readlines()
if len(lines) == 0:
continue
# 从第7行开始为标题
desc = lines[6].strip()
basename = os.path.basename(root)
content.append(f"|[{basename}](other/{basename}/)|{desc}|")
content.sort()
print("\n".join(content))
+22
View File
@@ -0,0 +1,22 @@
import os
DOCS_DIR = "docs"
# 获取脚本所在的路径
script_dir = os.path.dirname(os.path.abspath(__file__))
work_dir = os.path.join(script_dir, DOCS_DIR)
content = []
for root, _, files in os.walk(work_dir):
for file in files:
if not str(file).endswith(".md"):
continue
path = os.path.join(root, file)
with open(path) as f:
lines = f.readlines()
# 从第五行开始为标题
desc = lines[4].strip()[2:]
basename = os.path.basename(root)
content.append(f"|[{basename}]({basename}/)|{desc}|")
content.sort()
print("\n".join(content))
+48
View File
@@ -0,0 +1,48 @@
import os
import re
def replace_links(file_path):
with open(file_path, 'r') as f:
content = f.read()
# content = re.sub(r'(/[^/]+\.md/)', '/', content)
content = re.sub(r'(\.\./)(\d)(\.)', r'\g<1>0\2\3', content)
with open(file_path, 'w') as f:
f.write(content)
TARGET_NAME = "index.md"
DOCS_DIR = "docs/other"
# 获取脚本所在的路径
script_dir = os.path.dirname(os.path.abspath(__file__))
work_dir = os.path.join(script_dir, DOCS_DIR)
# 遍历目录中的文件
for root, _, files in os.walk(work_dir):
sp = str(root).split(".")
if len(sp) == 2:
dirname = os.path.dirname(sp[0])
basename = os.path.basename(sp[0])
if len(str(basename)) == 1:
# 1 => 01 2 => 02
basename = f"0{basename}.{sp[1]}"
os.rename(root, os.path.join(dirname, basename))
if root.endswith("other"):
continue
for fn in files:
fp = os.path.join(root, fn)
with open(fp, "r+") as f:
lines = f.readlines()
if len(lines) == 0:
continue
lines = lines[2:]
lines[0] = lines[0][2:-4]
lines[0] = lines[0] + "\n"
lines[0] = f"# {lines[0]}"
f.seek(0)
f.writelines(lines)
f.truncate()
print('done')
+42
View File
@@ -0,0 +1,42 @@
import os
import re
def replace_links(file_path):
with open(file_path, 'r') as f:
content = f.read()
# content = re.sub(r'(/[^/]+\.md/)', '/', content)
content = re.sub(r'(\.\./)(\d)(\.)', r'\g<1>0\2\3', content)
with open(file_path, 'w') as f:
f.write(content)
TARGET_NAME = "index.md"
DOCS_DIR = "docs"
# 获取脚本所在的路径
script_dir = os.path.dirname(os.path.abspath(__file__))
work_dir = os.path.join(script_dir, DOCS_DIR)
# 遍历目录中的文件
for root, _, files in os.walk(work_dir):
sp = str(root).split(".")
if len(sp) == 2:
dirname = os.path.dirname(sp[0])
basename = os.path.basename(sp[0])
if len(str(basename)) == 1:
# 1 => 01 2 => 02
basename = f"0{basename}.{sp[1]}"
os.rename(root, os.path.join(dirname, basename))
for file in files:
if not file.endswith(".md"):
continue
path = os.path.join(root, file)
replace_links(path)
if file == TARGET_NAME:
continue
new_file = os.path.join(root, TARGET_NAME)
os.rename(path, new_file)
print('done')