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

ir: Write documentation on static items. #941

Merged
merged 1 commit into from Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bindgen/ir/global.rs
Expand Up @@ -110,6 +110,7 @@ impl Item for Static {

impl Source for Static {
fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
self.documentation.write(config, out);
out.write("extern ");
if let Type::Ptr { is_const: true, .. } = self.ty {
} else if !self.mutable {
Expand Down
5 changes: 5 additions & 0 deletions tests/expectations/documentation.c
Expand Up @@ -3,6 +3,11 @@
#include <stdint.h>
#include <stdlib.h>

/**
* Some docs.
*/
extern const uint32_t FOO;

/**
* The root of all evil.
*
Expand Down
5 changes: 5 additions & 0 deletions tests/expectations/documentation.compat.c
Expand Up @@ -7,6 +7,11 @@
extern "C" {
#endif // __cplusplus

/**
* Some docs.
*/
extern const uint32_t FOO;

/**
* The root of all evil.
*
Expand Down
3 changes: 3 additions & 0 deletions tests/expectations/documentation.cpp
Expand Up @@ -6,6 +6,9 @@

extern "C" {

/// Some docs.
extern const uint32_t FOO;

/// The root of all evil.
///
/// But at least it contains some more documentation as someone would expect
Expand Down
3 changes: 3 additions & 0 deletions tests/expectations/documentation.pyx
Expand Up @@ -6,6 +6,9 @@ cdef extern from *:

cdef extern from *:

# Some docs.
extern const uint32_t FOO;

# The root of all evil.
#
# But at least it contains some more documentation as someone would expect
Expand Down
7 changes: 5 additions & 2 deletions tests/rust/documentation.rs
Expand Up @@ -17,5 +17,8 @@
/// slash doc-comment marker and the rest.
///
#[no_mangle]
pub extern "C" fn root() {
}
pub extern "C" fn root() {}

/// Some docs.
#[no_mangle]
pub static FOO: u32 = 4;