Skip to content

Commit

Permalink
Adjust documentation width
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Oct 17, 2022
1 parent fe9c5af commit 25ff2d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
35 changes: 13 additions & 22 deletions boa_engine/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ pub struct JsNativeError {
}

impl JsNativeError {
/// Creates a new `JsNativeError` from its `kind`, `message` and (optionally)
/// its `cause`.
/// Creates a new `JsNativeError` from its `kind`, `message` and (optionally) its `cause`.
fn new(kind: JsNativeErrorKind, message: Box<str>, cause: Option<Box<JsError>>) -> Self {
Self {
kind,
Expand All @@ -385,8 +384,8 @@ impl JsNativeError {
}
}

/// Creates a new `JsNativeError` of kind `AggregateError` from
/// a list of [`JsError`]s, with empty `message` and undefined `cause`.
/// Creates a new `JsNativeError` of kind `AggregateError` from a list of [`JsError`]s, with
/// empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -407,8 +406,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Aggregate(errors), Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `Error`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `Error`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -422,8 +420,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Error, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `EvalError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `EvalError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -437,8 +434,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Eval, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `RangeError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `RangeError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -452,8 +448,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Range, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `ReferenceError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `ReferenceError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -467,8 +462,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Reference, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `SyntaxError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `SyntaxError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -482,8 +476,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Syntax, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `TypeError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `TypeError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand All @@ -497,8 +490,7 @@ impl JsNativeError {
Self::new(JsNativeErrorKind::Type, Box::default(), None)
}

/// Creates a new `JsNativeError` of kind `UriError`, with empty `message`
/// and undefined `cause`.
/// Creates a new `JsNativeError` of kind `UriError`, with empty `message` and undefined `cause`.
///
/// # Examples
///
Expand Down Expand Up @@ -590,8 +582,7 @@ impl JsNativeError {
self.cause.as_deref()
}

/// Converts this native error to its opaque representation as a
/// [`JsObject`].
/// Converts this native error to its opaque representation as a [`JsObject`].
///
/// # Examples
///
Expand Down Expand Up @@ -745,8 +736,8 @@ pub enum JsNativeErrorKind {
/// [spec]: https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
Type,
/// An error thrown when the [`encodeURI()`][e_uri] and [`decodeURI()`][d_uri]
/// functions receive invalid parameters.
/// An error thrown when the [`encodeURI()`][e_uri] and [`decodeURI()`][d_uri] functions receive
/// invalid parameters.
///
/// More information:
/// - [ECMAScript reference][spec]
Expand Down
17 changes: 8 additions & 9 deletions boa_engine/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use self::common::{COMMON_STRINGS, COMMON_STRINGS_CACHE, MAX_COMMON_STRING_LENGT
///
///
/// You can create a `JsString` from a string literal, which completely skips the runtime
/// conversion from [`&str`] to [`&\[u16\]`]:
/// conversion from [`&str`] to <code>[&\[u16\]][slice]</code>:
///
/// ```
/// # use boa_engine::js_string;
Expand Down Expand Up @@ -255,7 +255,7 @@ impl TaggedJsString {
}

/// Enum representing either a reference to a heap allocated [`RawJsString`] or a static reference to
/// a [`\[u16\]`][std::slice] inside [`COMMON_STRINGS`].
/// a [`\[u16\]`][slice] inside [`COMMON_STRINGS`].
enum JsStringPtrKind<'a> {
// A string allocated on the heap.
Heap(&'a mut RawJsString),
Expand All @@ -265,17 +265,17 @@ enum JsStringPtrKind<'a> {

/// A UTF-16–encoded, reference counted, immutable string.
///
/// This is pretty similar to a <code>[Rc][std::rc::Rc]\<[\[u16\]][std::slice]\></code>, but without
/// the length metadata associated with the [`Rc`][std::rc::Rc] fat pointer. Instead, the length of
/// This is pretty similar to a <code>[Rc][std::rc::Rc]\<[\[u16\]][slice]\></code>, but without
/// the length metadata associated with the `Rc` fat pointer. Instead, the length of
/// every string is stored on the heap, along with its reference counter and its data.
///
/// We define some commonly used string constants in an interner. For these strings, we don't allocate
/// memory on the heap to reduce the overhead of memory allocation and reference counting.
///
/// # Deref
///
/// [`JsString`] implements <code>[Deref]<Target = [\[u16\]][std::slice]></code>, inheriting all of
/// [`\[u16\]`][std::slice]'s methods.
/// [`JsString`] implements <code>[Deref]<Target = \[u16\]></code>, inheriting all of
/// <code>\[u16\]</code>'s methods.
#[derive(Finalize)]
pub struct JsString {
ptr: TaggedJsString,
Expand All @@ -287,7 +287,7 @@ unsafe impl Trace for JsString {
}

impl JsString {
/// Obtains the underlying [`&[u16]`][std::slice] slice of a [`JsString`]
/// Obtains the underlying [`&[u16]`][slice] slice of a [`JsString`]
pub fn as_slice(&self) -> &[u16] {
self
}
Expand Down Expand Up @@ -874,8 +874,7 @@ impl Utf16Trim for [u16] {
}
}

/// Utility trait that adds a `UTF-16` escaped representation to every
/// [`[u16]`][std::slice].
/// Utility trait that adds a `UTF-16` escaped representation to every [`[u16]`][slice].
pub(crate) trait ToStringEscaped {
/// Decodes `self` as an `UTF-16` encoded string, escaping any unpaired surrogates by its
/// codepoint value.
Expand Down

0 comments on commit 25ff2d6

Please sign in to comment.