mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 22:51:14 +00:00
feat(cli/doc): use type definitions "deno doc" if available (#8459)
This commit adds support for type definitions in "deno doc"; with this change "deno doc" is able to leverage the same directives as TS compiler. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
687ff2ab14
commit
cdae4423c2
10 changed files with 232 additions and 132 deletions
6
cli/tests/doc/types_header.out
Normal file
6
cli/tests/doc/types_header.out
Normal file
|
@ -0,0 +1,6 @@
|
|||
Download http://127.0.0.1:4545/xTypeScriptTypes.js
|
||||
Download http://127.0.0.1:4545/xTypeScriptTypes.d.ts
|
||||
Defined in http://127.0.0.1:4545/xTypeScriptTypes.d.ts:1:0
|
||||
|
||||
const foo: "foo"
|
||||
|
1
cli/tests/doc/types_header.ts
Normal file
1
cli/tests/doc/types_header.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from "http://127.0.0.1:4545/xTypeScriptTypes.js";
|
5
cli/tests/doc/types_hint.out
Normal file
5
cli/tests/doc/types_hint.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
Defined in [WILDCARD]/type_definitions/foo.d.ts:2:0
|
||||
|
||||
const foo: string
|
||||
An exported value.
|
||||
|
2
cli/tests/doc/types_hint.ts
Normal file
2
cli/tests/doc/types_hint.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
// @deno-types="../type_definitions/foo.d.ts"
|
||||
export * from "../type_definitions/foo.js";
|
2
cli/tests/doc/types_ref.js
Normal file
2
cli/tests/doc/types_ref.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
/// <reference types="../type_definitions/foo.d.ts" />
|
||||
export const foo = "foo";
|
5
cli/tests/doc/types_ref.out
Normal file
5
cli/tests/doc/types_ref.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
Defined in [WILDCARD]/type_definitions/foo.d.ts:2:0
|
||||
|
||||
const foo: string
|
||||
An exported value.
|
||||
|
|
@ -3669,20 +3669,10 @@ console.log("finish");
|
|||
exit_code: 0,
|
||||
});
|
||||
|
||||
itest!(deno_doc_builtin {
|
||||
args: "doc",
|
||||
output: "deno_doc_builtin.out",
|
||||
});
|
||||
|
||||
itest!(deno_doc {
|
||||
args: "doc deno_doc.ts",
|
||||
output: "deno_doc.out",
|
||||
});
|
||||
|
||||
itest!(deno_doc_import_map {
|
||||
args:
|
||||
"doc --unstable --import-map=doc/import_map.json doc/use_import_map.js",
|
||||
output: "doc/use_import_map.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!(import_data_url_error_stack {
|
||||
|
@ -3945,6 +3935,42 @@ console.log("finish");
|
|||
assert_eq!(output.stderr, b"");
|
||||
}
|
||||
|
||||
mod doc {
|
||||
use super::*;
|
||||
|
||||
itest!(deno_doc_builtin {
|
||||
args: "doc",
|
||||
output: "deno_doc_builtin.out",
|
||||
});
|
||||
|
||||
itest!(deno_doc {
|
||||
args: "doc deno_doc.ts",
|
||||
output: "deno_doc.out",
|
||||
});
|
||||
|
||||
itest!(deno_doc_import_map {
|
||||
args:
|
||||
"doc --unstable --import-map=doc/import_map.json doc/use_import_map.js",
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
mod coverage {
|
||||
use super::*;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue