From 2499ec6ea4b24729ac488c46888c0fe723502319 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Wed, 17 May 2023 19:43:58 -0600 Subject: [PATCH] Fix docs --- boa_engine/src/context/hooks.rs | 2 +- boa_engine/src/context/mod.rs | 14 +++++++------- boa_engine/src/lib.rs | 3 ++- boa_engine/src/object/builtins/jspromise.rs | 2 +- boa_engine/src/script.rs | 2 +- boa_runtime/src/lib.rs | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/boa_engine/src/context/hooks.rs b/boa_engine/src/context/hooks.rs index 34024854dee..e6cd49c6bed 100644 --- a/boa_engine/src/context/hooks.rs +++ b/boa_engine/src/context/hooks.rs @@ -41,7 +41,7 @@ use super::intrinsics::Intrinsics; /// } /// let hooks: &dyn HostHooks = &Hooks; // Can have additional state. /// let context = &mut ContextBuilder::new().host_hooks(hooks).build().unwrap(); -/// let result = context.eval_script(Source::from_bytes(r#"eval("let a = 5")"#)); +/// let result = context.eval(Source::from_bytes(r#"eval("let a = 5")"#)); /// assert_eq!(result.unwrap_err().to_string(), "TypeError: eval calls not available"); /// ``` /// diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 59309289e4a..f80b95f7a7e 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -55,18 +55,18 @@ use crate::vm::RuntimeLimits; /// }; /// /// let script = r#" -/// function test(arg1) { -/// if(arg1 != null) { -/// return arg1.x; +/// function test(arg1) { +/// if(arg1 != null) { +/// return arg1.x; +/// } +/// return 112233; /// } -/// return 112233; -/// } /// "#; /// /// let mut context = Context::default(); /// /// // Populate the script definition to the context. -/// context.eval_script(Source::from_bytes(script)).unwrap(); +/// context.eval(Source::from_bytes(script)).unwrap(); /// /// // Create an object that can be used in eval calls. /// let arg = ObjectInitializer::new(&mut context) @@ -74,7 +74,7 @@ use crate::vm::RuntimeLimits; /// .build(); /// context.register_global_property("arg", arg, Attribute::all()); /// -/// let value = context.eval_script(Source::from_bytes("test(arg)")).unwrap(); +/// let value = context.eval(Source::from_bytes("test(arg)")).unwrap(); /// /// assert_eq!(value.as_number(), Some(12.0)) /// ``` diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index be02395c3b8..86feef67b7e 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -22,7 +22,7 @@ //! let mut context = Context::default(); //! //! // Parse the source code -//! match context.eval_script(Source::from_bytes(js_code)) { +//! match context.eval(Source::from_bytes(js_code)) { //! Ok(res) => { //! println!( //! "{}", @@ -173,6 +173,7 @@ pub use crate::{ module::Module, native_function::NativeFunction, object::JsObject, + script::Script, string::JsString, symbol::JsSymbol, value::JsValue, diff --git a/boa_engine/src/object/builtins/jspromise.rs b/boa_engine/src/object/builtins/jspromise.rs index 6159b755719..3882de9f907 100644 --- a/boa_engine/src/object/builtins/jspromise.rs +++ b/boa_engine/src/object/builtins/jspromise.rs @@ -229,7 +229,7 @@ impl JsPromise { /// # fn main() -> Result<(), Box> { /// let context = &mut Context::default(); /// - /// let promise = context.eval_script(Source::from_bytes("new Promise((resolve, reject) => resolve())"))?; + /// let promise = context.eval(Source::from_bytes("new Promise((resolve, reject) => resolve())"))?; /// let promise = promise.as_object().cloned().unwrap(); /// /// let promise = JsPromise::from_object(promise)?; diff --git a/boa_engine/src/script.rs b/boa_engine/src/script.rs index 3f9207e270e..a3974d91c1f 100644 --- a/boa_engine/src/script.rs +++ b/boa_engine/src/script.rs @@ -1,4 +1,4 @@ -//! Boa's implementation of Ecmascript's Scripts. +//! Boa's implementation of ECMAScript's Scripts. //! //! This module contains the [`Script`] type, which represents a [**Script Record**][script]. //! diff --git a/boa_runtime/src/lib.rs b/boa_runtime/src/lib.rs index ab8a9d3edda..7c9caacf09c 100644 --- a/boa_runtime/src/lib.rs +++ b/boa_runtime/src/lib.rs @@ -24,7 +24,7 @@ //! let js_code = "console.log('Hello World from a JS code string!')"; //! //! // Parse the source code -//! match context.eval_script(Source::from_bytes(js_code)) { +//! match context.eval(Source::from_bytes(js_code)) { //! Ok(res) => { //! println!( //! "{}",