From 75f4a998fda7ab5e35b1e51c0e8a13bb91fce113 Mon Sep 17 00:00:00 2001 From: l0calh05t Date: Sat, 26 Nov 2022 12:35:36 +0100 Subject: [PATCH] Process Doxygen comments Improve quality of generated documentation by converting Bela's Doxygen comments to rustdoc format --- Cargo.toml | 5 +++-- build.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40411e0..bf28c13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,12 +5,13 @@ authors = ["Andrew C. Smith "] links = "bela" [build-dependencies] -bindgen = "0.58" +bindgen = "0.63" cc = { version = "1.0", optional = true } +doxygen-rs = { git = "https://github.com/Techie-Pi/doxygen-rs.git", rev = "a7fee318dba1939bcd6f22a7a43de1b072552d87" } [dev-dependencies] libc = "0.2" -nix = "0.22" +nix = "0.25" [features] static = [] diff --git a/build.rs b/build.rs index 98e8cfb..333542e 100644 --- a/build.rs +++ b/build.rs @@ -3,6 +3,17 @@ extern crate bindgen; use std::env; use std::path::PathBuf; +use bindgen::callbacks::ParseCallbacks; + +#[derive(Debug)] +struct DoxygenCallback; + +impl ParseCallbacks for DoxygenCallback { + fn process_comment(&self, comment: &str) -> Option { + Some(doxygen_rs::transform(comment)) + } +} + fn main() { let bela_root = PathBuf::from(env::var("BELA_SYSROOT").unwrap_or_else(|_| "/".into())); let bela_include = bela_root.join("root/Bela/include"); @@ -44,6 +55,7 @@ fn main() { .allowlist_function("rt_.*printf") .allowlist_var("BELA_.*") .allowlist_var("DEFAULT_.*") + .parse_callbacks(Box::new(DoxygenCallback)) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); @@ -79,6 +91,7 @@ fn main() { .clang_arg(format!("--sysroot={}", bela_root.to_str().unwrap())) .clang_arg(format!("-I{}", bela_include.to_str().unwrap())) .allowlist_function("Midi_.*") + .parse_callbacks(Box::new(DoxygenCallback)) .generate() .expect("Unable to generate bindings"); bindings