Added some minimal documentation and a helper script.

This commit is contained in:
Ada Werefox 2023-04-02 15:14:57 -05:00
parent c029cd0d08
commit cd13cbbc1e
5 changed files with 41 additions and 0 deletions

View File

@ -15,3 +15,4 @@ members = [
[dependencies] [dependencies]
rust-letter-be = { path = "./rust-letter-be" } rust-letter-be = { path = "./rust-letter-be" }
rocket = "=0.5.0-rc.3" rocket = "=0.5.0-rc.3"
tokio = "1.27.0"

24
helper.sh Executable file
View File

@ -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

View File

@ -1,7 +1,12 @@
//! # Rust Letter Backend
//!
//! `rust_letter_be` handles the backend execution using Rocket.
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
/// A module that handles the backend for the site.
pub mod web_app_backend { pub mod web_app_backend {
use rocket::fs::FileServer; 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<Build> { pub async fn build_rocket() -> Rocket<Build> {
rocket::build() rocket::build()
.mount("/images", FileServer::from("public/images")) .mount("/images", FileServer::from("public/images"))

View File

@ -1,9 +1,16 @@
//! # Rust Letter Frontend
//!
//! Rendering functions for the site using [Dioxus](https://dioxuslabs.com/).
#![allow(non_snake_case)] #![allow(non_snake_case)]
/// A module that handles the functions needed
/// to render the site.
pub mod web_app { pub mod web_app {
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types // import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
pub use dioxus::prelude::*; pub use dioxus::prelude::*;
/// Renders the app and returns the rendered Element.
pub fn App(cx: Scope) -> Element { pub fn App(cx: Scope) -> Element {
cx.render(rsx!( cx.render(rsx!(
div { div {

View File

@ -1,4 +1,7 @@
use rust_letter_fe::web_app; use rust_letter_fe::web_app;
use dioxus_web;
use console_error_panic_hook;
use wasm_logger;
fn main() { fn main() {
// init debug tool for WebAssembly // init debug tool for WebAssembly