@@ -50,6 +50,7 @@ class InstallOptions:
50
50
# Tools
51
51
git_path : str = ''
52
52
cmake_path : str = ''
53
+ java_path : str = ''
53
54
54
55
# MrDocs
55
56
mrdocs_src_dir : str = field (
@@ -107,6 +108,7 @@ class InstallOptions:
107
108
INSTALL_OPTION_DESCRIPTIONS = {
108
109
"git_path" : "Path to the git executable, if not in system PATH." ,
109
110
"cmake_path" : "Path to the cmake executable, if not in system PATH." ,
111
+ "java_path" : "Path to the java executable, if not in system PATH." ,
110
112
"mrdocs_src_dir" : "MrDocs source directory." ,
111
113
"mrdocs_repo" : "URL of the MrDocs repository to clone." ,
112
114
"mrdocs_branch" : "Branch or tag of the MrDocs repository to use." ,
@@ -510,7 +512,8 @@ def setup_mrdocs_dir(self):
510
512
511
513
# MrDocs build type
512
514
self .prompt_build_type_option ("mrdocs_build_type" )
513
- self .prompt_option ("mrdocs_build_tests" )
515
+ if self .prompt_option ("mrdocs_build_tests" ):
516
+ self .check_tool ("java" )
514
517
515
518
def is_inside_mrdocs_dir (self , path ):
516
519
"""
@@ -962,6 +965,31 @@ def generate_clion_run_configs(self, configs):
962
965
for key , value in config ['env' ].items ():
963
966
ET .SubElement (envs , "env" , name = key , value = value )
964
967
ET .SubElement (clion_config , "method" , v = "2" )
968
+ else :
969
+ attrib = {
970
+ "default" : "false" ,
971
+ "name" : config ["name" ],
972
+ "type" : "ShConfigurationType"
973
+ }
974
+ if 'folder' in config :
975
+ attrib ["folderName" ] = config ["folder" ]
976
+ clion_config = ET .SubElement (root , "configuration" , attrib )
977
+ ET .SubElement (clion_config , "option" , name = "SCRIPT_TEXT" , value = f"{ shlex .quote (config ['script' ])} { ' ' .join (shlex .quote (arg ) for arg in config ['args' ])} " )
978
+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_SCRIPT_PATH" , value = "true" )
979
+ ET .SubElement (clion_config , "option" , name = "SCRIPT_PATH" , value = config ["script" ])
980
+ ET .SubElement (clion_config , "option" , name = "SCRIPT_OPTIONS" , value = "" )
981
+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_SCRIPT_WORKING_DIRECTORY" , value = "true" )
982
+ if 'cwd' in config and config ["cwd" ] != self .options .mrdocs_src_dir :
983
+ ET .SubElement (clion_config , "option" , name = "SCRIPT_WORKING_DIRECTORY" , value = config ["cwd" ])
984
+ else :
985
+ ET .SubElement (clion_config , "option" , name = "SCRIPT_WORKING_DIRECTORY" , value = "$PROJECT_DIR$" )
986
+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_INTERPRETER_PATH" , value = "true" )
987
+ ET .SubElement (clion_config , "option" , name = "INTERPRETER_PATH" , value = "" )
988
+ ET .SubElement (clion_config , "option" , name = "INTERPRETER_OPTIONS" , value = "" )
989
+ ET .SubElement (clion_config , "option" , name = "EXECUTE_IN_TERMINAL" , value = "true" )
990
+ ET .SubElement (clion_config , "option" , name = "EXECUTE_SCRIPT_FILE" , value = "false" )
991
+ ET .SubElement (clion_config , "envs" )
992
+ ET .SubElement (clion_config , "method" , v = "2" )
965
993
966
994
tree = ET .ElementTree (root )
967
995
tree .write (run_config_path , encoding = "utf-8" , xml_declaration = False )
@@ -988,7 +1016,7 @@ def generate_visual_studio_run_configs(self, configs):
988
1016
"type" : "default" ,
989
1017
"project" : "MrDocs" ,
990
1018
"args" : config ["args" ],
991
- "cwd" : self .options .mrdocs_build_dir ,
1019
+ "cwd" : config . get ( 'cwd' , self .options .mrdocs_build_dir ) ,
992
1020
"env" : {},
993
1021
"stopAtEntry" : False ,
994
1022
"console" : "integratedTerminal"
@@ -1227,6 +1255,57 @@ def generate_run_configs(self):
1227
1255
"cwd" : mrdocs_website_dir
1228
1256
})
1229
1257
1258
+ # XML schema tests
1259
+ if self .options .java_path :
1260
+ configs .append ({
1261
+ "name" : "MrDocs Generate RelaxNG Schema" ,
1262
+ "script" : self .options .java_path ,
1263
+ "args" : [
1264
+ "-jar" ,
1265
+ os .path .join (self .options .mrdocs_src_dir , "util" , "trang.jar" ),
1266
+ os .path .join (self .options .mrdocs_src_dir , "mrdocs.rnc" ),
1267
+ os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" )
1268
+ ],
1269
+ "cwd" : self .options .mrdocs_src_dir
1270
+ })
1271
+
1272
+ libxml2_xmllint_executable = os .path .join (self .options .libxml2_install_dir , "bin" , "xmllint" )
1273
+ xml_sources_dir = os .path .join (self .options .mrdocs_src_dir , "test-files" , "golden-tests" )
1274
+
1275
+ if self .is_windows ():
1276
+ xml_sources = []
1277
+ for root , _ , files in os .walk (xml_sources_dir ):
1278
+ for file in files :
1279
+ if file .endswith (".xml" ) and not file .endswith (".bad.xml" ):
1280
+ xml_sources .append (os .path .join (root , file ))
1281
+ configs .append ({
1282
+ "name" : "MrDocs XML Lint with RelaxNG Schema" ,
1283
+ "script" : libxml2_xmllint_executable ,
1284
+ "args" : [
1285
+ "--dropdtd" ,
1286
+ "--noout" ,
1287
+ "--relaxng" ,
1288
+ os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" )
1289
+ ].extend (xml_sources ),
1290
+ "cwd" : self .options .mrdocs_src_dir
1291
+ })
1292
+ else :
1293
+ configs .append ({
1294
+ "name" : "MrDocs XML Lint with RelaxNG Schema" ,
1295
+ "script" : "find" ,
1296
+ "args" : [
1297
+ xml_sources_dir ,
1298
+ "-type" , "f" ,
1299
+ "-name" , "*.xml" ,
1300
+ "!" , "-name" , "*.bad.xml" ,
1301
+ "-exec" , libxml2_xmllint_executable ,
1302
+ "--dropdtd" , "--noout" ,
1303
+ "--relaxng" , os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" ),
1304
+ "{}" , "+"
1305
+ ],
1306
+ "cwd" : self .options .mrdocs_src_dir
1307
+ })
1308
+
1230
1309
print ("Generating CLion run configurations for MrDocs..." )
1231
1310
self .generate_clion_run_configs (configs )
1232
1311
print ("Generating Visual Studio run configurations for MrDocs..." )
0 commit comments