mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-26 11:34:22 +03:00
Merge pull request #428 from alexcrichton/missing-docs
Fix some cases with `#[deny(missing_docs)]`
This commit is contained in:
commit
2b5dd430a8
@ -191,6 +191,7 @@ impl ToTokens for ast::Struct {
|
|||||||
|
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[doc(hidden)]
|
||||||
pub unsafe extern fn #free_fn(ptr: u32) {
|
pub unsafe extern fn #free_fn(ptr: u32) {
|
||||||
<#name as ::wasm_bindgen::convert::FromWasmAbi>::from_abi(
|
<#name as ::wasm_bindgen::convert::FromWasmAbi>::from_abi(
|
||||||
ptr,
|
ptr,
|
||||||
@ -246,6 +247,7 @@ impl ToTokens for ast::StructField {
|
|||||||
);
|
);
|
||||||
(quote! {
|
(quote! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[doc(hidden)]
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub unsafe extern fn #getter(js: u32)
|
pub unsafe extern fn #getter(js: u32)
|
||||||
-> <#ty as ::wasm_bindgen::convert::IntoWasmAbi>::Abi
|
-> <#ty as ::wasm_bindgen::convert::IntoWasmAbi>::Abi
|
||||||
@ -279,6 +281,7 @@ impl ToTokens for ast::StructField {
|
|||||||
|
|
||||||
(quote! {
|
(quote! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[doc(hidden)]
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
pub unsafe extern fn #setter(
|
pub unsafe extern fn #setter(
|
||||||
js: u32,
|
js: u32,
|
||||||
@ -441,8 +444,10 @@ impl ToTokens for ast::Export {
|
|||||||
let descriptor_name = Ident::new(&descriptor_name, Span::call_site());
|
let descriptor_name = Ident::new(&descriptor_name, Span::call_site());
|
||||||
let nargs = self.function.arguments.len() as u32;
|
let nargs = self.function.arguments.len() as u32;
|
||||||
let argtys = self.function.arguments.iter().map(|arg| &arg.ty);
|
let argtys = self.function.arguments.iter().map(|arg| &arg.ty);
|
||||||
|
let attrs = &self.function.rust_attrs;
|
||||||
|
|
||||||
let tokens = quote! {
|
let tokens = quote! {
|
||||||
|
#(#attrs)*
|
||||||
#[export_name = #export_name]
|
#[export_name = #export_name]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||||
|
@ -456,3 +456,52 @@ fn rename_setter_getter() {
|
|||||||
)
|
)
|
||||||
.test();
|
.test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deny_missing_docs() {
|
||||||
|
project()
|
||||||
|
.file(
|
||||||
|
"src/lib.rs",
|
||||||
|
r#"
|
||||||
|
//! dox
|
||||||
|
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
/// dox
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct Bar {
|
||||||
|
/// dox
|
||||||
|
pub a: u32,
|
||||||
|
b: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
/// dox
|
||||||
|
pub type Foo;
|
||||||
|
|
||||||
|
/// dox
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new() -> Foo;
|
||||||
|
|
||||||
|
/// dox
|
||||||
|
#[wasm_bindgen(getter = a, method)]
|
||||||
|
pub fn test(this: &Foo) -> i32;
|
||||||
|
|
||||||
|
/// dox
|
||||||
|
pub fn foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// dox
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn test() {
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.test();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user