-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
73 additions
and
9,899 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.bkp | ||
*.venv | ||
.DS_Store | ||
preview.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import re\n", | ||
"\n", | ||
"# Define the directory where the Markdown files and \"_sidebar.md\" are located\n", | ||
"path_docs = \"docs\" # Replace with the actual directory path\n", | ||
"SIDEBAR_FILE = os.path.join(path_docs, \"_sidebar.md\")\n", | ||
"\n", | ||
"# Extract the file order from \"_sidebar.md\"\n", | ||
"FILES = []\n", | ||
"if os.path.isfile(SIDEBAR_FILE):\n", | ||
" with open(SIDEBAR_FILE, \"r\", encoding=\"utf-8\") as sidebar:\n", | ||
" for line in sidebar:\n", | ||
" # Match the Markdown file path in each line, e.g., \"catalog.md\", \"chapter1.md\"\n", | ||
" match = re.search(r'\\(([^)]+\\.md)\\)', line)\n", | ||
" if match:\n", | ||
" FILES.append(match.group(1))\n", | ||
"else:\n", | ||
" print(f\"Warning: Sidebar file {SIDEBAR_FILE} does not exist.\")\n", | ||
"\n", | ||
"# Merge Markdown file content\n", | ||
"merged_content = \"\"\n", | ||
"for file in FILES:\n", | ||
" file_path = os.path.join(path_docs, file)\n", | ||
" if os.path.isfile(file_path):\n", | ||
" with open(file_path, \"r\", encoding=\"utf-8\") as f:\n", | ||
" merged_content += f.read() + \"\\n\\n\" # Add an empty line as a separator\n", | ||
" else:\n", | ||
" print(f\"Warning: File {file_path} does not exist and will be skipped.\")\n", | ||
"\n", | ||
"path_releases = \"releases\" # Replace with the actual directory path\n", | ||
"if not os.path.exists(path_releases):\n", | ||
" os.makedirs(path_releases)\n", | ||
"\n", | ||
"# Write the merged content to a temporary file\n", | ||
"merged_file = f\"{path_releases}/preview.md\"\n", | ||
"with open(merged_file, \"w\", encoding=\"utf-8\") as f:\n", | ||
" f.write(merged_content)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.