doxygen_rs/
lib.rs

1//! Simple Doxygen to Rustdoc translation.
2//!
3//! Provides a simple and straightforward API to translate _raw_ Doxygen comments to Rustdoc
4//! comments. Purely experimental right now, maybe practical in a future?
5//!
6//! # Examples
7//!
8//! ```
9//! use doxygen_rs::transform;
10//!
11//! let rustdoc = transform("@brief Example Doxygen brief");
12//! assert_eq!(rustdoc, "Example Doxygen brief");
13//! ```
14//!
15//! # Usage with bindgen >= 0.63
16//!
17//! ```
18//! # trait ParseCallbacks {
19//! #   fn process_comment(&self, comment: &str) -> Option<String>;
20//! # }
21//! #[derive(Debug)]
22//! struct Cb;
23//!
24//! impl ParseCallbacks for Cb {
25//!     fn process_comment(&self, comment: &str) -> Option<String> {
26//!         Some(doxygen_rs::transform(comment))
27//!     }
28//! }
29//! ```
30
31mod emojis;
32pub mod generator;
33mod lexer;
34mod parser;
35
36/// This function transforms the Doxygen of a single element (function, struct, etc.)
37///
38/// # Panics
39///
40/// This function will panic if any error from [`generator::rustdoc`] is returned.
41pub fn transform(value: &str) -> String {
42    generator::rustdoc(value.into()).expect("failed to transform the comments")
43}