Skip to content

Commit

Permalink
feat: upgrade deno_ast to 0.7 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 8, 2021
1 parent cc14e65 commit e699df7
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install rust
uses: hecrj/setup-rust-action@v1.3.4
with:
rust-version: 1.56.0
rust-version: 1.57.0

- name: Install clippy and rustfmt
run: |
Expand Down
51 changes: 26 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_doc"
version = "0.21.0"
version = "0.22.0"
edition = "2021"
description = "doc generation for deno"
authors = ["the Deno authors"]
Expand All @@ -16,8 +16,8 @@ name = "ddoc"
[dependencies]
anyhow = { version = "1.0.43", optional = true }
cfg-if = "1.0.0"
deno_ast = "0.5.0"
deno_graph = "0.12.0"
deno_ast = "0.7.0"
deno_graph = "0.13.0"
futures = "0.3.17"
js-sys = { version = "0.3.55", optional = true }
lazy_static = "1.4.0"
Expand Down
9 changes: 5 additions & 4 deletions lib/deno_doc.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
}
function __wbg_adapter_20(arg0, arg1, arg2) {
wasm
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1a8fcdae8f66ba52(
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h549293aed5fa1e6a(
arg0,
arg1,
addHeapObject(arg2),
Expand All @@ -221,7 +221,8 @@ function isLikeNone(x) {
* @param {boolean} include_all
* @param {Function} load
* @param {Function | undefined} maybe_resolve
* @returns {Promise<any>} */
* @returns {Promise<any>}
*/
export function doc(root_specifier, include_all, load, maybe_resolve) {
var ptr0 = passStringToWasm0(
root_specifier,
Expand All @@ -247,7 +248,7 @@ function handleError(f, args) {
}
}
function __wbg_adapter_36(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__hdf4cefd48e3ddd54(
wasm.wasm_bindgen__convert__closures__invoke2_mut__hd87b62b08b802ff6(
arg0,
arg1,
addHeapObject(arg2),
Expand Down Expand Up @@ -405,7 +406,7 @@ const imports = {
__wbindgen_throw: function (arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
},
__wbindgen_closure_wrapper834: function (arg0, arg1, arg2) {
__wbindgen_closure_wrapper835: function (arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 156, __wbg_adapter_20);
return addHeapObject(ret);
},
Expand Down
Binary file modified lib/deno_doc_bg.wasm
Binary file not shown.
5 changes: 1 addition & 4 deletions src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ pub fn class_to_class_def(
ClassProp(class_prop) => {
let prop_js_doc = js_doc_for_span(parsed_source, &class_prop.span());

let ts_type = class_prop
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let ts_type = class_prop.type_ann.as_ref().map(ts_type_ann_to_def);

let prop_name = expr_to_name(&*class_prop.key);

Expand Down
5 changes: 1 addition & 4 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ pub fn function_to_function_def(
params.push(param_def);
}

let maybe_return_type = function
.return_type
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let maybe_return_type = function.return_type.as_ref().map(ts_type_ann_to_def);

let type_params =
maybe_type_param_decl_to_type_param_defs(function.type_params.as_ref());
Expand Down
22 changes: 6 additions & 16 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,8 @@ pub fn get_doc_for_ts_interface_decl(

let name = expr_to_name(&*ts_method_sig.key);

let maybe_return_type = ts_method_sig
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let maybe_return_type =
ts_method_sig.type_ann.as_ref().map(ts_type_ann_to_def);

let type_params = maybe_type_param_decl_to_type_param_defs(
ts_method_sig.type_params.as_ref(),
Expand All @@ -271,10 +269,8 @@ pub fn get_doc_for_ts_interface_decl(
let method_js_doc = js_doc_for_span(parsed_source, &ts_getter_sig.span);
let name = expr_to_name(&*ts_getter_sig.key);

let maybe_return_type = ts_getter_sig
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let maybe_return_type =
ts_getter_sig.type_ann.as_ref().map(ts_type_ann_to_def);

let method_def = InterfaceMethodDef {
name,
Expand Down Expand Up @@ -322,10 +318,7 @@ pub fn get_doc_for_ts_interface_decl(
params.push(param_def);
}

let ts_type = ts_prop_sig
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let ts_type = ts_prop_sig.type_ann.as_ref().map(ts_type_ann_to_def);

let type_params = maybe_type_param_decl_to_type_param_defs(
ts_prop_sig.type_params.as_ref(),
Expand Down Expand Up @@ -353,10 +346,7 @@ pub fn get_doc_for_ts_interface_decl(
params.push(param_def);
}

let ts_type = ts_call_sig
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let ts_type = ts_call_sig.type_ann.as_ref().map(ts_type_ann_to_def);

let type_params = maybe_type_param_decl_to_type_param_defs(
ts_call_sig.type_params.as_ref(),
Expand Down
16 changes: 5 additions & 11 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn ident_to_param_def(
_parsed_source: Option<&ParsedSource>,
ident: &deno_ast::swc::ast::BindingIdent,
) -> ParamDef {
let ts_type = ident.type_ann.as_ref().map(|rt| ts_type_ann_to_def(rt));
let ts_type = ident.type_ann.as_ref().map(ts_type_ann_to_def);

ParamDef::Identifier {
name: ident.id.sym.to_string(),
Expand All @@ -157,7 +157,7 @@ fn rest_pat_to_param_def(
parsed_source: Option<&ParsedSource>,
rest_pat: &deno_ast::swc::ast::RestPat,
) -> ParamDef {
let ts_type = rest_pat.type_ann.as_ref().map(|rt| ts_type_ann_to_def(rt));
let ts_type = rest_pat.type_ann.as_ref().map(ts_type_ann_to_def);

ParamDef::Rest {
arg: Box::new(pat_to_param_def(parsed_source, &*rest_pat.arg)),
Expand Down Expand Up @@ -193,10 +193,7 @@ fn object_pat_to_param_def(
.iter()
.map(|prop| object_pat_prop_to_def(parsed_source, prop))
.collect::<Vec<_>>();
let ts_type = object_pat
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let ts_type = object_pat.type_ann.as_ref().map(ts_type_ann_to_def);

ParamDef::Object {
props,
Expand All @@ -214,7 +211,7 @@ fn array_pat_to_param_def(
.iter()
.map(|elem| elem.as_ref().map(|e| pat_to_param_def(parsed_source, e)))
.collect::<Vec<Option<_>>>();
let ts_type = array_pat.type_ann.as_ref().map(|rt| ts_type_ann_to_def(rt));
let ts_type = array_pat.type_ann.as_ref().map(ts_type_ann_to_def);

ParamDef::Array {
elements,
Expand All @@ -227,10 +224,7 @@ pub fn assign_pat_to_param_def(
parsed_source: Option<&ParsedSource>,
assign_pat: &deno_ast::swc::ast::AssignPat,
) -> ParamDef {
let ts_type = assign_pat
.type_ann
.as_ref()
.map(|rt| ts_type_ann_to_def(rt));
let ts_type = assign_pat.type_ann.as_ref().map(ts_type_ann_to_def);

ParamDef::Assign {
left: Box::new(pat_to_param_def(parsed_source, &*assign_pat.left)),
Expand Down
2 changes: 1 addition & 1 deletion src/ts_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ impl From<&TsImportType> for TsTypeDef {

let import_type_def = TsImportTypeDef {
specifier: other.arg.value.to_string(),
qualifier: other.qualifier.as_ref().map(|e| ts_entity_name_to_name(e)),
qualifier: other.qualifier.as_ref().map(ts_entity_name_to_name),
type_params,
};

Expand Down
2 changes: 1 addition & 1 deletion src/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn get_doc_for_var_decl(

let maybe_ts_type = match &var_declarator.name {
deno_ast::swc::ast::Pat::Ident(ident) => {
ident.type_ann.as_ref().map(|rt| ts_type_ann_to_def(rt))
ident.type_ann.as_ref().map(ts_type_ann_to_def)
}
_ => None,
};
Expand Down

0 comments on commit e699df7

Please sign in to comment.