From d77c242d8b4541f575abb970fcf14c8545ce788c Mon Sep 17 00:00:00 2001 From: Doonv <58695417+doonv@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:04:08 +0200 Subject: [PATCH] Add more documentation --- Cargo.lock | 37 ------------------------------------ Cargo.toml | 5 ++--- src/builtin_parser/number.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e0316c..9d5686a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,7 +536,6 @@ dependencies = [ "bevy_egui", "chrono", "console_error_panic_hook", - "kinded", "logos", "tracing-log 0.2.0", "tracing-subscriber", @@ -1423,15 +1422,6 @@ dependencies = [ "const_soft_float", ] -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -2323,27 +2313,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "kinded" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce4bdbb2f423660b19f0e9f7115182214732d8dd5f840cd0a3aee3e22562f34c" -dependencies = [ - "kinded_macros", -] - -[[package]] -name = "kinded_macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13b4ddc5dcb32f45dac3d6f606da2a52fdb9964a18427e63cd5ef6c0d13288d" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "syn 2.0.41", -] - [[package]] name = "ktx2" version = "0.3.0" @@ -3617,12 +3586,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "unicode-width" version = "0.1.11" diff --git a/Cargo.toml b/Cargo.toml index 56f5aea..c252ff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [features] default = ["builtin-parser"] -builtin-parser = ["dep:logos", "dep:kinded"] +builtin-parser = ["dep:logos"] [dependencies] bevy = "0.12.1" @@ -18,9 +18,8 @@ tracing-log = "0.2.0" tracing-subscriber = "0.3.18" web-time = "0.2.4" -# built-in parser +# builtin-parser feature logos = { version = "0.13.0", optional = true } -kinded = { version = "0.3.0", optional = true } [target.'cfg(target_os = "android")'.dependencies] android_log-sys = "0.3.0" diff --git a/src/builtin_parser/number.rs b/src/builtin_parser/number.rs index 4b32d30..e17334d 100644 --- a/src/builtin_parser/number.rs +++ b/src/builtin_parser/number.rs @@ -1,5 +1,3 @@ -#![allow(non_camel_case_types)] - use std::fmt::Display; use std::ops::*; @@ -8,12 +6,13 @@ use logos::Span; use super::{RunError, SpanExtension, Spanned}; -/// An enum for containing any type of number. +/// An enum that contains any type of number. /// /// The [`Integer`](Number::Integer) and [`Float`](Number::Float) types /// are generic types that then get downcasted when they first interact /// with a concrete type. (i.e. calling a function, etc) #[derive(Debug, Clone, Copy)] +#[allow(missing_docs, non_camel_case_types)] pub enum Number { /// Generic integer that can get downcasted. Integer(i128), @@ -33,6 +32,7 @@ pub enum Number { } impl Number { + /// Converts this into a [`Box`](Reflect). pub fn reflect(self) -> Box { match self { Number::u8(number) => Box::new(number), @@ -50,6 +50,7 @@ impl Number { } } + /// Returns a [`&'static str`](str) represents the kind of the number. pub fn kind(&self) -> &'static str { match self { Number::Float(_) => "(float)", @@ -90,6 +91,7 @@ impl Display for Number { macro_rules! impl_op { ($fn:ident, $op:tt) => { impl Number { + #[doc = concat!("Performs the `", stringify!($op), "` calculation.")] pub fn $fn(left: Number, right: Number, span: Span) -> Result { match (left, right) { (Number::u8(left), Number::u8(right)) => Ok(Number::u8(left $op right)), @@ -162,6 +164,7 @@ impl_op_spanned!(Mul, mul); impl_op_spanned!(Rem, rem); impl Number { + /// Performs the unary `-` operation. pub fn neg(self, span: Span) -> Result { match self { Number::u8(_) => Err(RunError::CannotNegateUnsignedInteger(Spanned {