Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improve bindings.rs documentation #75

Merged
merged 8 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["ctru-rs", "ctru-sys"]
members = ["ctru-rs", "ctru-sys", "ctru-sys/docstring-to-rustdoc"]

[patch.'https://github.com/Meziu/ctru-rs']
# Make sure all dependencies use the local ctru-sys package
Expand Down
4 changes: 3 additions & 1 deletion ctru-sys/bindgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ bindgen "$DEVKITPRO/libctru/include/3ds.h" \
-D__3DS__ \
> src/bindings.rs

cargo run --bin docstring-to-rustdoc -- src/bindings.rs
cargo run --package docstring-to-rustdoc -- src/bindings.rs

cargo fmt --all
7 changes: 7 additions & 0 deletions ctru-sys/docstring-to-rustdoc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "docstring-to-rustdoc"
version = "0.1.0"
edition = "2021"

[dependencies]
doxygen-rs = { git = "https://github.com/Techie-Pi/doxygen-rs.git", version = "0.2.2", rev = "573f483ad63ab4662650961998d3ed093a703983" }
31 changes: 31 additions & 0 deletions ctru-sys/docstring-to-rustdoc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! This script transforms _some_ Boxygen comments to Rustdoc format
//!
//! # Usage
//!
//! `cargo run --package docstring-to-rustdoc -- [location of the bindings.rs]`
//! Example: `cargo run --package docstring-to-rustdoc -- src/bindings.rs`
//!
//! # Transformations
//!
//! Check [doxygen-rs docs](https://techie-pi.github.io/doxygen-rs/doxygen_rs/)

use std::path::Path;
use std::{env, fs, io};

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"));
let bindings = fs::read_to_string(bindings_path)?;

let parsed = doxygen_rs::transform_bindgen(bindings.as_str());

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(())
}
67 changes: 0 additions & 67 deletions ctru-sys/src/bin/docstring-to-rustdoc.rs

This file was deleted.

Loading