fix: formatting
This commit is contained in:
parent
731ad4fd84
commit
1ca6dd3129
1 changed files with 7 additions and 16 deletions
23
.github/scripts/prepare_docs.py
vendored
23
.github/scripts/prepare_docs.py
vendored
|
|
@ -3,33 +3,24 @@ import glob
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
folders_to_copy = ['src', 'scripts']
|
folders_to_copy = ["src", "scripts"]
|
||||||
for folder in folders_to_copy:
|
for folder in folders_to_copy:
|
||||||
if os.path.exists(folder):
|
if os.path.exists(folder):
|
||||||
shutil.copytree(folder, f'docs/{folder}', dirs_exist_ok=True)
|
shutil.copytree(folder, f"docs/{folder}", dirs_exist_ok=True)
|
||||||
|
|
||||||
for filepath in glob.glob('docs/**/*.md', recursive=True):
|
for filepath in glob.glob("docs/**/*.md", recursive=True):
|
||||||
with open(filepath, 'r', encoding='utf-8') as f:
|
with open(filepath, "r", encoding="utf-8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# RULE A: Fix links pointing OUT to src/ or scripts/
|
# RULE A: Fix links pointing OUT to src/ or scripts/
|
||||||
# Logic: Because the folders were moved one level deeper, we remove exactly ONE '../'
|
# Logic: Because the folders were moved one level deeper, we remove exactly ONE '../'
|
||||||
content = re.sub(
|
content = re.sub(r"\]\(\.\./((?:\.\./)*)(src|scripts)/([^)]*)\)", r"](\1\2/\3)", content)
|
||||||
r'\]\(\.\./((?:\.\./)*)(src|scripts)/([^)]*)\)',
|
|
||||||
r'](\1\2/\3)',
|
|
||||||
content
|
|
||||||
)
|
|
||||||
|
|
||||||
# RULE B: Fix links pointing FROM the copied files back TO the original docs/ folder
|
# RULE B: Fix links pointing FROM the copied files back TO the original docs/ folder
|
||||||
# Logic: Since these files are now inside docs/, the 'docs/' segment in the path is redundant.
|
# Logic: Since these files are now inside docs/, the 'docs/' segment in the path is redundant.
|
||||||
content = re.sub(
|
content = re.sub(r"\]\(((?:\.\./)+)docs/([^)]*)\)", r"](\1\2)", content)
|
||||||
r'\]\(((?:\.\./)+)docs/([^)]*)\)',
|
|
||||||
r'](\1\2)',
|
|
||||||
content
|
|
||||||
)
|
|
||||||
|
|
||||||
with open(filepath, 'w', encoding='utf-8') as f:
|
with open(filepath, "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
print("Successfully imported external files and adjusted markdown links.")
|
print("Successfully imported external files and adjusted markdown links.")
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue