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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstrings missing for constant values in C++ headers. #1995

Closed
achary opened this issue Feb 14, 2021 · 3 comments
Closed

Docstrings missing for constant values in C++ headers. #1995

achary opened this issue Feb 14, 2021 · 3 comments

Comments

@achary
Copy link

achary commented Feb 14, 2021

Input C/C++ Header

// test.hpp

#pragma once

/// This is a constant that has a docstring
///
/// And expected be be found in generated bindings code too.
const int FOO = 1;

/// This is a constant that has a docstring
///
/// And expected be be found in generated bindings code too.
struct Bar
{
    int baz;
};

Bindgen Invocation

// in build.rs 

    let bindings = bindgen::Builder::default()
        .header("test.hpp")
        .layout_tests(false)
        .generate_comments(true)
        .generate()
        .expect("Unable to generate bindings");

    bindings
        .write_to_file(out_path.join("test.rs"))
        .expect("Couldn't write bindings!");

Actual Results

/* automatically generated by rust-bindgen 0.57.0 */

pub const FOO: ::std::os::raw::c_int = 1;
#[doc = " This is a constant that has a docstring"]
#[doc = ""]
#[doc = " And expected be be found in generated bindings code too."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
    pub baz: ::std::os::raw::c_int,
}

Expected Results

Markdown docstring for the const FOO should be present in the output *.rs file as well.

@emilio
Copy link
Contributor

emilio commented Apr 3, 2021

impl CodeGenerator for Var doesn't look at item.comment(), and it probably should, should be trivial to fix :)

@highfive
Copy link

highfive commented Apr 3, 2021

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in Matrix.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@emilio
Copy link
Contributor

emilio commented Jun 21, 2021

this was fixed in #2027, thanks!

@emilio emilio closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants