Skip to content

Commit 72bfb1e

Browse files
committed
feat: dynamically adding/updating all README file
Signed-off-by: rajput-hemant <[email protected]>
1 parent 501a873 commit 72bfb1e

File tree

7 files changed

+2859
-36
lines changed

7 files changed

+2859
-36
lines changed

docs/readme.py .dev/docs.py

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
1-
import os, re
1+
import os
2+
import re
23

34
SOLUTION_FOLDER = "./docs/solution"
45
SERIALWISE = "./docs/SERIALWISE.md"
56
TOPICWISE = "./docs/TOPICWISE.md"
67
SIDEBAR = "./docs/.vitepress/Sidebar.js"
78

9+
TAGS = {
10+
"BIT": "Binary Indexed Tree",
11+
"BS": "Binary Search",
12+
"BST": "Binary Search Tree",
13+
"Bit Manip": "Bit Manipulation",
14+
"BFS": "Breadth First Search",
15+
"DFS": "Depth First Search",
16+
"DNC": "Divide and Conquer",
17+
"DLL": "Doubly Linked List",
18+
"DP": "Dynamic Programming",
19+
"LL": "Linked List",
20+
"MEM": "Memoization",
21+
"MST": "Minimum Spanning Tree",
22+
"Q": "Queue",
23+
"ST": "Stack",
24+
"TAB": "Tabulation",
25+
"2P": "Two Pointers",
26+
}
27+
828

929
def refactor_serialwise():
1030
with open(SERIALWISE, "r", encoding="utf-8") as file:
1131
readme = file.read()
1232
with open(SERIALWISE, "w", encoding="utf-8") as file:
1333
readme = (
1434
readme.replace("../docs/public", "")
35+
.replace("/\n", ".md\n")
1536
.replace(
1637
"<kbd>Ctrl</kbd>+<kbd>F</kbd> or <kbd>⌘</kbd>+<kbd>F</kbd>",
1738
"`Ctrl`+`F` or `⌘`+`F`",
1839
)
19-
.replace("/\n", ".md\n")
2040
)
41+
for key, value in TAGS.items():
42+
readme = readme.replace(key, value)
2143
if "./solution/" not in readme:
2244
readme = readme.replace("]: ./", "]: ./solution/")
2345
file.write(readme)
@@ -27,15 +49,18 @@ def refactor_topicwise():
2749
with open(TOPICWISE, "r", encoding="utf-8") as file:
2850
readme = file.read()
2951
with open(TOPICWISE, "w", encoding="utf-8") as file:
30-
file.write(
52+
readme = (
3153
readme.replace("docs/public", "")
54+
.replace("/\n", ".md\n")
55+
.replace("./src/", "./solution/")
3256
.replace(
3357
"<kbd>Ctrl</kbd>+<kbd>F</kbd> or <kbd>⌘</kbd>+<kbd>F</kbd>",
3458
"`Ctrl`+`F` or `⌘`+`F`",
3559
)
36-
.replace("./src/", "./solution/")
37-
.replace("/\n", ".md\n")
3860
)
61+
for key, value in TAGS.items():
62+
readme = readme.replace(key, value)
63+
file.write(readme)
3964

4065

4166
def refactor_sidebar():
@@ -86,8 +111,8 @@ def refactor_readmes():
86111

87112
def main():
88113
refactor_serialwise()
89-
refactor_topicwise()
90-
refactor_sidebar()
114+
# refactor_topicwise()
115+
# refactor_sidebar()
91116
refactor_readmes()
92117

93118

0 commit comments

Comments
 (0)