From cd13cbbc1ead4876e434bd2f74c860f6da7cf33e Mon Sep 17 00:00:00 2001 From: Ada Werefox Date: Sun, 2 Apr 2023 15:14:57 -0500 Subject: [PATCH] Added some minimal documentation and a helper script. --- Cargo.toml | 1 + helper.sh | 24 ++++++++++++++++++++++++ rust-letter-be/src/lib.rs | 6 ++++++ rust-letter-fe/src/lib.rs | 7 +++++++ rust-letter-fe/src/main.rs | 3 +++ 5 files changed, 41 insertions(+) create mode 100755 helper.sh diff --git a/Cargo.toml b/Cargo.toml index 4192793..24d0cb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ members = [ [dependencies] rust-letter-be = { path = "./rust-letter-be" } rocket = "=0.5.0-rc.3" +tokio = "1.27.0" diff --git a/helper.sh b/helper.sh new file mode 100755 index 0000000..032fd47 --- /dev/null +++ b/helper.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -xe + +ARG=$1 +OPTION=$2 + +if [ $ARG = "doc" ]; then + if [ $OPTION = "fe" ]; then + cargo doc --no-deps --target wasm32-unknown-unknown -p rust-letter-fe --open + elif [ $OPTION = "be" ]; then + cargo doc --no-deps -p rust-letter-be --open + else + cargo doc --no-deps --open --workspace + fi +elif [ $ARG = "test" ]; then + if [ $OPTION = "fe" ]; then + cargo test --target wasm32-unknown-unknown -p rust-letter-fe --doc + elif [ $OPTION = "be" ]; then + cargo test -p rust-letter-be --doc + else + cargo test --workspace --doc + fi +fi diff --git a/rust-letter-be/src/lib.rs b/rust-letter-be/src/lib.rs index ef8e9e8..66f0fa7 100644 --- a/rust-letter-be/src/lib.rs +++ b/rust-letter-be/src/lib.rs @@ -1,7 +1,12 @@ +//! # Rust Letter Backend +//! +//! `rust_letter_be` handles the backend execution using Rocket. + #[macro_use] extern crate rocket; +/// A module that handles the backend for the site. pub mod web_app_backend { use rocket::fs::FileServer; @@ -24,6 +29,7 @@ pub mod web_app_backend { ) } + /// This runs `rocket::build()` with the needed mounts and routes. pub async fn build_rocket() -> Rocket { rocket::build() .mount("/images", FileServer::from("public/images")) diff --git a/rust-letter-fe/src/lib.rs b/rust-letter-fe/src/lib.rs index d6d5f95..64fbeaf 100644 --- a/rust-letter-fe/src/lib.rs +++ b/rust-letter-fe/src/lib.rs @@ -1,9 +1,16 @@ +//! # Rust Letter Frontend +//! +//! Rendering functions for the site using [Dioxus](https://dioxuslabs.com/). + #![allow(non_snake_case)] +/// A module that handles the functions needed +/// to render the site. pub mod web_app { // import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types pub use dioxus::prelude::*; + /// Renders the app and returns the rendered Element. pub fn App(cx: Scope) -> Element { cx.render(rsx!( div { diff --git a/rust-letter-fe/src/main.rs b/rust-letter-fe/src/main.rs index f972957..2732e01 100644 --- a/rust-letter-fe/src/main.rs +++ b/rust-letter-fe/src/main.rs @@ -1,4 +1,7 @@ use rust_letter_fe::web_app; +use dioxus_web; +use console_error_panic_hook; +use wasm_logger; fn main() { // init debug tool for WebAssembly