You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
983 B
32 lines
983 B
2 years ago
|
//! This script transforms _some_ Boxygen comments to Rustdoc format
|
||
|
//!
|
||
|
//! # Usage
|
||
|
//!
|
||
2 years ago
|
//! `cargo docstring-to-rustdoc [location of the bindings.rs]`
|
||
|
//! Example: `cargo docstring-to-rustdoc src/bindings.rs`
|
||
2 years ago
|
//!
|
||
|
//! # Transformations
|
||
|
//!
|
||
2 years ago
|
//! Check [doxygen-rs docs](https://techie-pi.github.io/doxygen-rs/doxygen_rs/)
|
||
2 years ago
|
|
||
2 years ago
|
use std::path::Path;
|
||
2 years ago
|
use std::{env, fs, io};
|
||
2 years ago
|
|
||
|
fn main() -> io::Result<()> {
|
||
|
let args: Vec<String> = env::args().collect();
|
||
|
|
||
|
let bindings_path = Path::new(args.get(1).expect("bindings.rs not provided in the args"));
|
||
2 years ago
|
let bindings = fs::read_to_string(bindings_path)?;
|
||
2 years ago
|
|
||
2 years ago
|
let parsed = doxygen_rs::transform_bindgen(bindings.as_str());
|
||
2 years ago
|
|
||
|
let old_bindings_path = bindings_path.to_str().unwrap().to_owned() + ".old";
|
||
|
|
||
|
// If something fails, the original bindings are available at ``bindings.rs.old``
|
||
|
fs::rename(bindings_path, &old_bindings_path)?;
|
||
|
fs::write(bindings_path, parsed)?;
|
||
|
fs::remove_file(&old_bindings_path)?;
|
||
|
|
||
|
Ok(())
|
||
2 years ago
|
}
|