@@ -98,7 +98,7 @@ class InstallOptions:
98
98
99
99
# Libxml2
100
100
libxml2_src_dir : str = "<third-party-src-dir>/libxml2"
101
- libxml2_build_type : str = "Release" # purposefully does not depend on mrdocs-build-type because we only need the executable
101
+ libxml2_build_type : str = "Release" # purposefully does not depend on mrdocs-build-type because we only need the executable
102
102
libxml2_build_dir : str = "<libxml2-src-dir>/build/<libxml2-build-type:lower><\" -\" :if(cc)><cc:basename>"
103
103
libxml2_install_dir : str = "<libxml2-src-dir>/install/<libxml2-build-type:lower><\" -\" :if(cc)><cc:basename>"
104
104
libxml2_repo : str = "https://github.com/GNOME/libxml2"
@@ -109,8 +109,9 @@ class InstallOptions:
109
109
jetbrains_run_config_dir : str = "<mrdocs-src-dir>/.run"
110
110
boost_src_dir : str = "<mrdocs-src-dir>/../boost"
111
111
112
- # Meta
112
+ # Command line arguments
113
113
non_interactive : bool = False
114
+ refresh_all : bool = False
114
115
115
116
116
117
# Constant for option descriptions
@@ -154,7 +155,8 @@ class InstallOptions:
154
155
"generate_run_configs" : "Whether to generate run configurations for IDEs." ,
155
156
"jetbrains_run_config_dir" : "Directory where JetBrains run configurations will be stored." ,
156
157
"boost_src_dir" : "Directory where the source files of the Boost libraries are located." ,
157
- "non_interactive" : "Whether to use all default options without interactive prompts."
158
+ "non_interactive" : "Whether to use all default options without interactive prompts." ,
159
+ "refresh_all" : "Call the command to refresh dependencies for all configurations"
158
160
}
159
161
160
162
@@ -178,6 +180,7 @@ def __init__(self, cmd_line_args=None):
178
180
else :
179
181
raise TypeError (f"Unsupported type { field .type } for field { field .name } in InstallOptions." )
180
182
self .options .non_interactive = self .cmd_line_args .get ("non_interactive" , False )
183
+ self .options .refresh_all = self .cmd_line_args .get ("refresh_all" , False )
181
184
self .prompted_options = set ()
182
185
self .compiler_info = {}
183
186
@@ -1805,6 +1808,13 @@ def generate_run_configs(self):
1805
1808
"args" : bootstrap_refresh_args ,
1806
1809
"cwd" : self .options .mrdocs_src_dir
1807
1810
})
1811
+ configs .append ({
1812
+ "name" : f"MrDocs Bootstrap Refresh All" ,
1813
+ "script" : os .path .join (self .options .mrdocs_src_dir , "bootstrap.py" ),
1814
+ "folder" : "MrDocs Bootstrap Refresh" ,
1815
+ "args" : ["--refresh-all" ],
1816
+ "cwd" : self .options .mrdocs_src_dir
1817
+ })
1808
1818
1809
1819
# Targets for the pre-build steps
1810
1820
configs .append ({
@@ -1956,6 +1966,33 @@ def install_all(self):
1956
1966
else :
1957
1967
print ("Skipping run configurations generation as per user preference." )
1958
1968
1969
+ def refresh_all (self ):
1970
+ # 1. Read all configurations in .vscode/launch.json
1971
+ current_python_interpreter_path = sys .executable
1972
+ this_script_path = os .path .abspath (__file__ )
1973
+ mrdocs_src_dir = os .path .dirname (this_script_path )
1974
+ vscode_launch_path = os .path .join (mrdocs_src_dir , ".vscode" , "launch.json" )
1975
+ if not os .path .exists (vscode_launch_path ):
1976
+ print ("No existing Visual Studio Code launch configurations found." )
1977
+ return
1978
+ with open (vscode_launch_path , "r" ) as f :
1979
+ vscode_launch_data = json .load (f )
1980
+ vscode_configs = vscode_launch_data .get ("configurations" , [])
1981
+
1982
+ # 2. Filter configurations whose name starts with "MrDocs Bootstrap Refresh ("
1983
+ bootstrap_refresh_configs = [
1984
+ cfg for cfg in vscode_configs if cfg .get ("name" , "" ).startswith ("MrDocs Bootstrap Refresh (" )
1985
+ ]
1986
+ if not bootstrap_refresh_configs :
1987
+ print ("No bootstrap refresh configurations found in Visual Studio Code launch configurations." )
1988
+ return
1989
+
1990
+ # 3. For each configuration, run this very same bootstrap.py script with the same arguments
1991
+ for config in bootstrap_refresh_configs :
1992
+ args = [current_python_interpreter_path , this_script_path ] + [
1993
+ arg .replace ("${workspaceFolder}" , mrdocs_src_dir ) for arg in config .get ("args" , [])]
1994
+ print (f"Running bootstrap refresh with arguments: { args } " )
1995
+ subprocess .run (args , check = True )
1959
1996
1960
1997
def get_command_line_args ():
1961
1998
"""
@@ -1999,6 +2036,9 @@ def get_command_line_args():
1999
2036
def main ():
2000
2037
args = get_command_line_args ()
2001
2038
installer = MrDocsInstaller (args )
2039
+ if installer .options .refresh_all :
2040
+ installer .refresh_all ()
2041
+ exit (0 )
2002
2042
installer .install_all ()
2003
2043
2004
2044
0 commit comments