Skip to content

Commit a521f1c

Browse files
GinMysticial
authored andcommitted
use script to update links
1 parent dc18d97 commit a521f1c

File tree

193 files changed

+326
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+326
-194
lines changed

SerialPrograms/Scripts/CodeTemplates/Program/GameName_ProgramName.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ProgramName_Descriptor::ProgramName_Descriptor()
2020
: SingleSwitchProgramDescriptor(
2121
"GameName:ProgramName",
2222
"Game Name", "Program Name",
23-
"ComputerControl/blob/master/Wiki/Programs/GameName/ProgramName.md",
23+
"Programs/GameName/ProgramName.html",
2424
"<Description of this program>.",
2525
FeedbackType::REQUIRED,
2626
AllowCommandsWhenRunning::DISABLE_COMMANDS,
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Script to update wiki links from old format to new format.
4+
Old format: Programs/PokemonSV/AutoStory.html
5+
New format: Programs/PokemonSV/AutoStory.html
6+
"""
7+
8+
import os
9+
import re
10+
import sys
11+
from pathlib import Path
12+
13+
14+
def update_wiki_links(content):
15+
"""
16+
Update wiki links from old format to new format.
17+
18+
Args:
19+
content: File content as string
20+
21+
Returns:
22+
Updated content with new wiki links
23+
"""
24+
# Pattern to match old wiki links
25+
# Matches: ComputerControl/blob/master/Wiki/ followed by path and .md extension
26+
pattern = r'ComputerControl/blob/master/Wiki/([^)\s]+)\.md'
27+
28+
# Replace with new format: just the path with .html extension
29+
replacement = r'\1.html'
30+
31+
updated_content = re.sub(pattern, replacement, content)
32+
33+
return updated_content
34+
35+
36+
def process_file(file_path):
37+
"""
38+
Process a single file to update wiki links.
39+
40+
Args:
41+
file_path: Path to the file to process
42+
43+
Returns:
44+
True if file was modified, False otherwise
45+
"""
46+
try:
47+
with open(file_path, 'r', encoding='utf-8') as f:
48+
content = f.read()
49+
50+
updated_content = update_wiki_links(content)
51+
52+
if content != updated_content:
53+
# Convert to Windows line endings (CRLF)
54+
updated_content = updated_content.replace('\r\n', '\n').replace('\n', '\r\n')
55+
56+
with open(file_path, 'w', encoding='utf-8', newline='') as f:
57+
f.write(updated_content)
58+
return True
59+
60+
return False
61+
except Exception as e:
62+
print(f"Error processing {file_path}: {e}", file=sys.stderr)
63+
return False
64+
65+
66+
def find_files_with_wiki_links(root_dir, extensions=None):
67+
"""
68+
Find all files that might contain wiki links.
69+
70+
Args:
71+
root_dir: Root directory to search
72+
extensions: List of file extensions to search (default: code files only)
73+
74+
Returns:
75+
List of file paths
76+
"""
77+
if extensions is None:
78+
# Only process code files (.cpp, .h, .c, .hpp, .cc, .cxx)
79+
extensions = ['.cpp', '.h', '.c', '.hpp', '.cc', '.cxx', '.tpp']
80+
81+
files_to_process = []
82+
83+
for root, dirs, files in os.walk(root_dir):
84+
# Skip certain directories
85+
dirs[:] = [d for d in dirs if d not in ['.git', 'build', 'Build', '__pycache__']]
86+
87+
for file in files:
88+
if any(file.endswith(ext) for ext in extensions):
89+
files_to_process.append(os.path.join(root, file))
90+
91+
return files_to_process
92+
93+
94+
def main():
95+
"""Main function to update wiki links in the repository."""
96+
# Determine the root directory (SerialPrograms directory)
97+
script_dir = Path(__file__).parent
98+
serial_programs_dir = script_dir.parent
99+
100+
print(f"Searching for wiki links in: {serial_programs_dir}")
101+
print("Looking for pattern: ComputerControl/blob/master/Wiki/.../*.md")
102+
print("Replacing with: .../....html")
103+
print("Target files: C/C++ code files (.cpp, .h, .c, .hpp, .cc, .cxx, .tpp)")
104+
print("Output: Windows line endings (CRLF)\n")
105+
106+
# Find all relevant files
107+
files = find_files_with_wiki_links(serial_programs_dir)
108+
print(f"Found {len(files)} files to scan\n")
109+
110+
# Process each file
111+
modified_count = 0
112+
modified_files = []
113+
114+
for file_path in files:
115+
if process_file(file_path):
116+
modified_count += 1
117+
modified_files.append(file_path)
118+
print(f"Updated: {os.path.relpath(file_path, serial_programs_dir)}")
119+
120+
print(f"\n{'='*60}")
121+
print(f"Summary: {modified_count} file(s) modified")
122+
123+
if modified_files:
124+
print("\nModified files:")
125+
for file_path in modified_files:
126+
print(f" - {os.path.relpath(file_path, serial_programs_dir)}")
127+
128+
return 0 if modified_count >= 0 else 1
129+
130+
131+
if __name__ == "__main__":
132+
sys.exit(main())

SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ GlobalSettings::GlobalSettings()
160160
, m_discord_settings(
161161
"<font size=4><b>Discord Settings:</b> Integrate with Discord. (" +
162162
make_text_url(
163-
ONLINE_DOC_URL_BASE + "ComputerControl/blob/master/Wiki/Software/DiscordIntegration.md",
163+
ONLINE_DOC_URL_BASE + "DiscordIntegration/index.html",
164164
"online documentation"
165165
) + ")</font>"
166166
)
@@ -282,7 +282,7 @@ void GlobalSettings::load_json(const JsonValue& json){
282282
m_discord_settings.set_text(
283283
"<font size=4><b>Discord Settings:</b> Integrate with Discord. (" +
284284
make_text_url(
285-
ONLINE_DOC_URL_BASE + "ComputerControl/blob/master/Wiki/Software/DiscordIntegration.md",
285+
ONLINE_DOC_URL_BASE + "DiscordIntegration/index.html",
286286
"online documentation"
287287
) + ")</font>"
288288
);

SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LabelImages_Descriptor::LabelImages_Descriptor()
3434
Color(),
3535
"ML:LabelImages",
3636
"ML", "Label Images",
37-
"ComputerControl/blob/master/Wiki/Programs/ML/LabelImages.md",
37+
"Programs/ML/LabelImages.html",
3838
"Label " + Pokemon::STRING_POKEMON + " on images"
3939
)
4040
{}

SerialPrograms/Source/ML/Programs/ML_RunYOLO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RunYOLO_Descriptor::RunYOLO_Descriptor()
2626
: SingleSwitchProgramDescriptor(
2727
"NintendoSwitch:RunYOLO",
2828
"Nintendo Switch", "Run YOLO",
29-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/RunYOLO.md",
29+
"Programs/NintendoSwitch/RunYOLO.html",
3030
"Run YOLO object detection model.",
3131
ProgramControllerClass::StandardController_NoRestrictions,
3232
FeedbackType::NONE,

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_Settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ ConsoleSettings_Descriptor::ConsoleSettings_Descriptor()
176176
Color(),
177177
"NintendoSwitch:GlobalSettings",
178178
"Nintendo Switch", "Framework Settings",
179-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/FrameworkSettings.md",
179+
"Programs/NintendoSwitch/FrameworkSettings.html",
180180
"Switch Framework Settings"
181181
)
182182
{}

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FriendCodeAdder_Descriptor::FriendCodeAdder_Descriptor()
2020
: SingleSwitchProgramDescriptor(
2121
"NintendoSwitch:FriendCodeAdder",
2222
"Nintendo Switch", "Friend Code Adder",
23-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/FriendCodeAdder.md",
23+
"Programs/NintendoSwitch/FriendCodeAdder.html",
2424
"Add a list of friend codes.",
2525
ProgramControllerClass::StandardController_PerformanceClassSensitive,
2626
FeedbackType::NONE,

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FriendDelete_Descriptor::FriendDelete_Descriptor()
1515
: SingleSwitchProgramDescriptor(
1616
"NintendoSwitch:FriendDelete",
1717
"Nintendo Switch", "Friend Delete",
18-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/FriendDelete.md",
18+
"Programs/NintendoSwitch/FriendDelete.html",
1919
"Mass delete/block all those unwanted friends.",
2020
ProgramControllerClass::StandardController_NoRestrictions,
2121
FeedbackType::NONE,

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_PreventSleep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PreventSleep_Descriptor::PreventSleep_Descriptor()
1515
: SingleSwitchProgramDescriptor(
1616
"NintendoSwitch:PreventSleep",
1717
"Nintendo Switch", "Prevent Sleep",
18-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/PreventSleep.md",
18+
"Programs/NintendoSwitch/PreventSleep.html",
1919
"Press B every 15 seconds to keep the Switch from sleeping.",
2020
ProgramControllerClass::StandardController_NoRestrictions,
2121
FeedbackType::NONE,

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_PushJoySticks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PushJoySticks_Descriptor::PushJoySticks_Descriptor()
1616
: SingleSwitchProgramDescriptor(
1717
"NintendoSwitch:PushJoySticks",
1818
"Nintendo Switch", "Push Joy Sticks",
19-
"ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/PushJoySticks.md",
19+
"Programs/NintendoSwitch/PushJoySticks.html",
2020
"Push Joy Sticks continuously.",
2121
ProgramControllerClass::StandardController_NoRestrictions,
2222
FeedbackType::NONE,

0 commit comments

Comments
 (0)