rustdoc: Fix many rustdoc errors (#31147)

This fixes many rustdoc errors that occur due to raw URLs in rustdoc
comments as well as unescaped Rust code that should be in backticks.
This commit is contained in:
Martin Robinson 2024-01-22 14:13:48 +01:00 committed by GitHub
parent d7de206dbd
commit 5c1723c983
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
185 changed files with 939 additions and 942 deletions

View file

@ -224,8 +224,9 @@ where
/// A rooting mechanism for reflectors on the stack.
/// LIFO is not required.
///
/// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*]
/// (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting).
/// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*][cstack].
///
/// [cstack]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting
pub struct RootCollection {
roots: UnsafeCell<Vec<*const dyn JSTraceable>>,
}
@ -340,7 +341,7 @@ impl<T> Dom<T> {
}
impl<T: DomObject> Dom<T> {
/// Create a Dom<T> from a &T
/// Create a `Dom<T>` from a `&T`
#[allow(crown::unrooted_must_root)]
pub fn from_ref(obj: &T) -> Dom<T> {
assert_in_script();
@ -758,7 +759,7 @@ where
self.value
}
/// Transforms a slice of Dom<T> into a slice of LayoutDom<T>.
/// Transforms a slice of `Dom<T>` into a slice of `LayoutDom<T>`.
// FIXME(nox): This should probably be done through a ToLayout trait.
pub unsafe fn to_layout_slice(slice: &'dom [Dom<T>]) -> &'dom [LayoutDom<'dom, T>] {
// This doesn't compile if Dom and LayoutDom don't have the same

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Trait representing the concept of [serializable objects]
//! (https://html.spec.whatwg.org/multipage/#serializable-objects).
//! (<https://html.spec.whatwg.org/multipage/#serializable-objects>).
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::structuredclone::StructuredDataHolder;

View file

@ -316,12 +316,12 @@ impl DOMString {
/// A valid date string should be "YYYY-MM-DD"
/// YYYY must be four or more digits, MM and DD both must be two digits
/// https://html.spec.whatwg.org/multipage/#valid-date-string
/// <https://html.spec.whatwg.org/multipage/#valid-date-string>
pub fn is_valid_date_string(&self) -> bool {
self.parse_date_string().is_ok()
}
/// https://html.spec.whatwg.org/multipage/#parse-a-date-string
/// <https://html.spec.whatwg.org/multipage/#parse-a-date-string>
pub fn parse_date_string(&self) -> Result<(i32, u32, u32), ()> {
let value = &self.0;
// Step 1, 2, 3
@ -336,7 +336,7 @@ impl DOMString {
Ok((year_int, month_int, day_int))
}
/// https://html.spec.whatwg.org/multipage/#parse-a-time-string
/// <https://html.spec.whatwg.org/multipage/#parse-a-time-string>
pub fn parse_time_string(&self) -> Result<(u32, u32, f64), ()> {
let value = &self.0;
// Step 1, 2, 3
@ -353,12 +353,12 @@ impl DOMString {
/// A valid month string should be "YYYY-MM"
/// YYYY must be four or more digits, MM both must be two digits
/// https://html.spec.whatwg.org/multipage/#valid-month-string
/// <https://html.spec.whatwg.org/multipage/#valid-month-string>
pub fn is_valid_month_string(&self) -> bool {
self.parse_month_string().is_ok()
}
/// https://html.spec.whatwg.org/multipage/#parse-a-month-string
/// <https://html.spec.whatwg.org/multipage/#parse-a-month-string>
pub fn parse_month_string(&self) -> Result<(i32, u32), ()> {
let value = &self;
// Step 1, 2, 3
@ -374,12 +374,12 @@ impl DOMString {
/// A valid week string should be like {YYYY}-W{WW}, such as "2017-W52"
/// YYYY must be four or more digits, WW both must be two digits
/// https://html.spec.whatwg.org/multipage/#valid-week-string
/// <https://html.spec.whatwg.org/multipage/#valid-week-string>
pub fn is_valid_week_string(&self) -> bool {
self.parse_week_string().is_ok()
}
/// https://html.spec.whatwg.org/multipage/#parse-a-week-string
/// <https://html.spec.whatwg.org/multipage/#parse-a-week-string>
pub fn parse_week_string(&self) -> Result<(i32, u32), ()> {
let value = &self.0;
// Step 1, 2, 3
@ -422,7 +422,7 @@ impl DOMString {
Ok((year_int, week_int))
}
/// https://html.spec.whatwg.org/multipage/#valid-floating-point-number
/// <https://html.spec.whatwg.org/multipage/#valid-floating-point-number>
pub fn is_valid_floating_point_number_string(&self) -> bool {
lazy_static! {
static ref RE: Regex =
@ -431,7 +431,7 @@ impl DOMString {
RE.is_match(&self.0) && self.parse_floating_point_number().is_ok()
}
/// https://html.spec.whatwg.org/multipage/#rules-for-parsing-floating-point-number-values
/// <https://html.spec.whatwg.org/multipage/#rules-for-parsing-floating-point-number-values>
pub fn parse_floating_point_number(&self) -> Result<f64, ()> {
// Steps 15-16 are telling us things about IEEE rounding modes
// for floating-point significands; this code assumes the Rust
@ -456,7 +456,7 @@ impl DOMString {
}
}
/// https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number
/// <https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number>
pub fn set_best_representation_of_the_floating_point_number(&mut self) {
if let Ok(val) = self.parse_floating_point_number() {
self.0 = val.to_string();
@ -465,7 +465,7 @@ impl DOMString {
/// A valid normalized local date and time string should be "{date}T{time}"
/// where date and time are both valid, and the time string must be as short as possible
/// https://html.spec.whatwg.org/multipage/#valid-normalised-local-date-and-time-string
/// <https://html.spec.whatwg.org/multipage/#valid-normalised-local-date-and-time-string>
pub fn convert_valid_normalized_local_date_and_time_string(&mut self) -> Result<(), ()> {
let ((year, month, day), (hour, minute, second)) =
self.parse_local_date_and_time_string()?;
@ -491,7 +491,7 @@ impl DOMString {
Ok(())
}
/// https://html.spec.whatwg.org/multipage/#parse-a-local-date-and-time-string
/// <https://html.spec.whatwg.org/multipage/#parse-a-local-date-and-time-string>
pub fn parse_local_date_and_time_string(
&self,
) -> Result<((i32, u32, u32), (u32, u32, f64)), ()> {
@ -520,7 +520,7 @@ impl DOMString {
Ok((date_tuple, time_tuple))
}
/// https://html.spec.whatwg.org/multipage/#valid-e-mail-address
/// <https://html.spec.whatwg.org/multipage/#valid-e-mail-address>
pub fn is_valid_email_address_string(&self) -> bool {
lazy_static! {
static ref RE: Regex = Regex::new(concat!(
@ -532,7 +532,7 @@ impl DOMString {
RE.is_match(&self.0)
}
/// https://html.spec.whatwg.org/multipage/#valid-simple-colour
/// <https://html.spec.whatwg.org/multipage/#valid-simple-colour>
pub fn is_valid_simple_color_string(&self) -> bool {
let mut chars = self.0.chars();
if self.0.len() == 7 && chars.next() == Some('#') {
@ -669,7 +669,7 @@ impl Extend<char> for DOMString {
}
}
/// https://html.spec.whatwg.org/multipage/#parse-a-month-component
/// <https://html.spec.whatwg.org/multipage/#parse-a-month-component>
fn parse_month_component(value: &str) -> Result<(i32, u32), ()> {
// Step 3
let mut iterator = value.split('-');
@ -692,7 +692,7 @@ fn parse_month_component(value: &str) -> Result<(i32, u32), ()> {
Ok((year_int, month_int))
}
/// https://html.spec.whatwg.org/multipage/#parse-a-date-component
/// <https://html.spec.whatwg.org/multipage/#parse-a-date-component>
fn parse_date_component(value: &str) -> Result<(i32, u32, u32), ()> {
// Step 1
let (year_int, month_int) = parse_month_component(value)?;
@ -714,7 +714,7 @@ fn parse_date_component(value: &str) -> Result<(i32, u32, u32), ()> {
Ok((year_int, month_int, day_int))
}
/// https://html.spec.whatwg.org/multipage/#parse-a-time-component
/// <https://html.spec.whatwg.org/multipage/#parse-a-time-component>
fn parse_time_component(value: &str) -> Result<(u32, u32, f64), ()> {
// Step 1
let mut iterator = value.split(':');
@ -781,7 +781,7 @@ fn max_day_in_month(year_num: i32, month_num: u32) -> Result<u32, ()> {
}
}
/// https://html.spec.whatwg.org/multipage/#week-number-of-the-last-day
/// <https://html.spec.whatwg.org/multipage/#week-number-of-the-last-day>
fn max_week_in_year(year: i32) -> u32 {
Utc.with_ymd_and_hms(year as i32, 1, 1, 0, 0, 0)
.earliest()

View file

@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! This module implements structured cloning, as defined by [HTML]
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
//! This module implements structured cloning, as defined by [HTML](https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
use std::collections::HashMap;
use std::os::raw;
@ -253,7 +252,7 @@ static STRUCTURED_CLONE_CALLBACKS: JSStructuredCloneCallbacks = JSStructuredClon
};
/// A data holder for results from, and inputs to, structured-data read/write operations.
/// https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data
/// <https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data>
pub enum StructuredDataHolder {
Read {
/// A map of deserialized blobs, stored temporarily here to keep them rooted.

View file

@ -579,7 +579,7 @@ impl<'a, T: 'static + JSTraceable> RootedVec<'a, T> {
}
impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, Dom<T>> {
/// Create a vector of items of type Dom<T> that is rooted for
/// Create a vector of items of type `Dom<T>` that is rooted for
/// the lifetime of this struct
pub fn from_iter<I>(root: &'a mut RootableVec<Dom<T>>, iter: I) -> Self
where

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Trait representing the concept of [transferable objects]
//! (https://html.spec.whatwg.org/multipage/#transferable-objects).
//! (<https://html.spec.whatwg.org/multipage/#transferable-objects>).
use js::jsapi::MutableHandleObject;

View file

@ -9,7 +9,7 @@ use html5ever::{namespace_url, ns, LocalName, Namespace, Prefix};
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::str::DOMString;
/// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details.
/// Validate a qualified name. See <https://dom.spec.whatwg.org/#validate> for details.
pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
// Step 2.
match xml_name_type(qualified_name) {
@ -20,7 +20,7 @@ pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
}
/// Validate a namespace and qualified name and extract their parts.
/// See https://dom.spec.whatwg.org/#validate-and-extract for details.
/// See <https://dom.spec.whatwg.org/#validate-and-extract> for details.
pub fn validate_and_extract(
namespace: Option<DOMString>,
qualified_name: &str,
@ -86,7 +86,7 @@ pub enum XMLName {
InvalidXMLName,
}
/// Check if an element name is valid. See http://www.w3.org/TR/xml/#NT-Name
/// Check if an element name is valid. See <http://www.w3.org/TR/xml/#NT-Name>
/// for details.
pub fn xml_name_type(name: &str) -> XMLName {
fn is_valid_start(c: char) -> bool {