mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 14:01:25 +00:00
Add doc comments to web-sys dictionaries/fields
This commit ensures that web-sys generated dictionaries and fields all have comments like interfaces do, indicating a bare minimum of what's happening as well as the required features to enable the API.
This commit is contained in:
@ -1281,9 +1281,18 @@ impl ToTokens for ast::Dictionary {
|
||||
.collect::<Vec<_>>();
|
||||
let required_names2 = required_names;
|
||||
let required_names3 = required_names;
|
||||
let doc_comment = match &self.doc_comment {
|
||||
None => "",
|
||||
Some(doc_string) => doc_string,
|
||||
};
|
||||
|
||||
let ctor = if self.ctor {
|
||||
let doc_comment = match &self.ctor_doc_comment {
|
||||
None => "",
|
||||
Some(doc_string) => doc_string,
|
||||
};
|
||||
quote! {
|
||||
#[doc = #doc_comment]
|
||||
pub fn new(#(#required_names: #required_types),*) -> #name {
|
||||
let mut _ret = #name { obj: ::js_sys::Object::new() };
|
||||
#(_ret.#required_names2(#required_names3);)*
|
||||
@ -1299,6 +1308,7 @@ impl ToTokens for ast::Dictionary {
|
||||
#[derive(Clone, Debug)]
|
||||
#[repr(transparent)]
|
||||
#[allow(clippy::all)]
|
||||
#[doc = #doc_comment]
|
||||
pub struct #name {
|
||||
obj: ::js_sys::Object,
|
||||
}
|
||||
@ -1414,8 +1424,13 @@ impl ToTokens for ast::DictionaryField {
|
||||
let rust_name = &self.rust_name;
|
||||
let js_name = &self.js_name;
|
||||
let ty = &self.ty;
|
||||
let doc_comment = match &self.doc_comment {
|
||||
None => "",
|
||||
Some(doc_string) => doc_string,
|
||||
};
|
||||
(quote! {
|
||||
#[allow(clippy::all)]
|
||||
#[doc = #doc_comment]
|
||||
pub fn #rust_name(&mut self, val: #ty) -> &mut Self {
|
||||
use wasm_bindgen::JsValue;
|
||||
let r = ::js_sys::Reflect::set(
|
||||
|
Reference in New Issue
Block a user