@ -7,17 +7,7 @@
//!
//!
//! # Transformations
//! # Transformations
//!
//!
//! The following are _completely_ removed, but _its contents are kept_:
//! Check [doxygen-rs docs](https://techie-pi.github.io/doxygen-rs/doxygen_rs/)
//! * `@brief`
//! * `@ref`
//! * `@note`
//! * `@return`
//! * `@sa`
//! * `<`
//! * `[out]` and `[in]`
//!
//! The followings are _partially_ transformed to Rustdoc format:
//! * `@param`
use std ::path ::Path ;
use std ::path ::Path ;
use std ::{ env , fs , io } ;
use std ::{ env , fs , io } ;
@ -26,35 +16,8 @@ fn main() -> io::Result<()> {
let args : Vec < String > = env ::args ( ) . collect ( ) ;
let args : Vec < String > = env ::args ( ) . collect ( ) ;
let bindings_path = Path ::new ( args . get ( 1 ) . expect ( "bindings.rs not provided in the args" ) ) ;
let bindings_path = Path ::new ( args . get ( 1 ) . expect ( "bindings.rs not provided in the args" ) ) ;
let bindings_string : String = fs ::read_to_string ( bindings_path ) ? ;
let parsed = bindings_string
let parsed = doxygen_rs ::transform_bindgen ( & bindings_path ) ? ;
. lines ( )
. map ( | v | {
// Only modify lines with the following structure: `` #[doc ... ] ``
if v . trim_start ( ) . starts_with ( "#[doc" ) & & v . trim_end ( ) . ends_with ( ']' ) {
v . replace ( "@brief" , "" )
// Example: ``@param offset Offset of the RomFS...`` -> ``- offset Offset of the RomFS...``
// Will improve in the future
. replace ( "@param" , "* " )
. replace ( "@ref" , "" )
. replace ( "@note" , "" )
. replace ( "@return" , "" )
. replace ( "@sa" , "" )
. replace ( "< " , "" )
// Remove things like ``@param[out]``
. replace ( "[out]" , "" )
. replace ( "[in]" , "" )
// Trim start of the Rustdoc: ``...= " ...`` -> ``...= "...``
. replace ( "= \" " , "= \"" )
// Double pass because _most_ annotations are at the start
. replace ( "= \" " , "= \"" )
} else {
String ::from ( v )
}
} )
. map ( | v | v + "\n" )
. collect ::< String > ( ) ;
let old_bindings_path = bindings_path . to_str ( ) . unwrap ( ) . to_owned ( ) + ".old" ;
let old_bindings_path = bindings_path . to_str ( ) . unwrap ( ) . to_owned ( ) + ".old" ;