Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed May 18, 2023
1 parent f570cc8 commit 2499ec6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion boa_engine/src/context/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
/// ```
///
Expand Down
14 changes: 7 additions & 7 deletions boa_engine/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ 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)
/// .property("x", 12, Attribute::READONLY)
/// .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))
/// ```
Expand Down
3 changes: 2 additions & 1 deletion boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
//! "{}",
Expand Down Expand Up @@ -173,6 +173,7 @@ pub use crate::{
module::Module,
native_function::NativeFunction,
object::JsObject,
script::Script,
string::JsString,
symbol::JsSymbol,
value::JsValue,
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/object/builtins/jspromise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl JsPromise {
/// # fn main() -> Result<(), Box<dyn Error>> {
/// 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)?;
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/script.rs
Original file line number Diff line number Diff line change
@@ -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].
//!
Expand Down
2 changes: 1 addition & 1 deletion boa_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
//! "{}",
Expand Down

0 comments on commit 2499ec6

Please sign in to comment.