Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript files: Add docs for methods #1468

Closed
dbrgn opened this issue Apr 17, 2019 · 4 comments 路 Fixed by #1472
Closed

Typescript files: Add docs for methods #1468

dbrgn opened this issue Apr 17, 2019 · 4 comments 路 Fixed by #1472

Comments

@dbrgn
Copy link
Contributor

dbrgn commented Apr 17, 2019

馃挕 Feature description

In the Typescript declaration files that are generated, the struct docstrings are included but the method docstrings aren't. It would be great if methods were documented too.

馃捇 Basic example

Rust:

/// The context object containing the state.
#[wasm_bindgen]
pub struct ComposeArea {
    window: web_sys::Window,
    document: web_sys::Document,
    wrapper_id: String,
    selection_range: Option<Range>,
}

#[wasm_bindgen]
impl ComposeArea {
    /// Insert plain text at the current caret position.
    pub fn insert_text(&mut self, text: &str) {
        let text_node = self.document.create_text_node(text);
        self.insert_node(text_node.unchecked_ref());
    }
}

Current type declaration:

/**
* The context object containing the state.
*/
export class ComposeArea {
  insert_text(text: string): void;
}

Desired type declaration:

/**
* The context object containing the state.
*/
export class ComposeArea {
  /**
   * Insert plain text at the current caret position.
   */
  insert_text(text: string): void;
}
@alexcrichton alexcrichton transferred this issue from rustwasm/wasm-pack Apr 17, 2019
@alexcrichton
Copy link
Contributor

Thanks for the report! I've transferred this issue to the wasm-bindgen repository since this is where the fix will go, but I believe this is definitely something we should fix!

@c410-f3r
Copy link
Contributor

wasm-bindgen already generates docs for JS and it shouldn't be too difficult to implement it for TS. If no one is going to take on this issue, I will gladly send a PR.

@alexcrichton
Copy link
Contributor

Indeed yeah, and PRs are most welcome!

@dbrgn
Copy link
Contributor Author

dbrgn commented Apr 18, 2019

Cool, thanks @c410-f3r!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants