diff --git a/main/main.cpp b/main/main.cpp index aa925c508cc..4635d377c45 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -365,7 +365,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n"); OS::get_singleton()->print(" --export-debug Same as --export, but using the debug template.\n"); OS::get_singleton()->print(" --export-pack Same as --export, but only export the game pack for the given preset. The extension determines whether it will be in PCK or ZIP format.\n"); - OS::get_singleton()->print(" --doctool Dump the engine API reference to the given in XML format, merging if existing files are found.\n"); + OS::get_singleton()->print(" --doctool [] Dump the engine API reference to the given (defaults to current dir) in XML format, merging if existing files are found.\n"); OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n"); OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n"); #ifdef DEBUG_METHODS_ENABLED @@ -1826,8 +1826,7 @@ bool Main::start() { ERR_FAIL_COND_V(!_start_success, false); bool hasicon = false; - String doc_tool; - List removal_docs; + String doc_tool_path; String positional_arg; String game_path; String script; @@ -1881,9 +1880,11 @@ bool Main::start() { script = args[i + 1]; #ifdef TOOLS_ENABLED } else if (args[i] == "--doctool") { - doc_tool = args[i + 1]; - for (int j = i + 2; j < args.size(); j++) { - removal_docs.push_back(args[j]); + doc_tool_path = args[i + 1]; + if (doc_tool_path.begins_with("-")) { + // Assuming other command line arg, so default to cwd. + doc_tool_path = "."; + parsed_pair = false; } } else if (args[i] == "--export") { editor = true; //needs editor @@ -1904,16 +1905,19 @@ bool Main::start() { if (parsed_pair) { i++; } + } else if (args[i] == "--doctool") { + // Handle case where no path is given to --doctool. + doc_tool_path = "."; } } #ifdef TOOLS_ENABLED - if (doc_tool != "") { + if (doc_tool_path != "") { Engine::get_singleton()->set_editor_hint( true); // Needed to instance editor-only classes for their default values { - DirAccessRef da = DirAccess::open(doc_tool); + DirAccessRef da = DirAccess::open(doc_tool_path); ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path."); } @@ -1943,7 +1947,7 @@ bool Main::start() { // Custom modules are always located by absolute path. String path = _doc_data_class_paths[i].path; if (path.is_rel_path()) { - path = doc_tool.plus_file(path); + path = doc_tool_path.plus_file(path); } String name = _doc_data_class_paths[i].name; doc_data_classes[name] = path; @@ -1960,7 +1964,7 @@ bool Main::start() { } } - String index_path = doc_tool.plus_file("doc/classes"); + String index_path = doc_tool_path.plus_file("doc/classes"); // Create the main documentation directory if it doesn't exist DirAccess *da = DirAccess::create_for_path(index_path); da->make_dir_recursive(index_path);