2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-01-12 20:59:13 -05:00
|
|
|
|
|
|
|
use test_util as util;
|
2024-02-12 19:13:14 -05:00
|
|
|
use test_util::itest;
|
2023-01-12 20:59:13 -05:00
|
|
|
use util::assert_contains;
|
2023-03-13 09:40:46 -04:00
|
|
|
use util::TestContext;
|
2023-01-12 20:59:13 -05:00
|
|
|
|
|
|
|
itest!(deno_doc_builtin {
|
|
|
|
args: "doc",
|
|
|
|
output: "doc/deno_doc_builtin.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn deno_doc() {
|
2023-03-13 09:40:46 -04:00
|
|
|
let context = TestContext::default();
|
2023-01-12 20:59:13 -05:00
|
|
|
// try this twice to ensure it works with the cache
|
|
|
|
for _ in 0..2 {
|
2023-03-13 09:40:46 -04:00
|
|
|
let output = context
|
|
|
|
.new_command()
|
2023-01-12 20:59:13 -05:00
|
|
|
.env("NO_COLOR", "1")
|
2023-10-30 18:58:57 -04:00
|
|
|
.args("doc doc/deno_doc.ts doc/deno_doc2.ts")
|
2023-03-13 09:40:46 -04:00
|
|
|
.split_output()
|
|
|
|
.run();
|
|
|
|
|
|
|
|
output.assert_exit_code(0);
|
|
|
|
assert_contains!(output.stdout(), "function foo");
|
2023-10-30 18:58:57 -04:00
|
|
|
assert_contains!(output.stdout(), "function bar");
|
2023-01-12 20:59:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itest!(deno_doc_import_map {
|
2024-01-23 09:33:07 -05:00
|
|
|
args: "doc --import-map=doc/import_map.json doc/use_import_map.js",
|
2023-01-12 20:59:13 -05:00
|
|
|
output: "doc/use_import_map.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_types_hint {
|
|
|
|
args: "doc doc/types_hint.ts",
|
|
|
|
output: "doc/types_hint.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_types_ref {
|
|
|
|
args: "doc doc/types_ref.js",
|
|
|
|
output: "doc/types_ref.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_types_header {
|
|
|
|
args: "doc --reload doc/types_header.ts",
|
|
|
|
output: "doc/types_header.out",
|
|
|
|
http_server: true,
|
|
|
|
});
|
|
|
|
|
2023-10-26 21:27:50 -04:00
|
|
|
itest!(deno_doc_referenced_private_types {
|
|
|
|
args: "doc doc/referenced_private_types.ts",
|
|
|
|
output: "doc/referenced_private_types.out",
|
|
|
|
});
|
|
|
|
|
2023-10-31 18:19:42 -04:00
|
|
|
itest!(deno_doc_lint_referenced_private_types_error {
|
|
|
|
args: "doc --lint doc/referenced_private_types.ts",
|
|
|
|
exit_code: 1,
|
|
|
|
output: "doc/referenced_private_types_lint.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_lint_referenced_private_types_fixed {
|
|
|
|
args: "doc --lint doc/referenced_private_types_fixed.ts",
|
|
|
|
output: "doc/referenced_private_types_fixed.out",
|
|
|
|
});
|
|
|
|
|
2023-11-01 11:25:05 -04:00
|
|
|
itest!(deno_doc_html_lint_referenced_private_types_fixed {
|
|
|
|
args: "doc --lint --html --name=Library doc/referenced_private_types.ts",
|
|
|
|
exit_code: 1,
|
|
|
|
output: "doc/referenced_private_types_lint.out",
|
|
|
|
});
|
|
|
|
|
2023-11-04 00:43:54 -04:00
|
|
|
itest!(deno_doc_lint_success {
|
|
|
|
args: "doc --lint doc/lint_success.ts",
|
|
|
|
output: "doc/lint_success.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_lint_json_success {
|
|
|
|
args: "doc --lint --json doc/lint_success.ts",
|
|
|
|
output: "doc/lint_success_json.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_lint_html_success {
|
|
|
|
args: "doc --lint --html --name=Library lint_success.ts",
|
|
|
|
copy_temp_dir: Some("doc"),
|
|
|
|
cwd: Some("doc"),
|
|
|
|
output: "doc/lint_success_html.out",
|
|
|
|
});
|
|
|
|
|
2023-01-12 20:59:13 -05:00
|
|
|
itest!(_060_deno_doc_displays_all_overloads_in_details_view {
|
|
|
|
args:
|
2023-10-30 18:58:57 -04:00
|
|
|
"doc --filter NS.test doc/060_deno_doc_displays_all_overloads_in_details_view.ts",
|
2023-01-12 20:59:13 -05:00
|
|
|
output: "doc/060_deno_doc_displays_all_overloads_in_details_view.ts.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_types_header_direct {
|
|
|
|
args: "doc --reload http://127.0.0.1:4545/xTypeScriptTypes.js",
|
|
|
|
output: "doc/types_header.out",
|
|
|
|
http_server: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(deno_doc_invalid_url {
|
|
|
|
args: "doc https://raw.githubusercontent.com%2Fdyedgreen%2Fdeno-sqlite%2Frework_api%2Fmod.ts",
|
|
|
|
output: "doc/invalid_url.out",
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
2023-03-13 17:04:00 -04:00
|
|
|
|
|
|
|
itest!(doc_lock {
|
|
|
|
args: "doc main.ts",
|
|
|
|
http_server: true,
|
|
|
|
cwd: Some("lockfile/basic"),
|
|
|
|
exit_code: 10,
|
|
|
|
output: "lockfile/basic/fail.out",
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(doc_no_lock {
|
|
|
|
args: "doc --no-lock main.ts",
|
|
|
|
http_server: true,
|
|
|
|
cwd: Some("lockfile/basic"),
|
|
|
|
output: "lockfile/basic/doc.nolock.out",
|
|
|
|
});
|
2023-11-01 11:25:05 -04:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn deno_doc_html() {
|
|
|
|
let context = TestContext::default();
|
|
|
|
let temp_dir = context.temp_dir();
|
|
|
|
let output = context
|
|
|
|
.new_command()
|
|
|
|
.env("NO_COLOR", "1")
|
|
|
|
.args_vec(vec![
|
|
|
|
"doc",
|
|
|
|
"--html",
|
|
|
|
"--name=MyLib",
|
|
|
|
&format!("--output={}", temp_dir.path().to_string_lossy()),
|
|
|
|
"doc/referenced_private_types_fixed.ts",
|
|
|
|
])
|
|
|
|
.split_output()
|
|
|
|
.run();
|
|
|
|
|
|
|
|
output.assert_exit_code(0);
|
2023-12-01 15:12:10 -05:00
|
|
|
assert_contains!(output.stderr(), "Written 10 files to");
|
|
|
|
assert!(temp_dir.path().join("all_symbols.html").exists());
|
2023-11-01 11:25:05 -04:00
|
|
|
assert!(temp_dir.path().join("index.html").exists());
|
|
|
|
assert!(temp_dir.path().join("fuse.js").exists());
|
2023-12-01 15:12:10 -05:00
|
|
|
assert!(temp_dir.path().join("page.css").exists());
|
2023-11-01 11:25:05 -04:00
|
|
|
assert!(temp_dir.path().join("search.js").exists());
|
|
|
|
assert!(temp_dir.path().join("search_index.js").exists());
|
|
|
|
assert!(temp_dir.path().join("styles.css").exists());
|
2023-12-01 15:12:10 -05:00
|
|
|
assert!(temp_dir.path().join("~/MyInterface.html").exists());
|
|
|
|
assert!(temp_dir.path().join("~/MyClass.html").exists());
|
|
|
|
assert!(temp_dir.path().join("~/index.html").exists());
|
2023-11-01 11:25:05 -04:00
|
|
|
}
|