Skip to content

Commit

Permalink
Process Doxygen comments
Browse files Browse the repository at this point in the history
Improve quality of generated documentation by converting Bela's
Doxygen comments to rustdoc format
  • Loading branch information
l0calh05t committed Nov 26, 2022
1 parent 02cfc9f commit 75f4a99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ authors = ["Andrew C. Smith <andrewchristophersmith@gmail.com>"]
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 = []
Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
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");
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 75f4a99

Please sign in to comment.