Add C99 doc comment style
In modern C (post-C99) it's common to just use `// double-slash comments`, but currently cbindgen provides only `/* block-comment */` and `/// triple-slash comment` variants.
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
19fd975b6f
commit
944ecb958e
@@ -106,7 +106,7 @@ language = "[C|C++]"
|
||||
style = "[Both|Type|Tag]"
|
||||
# How the generated documentation should be commented.
|
||||
# C uses /* */; C++ uses //; Doxy is like C but with leading * per line.
|
||||
documentation_style = "[C, C++, Doxy]"
|
||||
documentation_style = "[C, C99, C++, Doxy]"
|
||||
|
||||
|
||||
[defines]
|
||||
|
||||
@@ -104,6 +104,7 @@ deserialize_enum_str!(Layout);
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
pub enum DocumentationStyle {
|
||||
C,
|
||||
C99,
|
||||
Doxy,
|
||||
Cxx,
|
||||
Auto,
|
||||
@@ -115,6 +116,7 @@ impl FromStr for DocumentationStyle {
|
||||
fn from_str(s: &str) -> Result<DocumentationStyle, Self::Err> {
|
||||
match s.to_lowercase().as_ref() {
|
||||
"c" => Ok(DocumentationStyle::C),
|
||||
"c99" => Ok(DocumentationStyle::C99),
|
||||
"cxx" => Ok(DocumentationStyle::Cxx),
|
||||
"c++" => Ok(DocumentationStyle::Cxx),
|
||||
"doxy" => Ok(DocumentationStyle::Doxy),
|
||||
|
||||
@@ -67,6 +67,7 @@ impl Source for Documentation {
|
||||
match style {
|
||||
DocumentationStyle::C => out.write(""),
|
||||
DocumentationStyle::Doxy => out.write(" *"),
|
||||
DocumentationStyle::C99 => out.write("//"),
|
||||
DocumentationStyle::Cxx => out.write("///"),
|
||||
DocumentationStyle::Auto => unreachable!(), // Auto case should always be covered
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The root of all evil.
|
||||
void root(void);
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The root of all evil.
|
||||
void root(void);
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// The root of all evil.
|
||||
void root();
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The root of all evil.
|
||||
void root(void);
|
||||
@@ -0,0 +1,4 @@
|
||||
/// The root of all evil.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root() {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
documentation_style = "c99"
|
||||
Reference in New Issue
Block a user