Rollup merge of #86297 - GuillaumeGomez:rustdoc-gui-args, r=Mark-Simulacrum
Allow to pass arguments to rustdoc-gui tool Very convenient for testing. This is another part of https://github.com/rust-lang/rust/pull/86293 cc ``@jsha`` r? ``@Mark-Simulacrum``
This commit is contained in:
commit
7dca2e276d
4 changed files with 39 additions and 10 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit f0618a8f06a464840079f30b3e25bcdcca3922a3
|
||||
Subproject commit 13da28cc2bc1b59f7af817eca36927a71edb023c
|
||||
|
|
@ -11,6 +11,9 @@ function showHelp() {
|
|||
console.log("rustdoc-js options:");
|
||||
console.log(" --doc-folder [PATH] : location of the generated doc folder");
|
||||
console.log(" --file [PATH] : file to run (can be repeated)");
|
||||
console.log(" --debug : show extra information about script run");
|
||||
console.log(" --show-text : render font in pages");
|
||||
console.log(" --no-headless : disable headless mode");
|
||||
console.log(" --help : show this message then quit");
|
||||
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
|
||||
}
|
||||
|
|
@ -20,10 +23,16 @@ function parseOptions(args) {
|
|||
"doc_folder": "",
|
||||
"tests_folder": "",
|
||||
"files": [],
|
||||
"debug": false,
|
||||
"show_text": false,
|
||||
"no_headless": false,
|
||||
};
|
||||
var correspondances = {
|
||||
"--doc-folder": "doc_folder",
|
||||
"--tests-folder": "tests_folder",
|
||||
"--debug": "debug",
|
||||
"--show-text": "show_text",
|
||||
"--no-headless": "no_headless",
|
||||
};
|
||||
|
||||
for (var i = 0; i < args.length; ++i) {
|
||||
|
|
@ -43,6 +52,8 @@ function parseOptions(args) {
|
|||
} else if (args[i] === "--help") {
|
||||
showHelp();
|
||||
process.exit(0);
|
||||
} else if (correspondances[args[i]]) {
|
||||
opts[correspondances[args[i]]] = true;
|
||||
} else {
|
||||
console.log("Unknown option `" + args[i] + "`.");
|
||||
console.log("Use `--help` to see the list of options");
|
||||
|
|
@ -68,17 +79,20 @@ async function main(argv) {
|
|||
const options = new Options();
|
||||
try {
|
||||
// This is more convenient that setting fields one by one.
|
||||
options.parseArguments([
|
||||
let args = [
|
||||
"--no-screenshot",
|
||||
// This option shows what puppeteer "code" is run
|
||||
// "--debug",
|
||||
// This option disable the headless mode, allowing you to see what's going on.
|
||||
// "--no-headless",
|
||||
// The text isn't rendered by default because of a lot of small differences
|
||||
// between hosts.
|
||||
// "--show-text",
|
||||
"--variable", "DOC_PATH", opts["doc_folder"],
|
||||
]);
|
||||
];
|
||||
if (opts["debug"]) {
|
||||
args.push("--debug");
|
||||
}
|
||||
if (opts["show_text"]) {
|
||||
args.push("--show-text");
|
||||
}
|
||||
if (opts["no_headless"]) {
|
||||
args.push("--no-headless");
|
||||
}
|
||||
options.parseArguments(args);
|
||||
} catch (error) {
|
||||
console.error(`invalid argument: ${error}`);
|
||||
process.exit(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue