Skip to content

Commit

Permalink
ir: Write documentation on static items.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Apr 14, 2024
1 parent e0aeb8f commit 8ea849e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/bindgen/ir/global.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;

0 comments on commit 8ea849e

Please sign in to comment.