From 6ebe002b1808a6f0e9c957bd5d59d60145dc2a29 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 5 Jun 2022 18:17:44 +0800 Subject: [PATCH] Check for missing docs. --- Cargo.toml | 2 +- src/eval/debugger.rs | 42 +++++++++++++++++++++++++++++------------- src/func/func.rs | 1 + src/func/plugin.rs | 1 + src/lib.rs | 1 + src/packages/mod.rs | 1 + src/tokenizer.rs | 7 ++++--- tests/plugins.rs | 2 -- 8 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c710ef4..c96d19a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ ahash = { version = "0.7", default-features = false } num-traits = { version = "0.2", default-features = false } bitflags = { version = "1", default-features = false } smartstring = { version = "1", default-features = false } -rhai_codegen = { version = "1.4", path = "codegen", default-features = false } +rhai_codegen = { version = "1.4.1", path = "codegen", default-features = false } no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true } libm = { version = "0.2", default-features = false, optional = true } diff --git a/src/eval/debugger.rs b/src/eval/debugger.rs index 11b52bf8..617b1db4 100644 --- a/src/eval/debugger.rs +++ b/src/eval/debugger.rs @@ -34,15 +34,15 @@ pub type OnDebuggerCallback = dyn Fn(EvalContext, DebuggerEvent, ASTNode, Option #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[non_exhaustive] pub enum DebuggerCommand { - // Continue normal execution. + /// Continue normal execution. Continue, - // Step into the next expression, diving into functions. + /// Step into the next expression, diving into functions. StepInto, - // Run to the next expression or statement, stepping over functions. + /// Run to the next expression or statement, stepping over functions. StepOver, - // Run to the next statement, skipping over functions. + /// Run to the next statement, skipping over functions. Next, - // Run to the end of the current function call. + /// Run to the end of the current function call. FunctionExit, } @@ -78,17 +78,17 @@ impl DebuggerStatus { #[derive(Debug, Clone, Copy)] #[non_exhaustive] pub enum DebuggerEvent<'a> { - // Script evaluation starts. + /// Script evaluation starts. Start, - // Break on next step. + /// Break on next step. Step, - // Break on break-point. + /// Break on break-point. BreakPoint(usize), - // Return from a function with a value. + /// Return from a function with a value. FunctionExitWithValue(&'a Dynamic), - // Return from a function with a value. + /// Return from a function with a value. FunctionExitWithError(&'a EvalAltResult), - // Script evaluation ends. + /// Script evaluation ends. End, } @@ -103,23 +103,39 @@ pub enum BreakPoint { /// Source is empty if not available. #[cfg(not(feature = "no_position"))] AtPosition { + /// Source (empty if not available) of the break-point. source: Identifier, + /// [Position] of the break-point. pos: Position, + /// Is the break-point enabled? enabled: bool, }, /// Break at a particular function call. - AtFunctionName { name: Identifier, enabled: bool }, + AtFunctionName { + /// Function name. + name: Identifier, + /// Is the break-point enabled? + enabled: bool, + }, /// Break at a particular function call with a particular number of arguments. AtFunctionCall { + /// Function name. name: Identifier, + /// Number of arguments. args: usize, + /// Is the break-point enabled? enabled: bool, }, /// Break at a particular property . /// /// Not available under `no_object`. #[cfg(not(feature = "no_object"))] - AtProperty { name: Identifier, enabled: bool }, + AtProperty { + /// Property name. + name: Identifier, + /// Is the break-point enabled? + enabled: bool, + }, } impl fmt::Display for BreakPoint { diff --git a/src/func/func.rs b/src/func/func.rs index 65636fbd..f74873c1 100644 --- a/src/func/func.rs +++ b/src/func/func.rs @@ -13,6 +13,7 @@ use std::prelude::v1::*; /// /// Not available under `no_function`. pub trait Func { + /// The closure's output type. type Output; /// Create a Rust closure from an [`AST`]. diff --git a/src/func/plugin.rs b/src/func/plugin.rs index dc20e6f3..7c4f84fe 100644 --- a/src/func/plugin.rs +++ b/src/func/plugin.rs @@ -10,6 +10,7 @@ pub use crate::{ use std::prelude::v1::*; pub use std::{any::TypeId, mem}; +/// Result of a Rhai function. pub type RhaiResult = crate::RhaiResult; #[cfg(not(features = "no_module"))] diff --git a/src/lib.rs b/src/lib.rs index f4a7bfff..8cd8b472 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,7 @@ //! See [The Rhai Book](https://rhai.rs/book) for details on the Rhai scripting engine and language. #![cfg_attr(feature = "no_std", no_std)] +#![deny(missing_docs)] #[cfg(feature = "no_std")] extern crate alloc; diff --git a/src/packages/mod.rs b/src/packages/mod.rs index 046b9cde..a4d4d612 100644 --- a/src/packages/mod.rs +++ b/src/packages/mod.rs @@ -97,6 +97,7 @@ macro_rules! def_package { } impl $package { + #[doc=concat!("Create a new `", stringify!($package), "`")] pub fn new() -> Self { let mut module = $crate::Module::new(); ::init(&mut module); diff --git a/src/tokenizer.rs b/src/tokenizer.rs index ab771a0f..f75269f6 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -292,6 +292,7 @@ pub struct Span { } impl Span { + /// Empty [`Span`]. pub const NONE: Self = Self::new(Position::NONE, Position::NONE); /// Create a new [`Span`]. @@ -862,15 +863,15 @@ impl Token { }) } - // Is this token [`EOF`][Token::EOF]? + /// Is this token [`EOF`][Token::EOF]? #[inline(always)] #[must_use] pub const fn is_eof(&self) -> bool { matches!(self, Self::EOF) } - // If another operator is after these, it's probably an unary operator - // (not sure about `fn` name). + /// If another operator is after these, it's probably a unary operator + /// (not sure about `fn` name). #[must_use] pub const fn is_next_unary(&self) -> bool { use Token::*; diff --git a/tests/plugins.rs b/tests/plugins.rs index 5327595c..85833a54 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -121,8 +121,6 @@ fn test_plugins_package() -> Result<(), Box> { fn test_plugins_parameters() -> Result<(), Box> { #[export_module] mod rhai_std { - use rhai::*; - pub fn noop(_: &str) {} }