madonoharu / tsify

A library for generating TypeScript definitions from rust code.
Apache License 2.0
300 stars 41 forks source link

Rustdoc comments are not included in TS output #14

Open sisou opened 1 year ago

sisou commented 1 year ago

Hi! I want to use tsify to generate types (duh :D) for a public API, and I would like my rustdoc comments on my structs and fields to transport over to the TS definitions.

E.g. I have

/// JSON-compatible and human readable format of transactions. E.g. addresses are presented in their human-readable
/// format and address types and the network are represented as strings. Data and proof are serialized as an object
/// describing their contents.
#[derive(serde::Serialize, serde::Deserialize, Tsify)]
#[serde(rename_all = "camelCase")]
pub struct PlainTransaction {
    /// The transaction's unique hash, used as its identifier. Sometimes also called `txId`.
    pub transaction_hash: String,

    // [...]
}

but unfortunately the generated TS types don't include those doc comments:

export interface PlainTransaction {
    transactionHash: string;
}

I would like the output to be this instead:

/**
 * JSON-compatible and human readable format of transactions. E.g. addresses are presented in their human-readable
 * format and address types and the network are represented as strings. Data and proof are serialized as an object
 * describing their contents.
 */
export interface PlainTransaction {
    /**
     * The transaction's unique hash, used as its identifier. Sometimes also called `txId`.
     */
    transactionHash: string;
}

wasm-bindgen does this, it converts the rustdoc into JSDoc annotations.

Is this complicated?

rouzwelt commented 8 months ago

I was just about to open an issue for this, it would be great to get this feature