Small documentation fixes 🧾

This commit is contained in:
Laurenz 2020-10-03 18:15:09 +02:00
parent 91d14d2a22
commit 54e0da59e3
10 changed files with 20 additions and 25 deletions

View File

@ -20,9 +20,11 @@ pub struct RgbaColor {
pub b: u8, pub b: u8,
/// Alpha channel. /// Alpha channel.
pub a: u8, pub a: u8,
/// This is true if this value was provided as a fail-over by the parser /// Whether the color was provided as a fail-over by the parser because the
/// because the user-defined value was invalid. This color may be /// user-defined value was invalid.
/// overwritten if this property is true. ///
/// If this is true, the color may be replaced with any color deemed
/// approriate at the use-site.
pub healed: bool, pub healed: bool,
} }

View File

@ -41,7 +41,7 @@ impl Display for Level {
} }
} }
/// Construct a diagnostic with `Error` level. /// Construct a diagnostic with [`Error`] level.
/// ///
/// ``` /// ```
/// # use typstc::error; /// # use typstc::error;
@ -59,6 +59,8 @@ impl Display for Level {
/// // Create an error and directly add it to existing feedback. /// // Create an error and directly add it to existing feedback.
/// error!(@feedback, span, "oh no!"); /// error!(@feedback, span, "oh no!");
/// ``` /// ```
///
/// [`Error`]: diagnostic/enum.Level.html#variant.Error
#[macro_export] #[macro_export]
macro_rules! error { macro_rules! error {
($($tts:tt)*) => { ($($tts:tt)*) => {
@ -66,10 +68,12 @@ macro_rules! error {
}; };
} }
/// Construct a diagnostic with `Warning` level. /// Construct a diagnostic with [`Warning`] level.
/// ///
/// This works exactly like `error!`. See its documentation for more /// This works exactly like `error!`. See its documentation for more
/// information. /// information.
///
/// [`Warning`]: diagnostic/enum.Level.html#variant.Warning
#[macro_export] #[macro_export]
macro_rules! warning { macro_rules! warning {
($($tts:tt)*) => { ($($tts:tt)*) => {

View File

@ -31,7 +31,7 @@ pub enum Value {
Length(f64), Length(f64),
/// A relative value: `50%`. /// A relative value: `50%`.
/// ///
/// Note: `50%` is represented as `0.5` here, but as `50.0` in the /// _Note_: `50%` is represented as `0.5` here, but as `50.0` in the
/// corresponding [literal]. /// corresponding [literal].
/// ///
/// [literal]: ../syntax/ast/enum.Lit.html#variant.Percent /// [literal]: ../syntax/ast/enum.Lit.html#variant.Percent

View File

@ -21,8 +21,6 @@
//! [_PDF_]: export/pdf/index.html //! [_PDF_]: export/pdf/index.html
//! [`MultiLayout`]: layout/type.MultiLayout.html //! [`MultiLayout`]: layout/type.MultiLayout.html
#[macro_use]
mod macros;
#[macro_use] #[macro_use]
pub mod diagnostic; pub mod diagnostic;
@ -122,8 +120,7 @@ impl Typesetter {
} }
/// A dynamic future type which allows recursive invocation of async functions /// A dynamic future type which allows recursive invocation of async functions
/// when used as the return type. This is also how the async trait functions /// when used as the return type.
/// work internally.
pub type DynFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; pub type DynFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>;
/// The result of some pass: Some output `T` and feedback data. /// The result of some pass: Some output `T` and feedback data.

View File

@ -1,10 +0,0 @@
/// Unwrap the option if it is `Some(T)` or evaluate `$or` if it is `None`.
#[allow(unused)]
macro_rules! try_or {
($option:expr, $or:expr $(,)?) => {
match $option {
Some(v) => v,
None => $or,
}
};
}

View File

@ -366,7 +366,7 @@ fn test_parse_colon_starting_func_args() {
e!("[val/🌎:$]" => s(4, 4, "expected colon")); e!("[val/🌎:$]" => s(4, 4, "expected colon"));
// String in invalid header without colon still parsed as string // String in invalid header without colon still parsed as string
// Note: No "expected quote" error because not even the string was // _Note_: No "expected quote" error because not even the string was
// expected. // expected.
e!("[val/\"]" => s(4, 4, "expected colon"), e!("[val/\"]" => s(4, 4, "expected colon"),
s(7, 7, "expected closing bracket")); s(7, 7, "expected closing bracket"));

View File

@ -1,9 +1,11 @@
//! A prelude for building custom functions. //! A prelude for building custom functions.
#[doc(no_inline)]
pub use crate::eval::{Dict, DictValue, Value}; pub use crate::eval::{Dict, DictValue, Value};
pub use crate::layout::primitive::*; pub use crate::layout::primitive::*;
#[doc(no_inline)]
pub use crate::layout::{layout, Command, Commands, LayoutContext}; pub use crate::layout::{layout, Command, Commands, LayoutContext};
pub use crate::style::*; #[doc(no_inline)]
pub use crate::syntax::{Span, Spanned, SynTree}; pub use crate::syntax::{Span, Spanned, SynTree};
pub use crate::{Feedback, Pass}; pub use crate::{Feedback, Pass};

View File

@ -22,7 +22,7 @@ pub enum Lit {
Length(Length), Length(Length),
/// A percent literal: `50%`. /// A percent literal: `50%`.
/// ///
/// Note: `50%` is represented as `50.0` here, but as `0.5` in the /// _Note_: `50%` is represented as `50.0` here, but as `0.5` in the
/// corresponding [value]. /// corresponding [value].
/// ///
/// [value]: ../../eval/enum.Value.html#variant.Relative /// [value]: ../../eval/enum.Value.html#variant.Relative

View File

@ -83,7 +83,7 @@ impl<T> Spanned<T> {
} }
impl<T> Spanned<Option<T>> { impl<T> Spanned<Option<T>> {
/// Swap the spanned and option. /// Swap the spanned and the option.
pub fn transpose(self) -> Option<Spanned<T>> { pub fn transpose(self) -> Option<Spanned<T>> {
let Spanned { v, span } = self; let Spanned { v, span } = self;
v.map(|v| v.span_with(span)) v.map(|v| v.span_with(span))

View File

@ -75,7 +75,7 @@ pub enum Token<'s> {
Length(Length), Length(Length),
/// A percentage: `50%`. /// A percentage: `50%`.
/// ///
/// Note: `50%` is represented as `50.0` here, as in the corresponding /// _Note_: `50%` is represented as `50.0` here, as in the corresponding
/// [literal]. /// [literal].
/// ///
/// [literal]: ../ast/enum.Lit.html#variant.Percent /// [literal]: ../ast/enum.Lit.html#variant.Percent