[WIP] Add support for unstable WebIDL (#1997)

* Re-enable WebGPU WebIDL as experimental

* Add `web_sys_unstable_apis` attribute

* Add test for unstable WebIDL

* Include unstable WebIDL in docs.rs builds

* Add docs and doc comment for unstable APIs

* Add unstable API checks to CI
This commit is contained in:
Josh Groves
2020-02-26 19:00:11 -03:30
committed by GitHub
parent d26068dc6c
commit 99c59a771e
24 changed files with 1387 additions and 792 deletions

View File

@ -113,10 +113,12 @@ pub fn ident_ty(ident: Ident) -> syn::Type {
}
pub fn wrap_import_function(function: ast::ImportFunction) -> ast::Import {
let unstable_api = function.unstable_api;
ast::Import {
module: ast::ImportModule::None,
js_namespace: None,
kind: ast::ImportKind::Function(function),
unstable_api,
}
}
@ -154,3 +156,20 @@ impl<T: Hash> fmt::Display for ShortHash<T> {
write!(f, "{:016x}", h.finish())
}
}
/// Create syn attribute for `#[cfg(web_sys_unstable_apis)]` and a doc comment.
pub fn unstable_api_attrs() -> proc_macro2::TokenStream {
quote::quote!(
#[cfg(web_sys_unstable_apis)]
#[doc = "\n\n*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as [described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
)
}
pub fn maybe_unstable_api_attr(unstable_api: bool) -> Option<proc_macro2::TokenStream> {
if unstable_api {
Some(unstable_api_attrs())
} else {
None
}
}