From 8ea849e6d1afe875b0715a927914e39c6b2629e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 14 Apr 2024 17:43:16 +0200 Subject: [PATCH] ir: Write documentation on static items. --- src/bindgen/ir/global.rs | 1 + tests/expectations/documentation.c | 5 +++++ tests/expectations/documentation.compat.c | 5 +++++ tests/expectations/documentation.cpp | 3 +++ tests/expectations/documentation.pyx | 3 +++ tests/rust/documentation.rs | 7 +++++-- 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/bindgen/ir/global.rs b/src/bindgen/ir/global.rs index 82a1756e1..d476947d7 100644 --- a/src/bindgen/ir/global.rs +++ b/src/bindgen/ir/global.rs @@ -110,6 +110,7 @@ impl Item for Static { impl Source for Static { fn write(&self, config: &Config, out: &mut SourceWriter) { + self.documentation.write(config, out); out.write("extern "); if let Type::Ptr { is_const: true, .. } = self.ty { } else if !self.mutable { diff --git a/tests/expectations/documentation.c b/tests/expectations/documentation.c index e455b8df7..81768b02f 100644 --- a/tests/expectations/documentation.c +++ b/tests/expectations/documentation.c @@ -3,6 +3,11 @@ #include #include +/** + * Some docs. + */ +extern const uint32_t FOO; + /** * The root of all evil. * diff --git a/tests/expectations/documentation.compat.c b/tests/expectations/documentation.compat.c index fcdb544a9..9a4bf6a7d 100644 --- a/tests/expectations/documentation.compat.c +++ b/tests/expectations/documentation.compat.c @@ -7,6 +7,11 @@ extern "C" { #endif // __cplusplus +/** + * Some docs. + */ +extern const uint32_t FOO; + /** * The root of all evil. * diff --git a/tests/expectations/documentation.cpp b/tests/expectations/documentation.cpp index ec2b8beea..e640a879e 100644 --- a/tests/expectations/documentation.cpp +++ b/tests/expectations/documentation.cpp @@ -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 diff --git a/tests/expectations/documentation.pyx b/tests/expectations/documentation.pyx index 340b38a25..1d0743b95 100644 --- a/tests/expectations/documentation.pyx +++ b/tests/expectations/documentation.pyx @@ -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 diff --git a/tests/rust/documentation.rs b/tests/rust/documentation.rs index 56da3c3ff..909221d6d 100644 --- a/tests/rust/documentation.rs +++ b/tests/rust/documentation.rs @@ -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;