Use newly stabilized intra doc links ↩

This commit is contained in:
Laurenz 2020-11-24 16:12:41 +01:00
parent f105663037
commit 761931405c
15 changed files with 25 additions and 66 deletions

View File

@ -7,9 +7,7 @@
use crate::syntax::SpanVec;
use std::fmt::{self, Display, Formatter};
/// The result of some pass: Some output `T` and [feedback] data.
///
/// [feedback]: struct.Feedback.html
/// The result of some pass: Some output `T` and [`Feedback`] data.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Pass<T> {
/// The output of this compilation pass.
@ -118,7 +116,7 @@ pub enum Deco {
DictKey,
}
/// Construct a diagnostic with [`Error`] level.
/// Construct a diagnostic with [`Error`](Level::Error) level.
///
/// ```
/// # use typst::error;
@ -131,8 +129,6 @@ pub enum Deco {
/// // Create spanned errors.
/// let spanned = error!(span, "there is an error here");
/// ```
///
/// [`Error`]: diag/enum.Level.html#variant.Error
#[macro_export]
macro_rules! error {
($($tts:tt)*) => {
@ -140,12 +136,10 @@ macro_rules! error {
};
}
/// Construct a diagnostic with [`Warning`] level.
/// Construct a diagnostic with [`Warning`](Level::Warning) level.
///
/// This works exactly like `error!`. See its documentation for more
/// information.
///
/// [`Warning`]: diag/enum.Level.html#variant.Warning
#[macro_export]
macro_rules! warning {
($($tts:tt)*) => {

View File

@ -28,10 +28,8 @@ impl Args {
})
}
/// This is the same as [`get`], except that it generates an error about a
/// This is the same as [`get`](Self::get), except that it generates an error about a
/// missing argument with the given `name` if the key does not exist.
///
/// [`get`]: #method.get
pub fn need<'a, K, T>(
&mut self,
ctx: &mut EvalContext,

View File

@ -85,10 +85,7 @@ macro_rules! convert_ident {
};
}
/// A value type that matches [identifier] and [string] values.
///
/// [identifier]: enum.Value.html#variant.Ident
/// [string]: enum.Value.html#variant.Str
/// A value type that matches [identifier](Value::Ident) and [string](Value::Str) values.
pub struct StringLike(pub String);
impl From<StringLike> for String {

View File

@ -91,8 +91,6 @@ impl EvalContext {
/// Push a layout node to the active group.
///
/// Spacing nodes will be handled according to their [`Softness`].
///
/// [`Softness`]: ../layout/nodes/enum.Softness.html
pub fn push(&mut self, node: impl Into<LayoutNode>) {
let node = node.into();
@ -196,21 +194,16 @@ impl EvalContext {
/// Start a layouting group.
///
/// All further calls to [`push`] will collect nodes for this group.
/// All further calls to [`push`](Self::push) will collect nodes for this group.
/// The given metadata will be returned alongside the collected nodes
/// in a matching call to [`end_group`].
///
/// [`push`]: #method.push
/// [`end_group`]: #method.end_group
/// in a matching call to [`end_group`](Self::end_group).
fn start_group<T: 'static>(&mut self, meta: T) {
self.groups.push((Box::new(meta), std::mem::take(&mut self.inner)));
}
/// End a layouting group started with [`start_group`].
/// End a layouting group started with [`start_group`](Self::start_group).
///
/// This returns the stored metadata and the collected nodes.
///
/// [`start_group`]: #method.start_group
fn end_group<T: 'static>(&mut self) -> (T, Vec<LayoutNode>) {
if let Some(&LayoutNode::Spacing(spacing)) = self.inner.last() {
if spacing.softness == Softness::Soft {

View File

@ -134,7 +134,6 @@ pub type ValueDict = Dict<SpannedEntry<Value>>;
/// [`Value`] when directly putting the `Rc` in there, see the [Rust
/// Issue].
///
/// [`Value`]: enum.Value.html
/// [Rust Issue]: https://github.com/rust-lang/rust/issues/31740
#[derive(Clone)]
pub struct ValueFunc(pub Rc<Func>);

View File

@ -18,8 +18,7 @@ use crate::layout::{BoxLayout, LayoutElement};
/// pass in the font loader used for typesetting such that the fonts can be
/// included in the _PDF_.
///
/// The raw _PDF_ is written into the `target` writable, returning the number of
/// bytes written.
/// Returns the raw bytes making up the _PDF_ document.
pub fn export(layouts: &[BoxLayout], loader: &FontLoader) -> Vec<u8> {
PdfExporter::new(layouts, loader).write()
}

View File

@ -3,9 +3,7 @@ use super::*;
/// A relative length.
///
/// _Note_: `50%` is represented as `0.5` here, but stored as `50.0` in the
/// corresponding [literal].
///
/// [literal]: ../syntax/ast/enum.Lit.html#variant.Percent
/// corresponding [literal](crate::syntax::Lit::Percent).
#[derive(Default, Copy, Clone, PartialEq, PartialOrd)]
pub struct Relative(f64);

View File

@ -23,9 +23,7 @@ impl Document {
pub struct Pages {
/// The size of the pages.
pub size: Size,
/// The layout node that produces the actual pages (typically a [stack]).
///
/// [stack]: struct.Stack.html
/// The layout node that produces the actual pages (typically a [`Stack`]).
pub child: LayoutNode,
}

View File

@ -124,9 +124,7 @@ impl Expansion {
}
}
/// The result of [layouting] a node.
///
/// [layouting]: trait.Layout.html#method.layout
/// The result of [layouting](Layout::layout) a node.
#[derive(Debug, Clone, PartialEq)]
pub enum Layouted {
/// Spacing that should be added to the parent.

View File

@ -50,7 +50,6 @@ impl Debug for LayoutNode {
/// [`LayoutNode`] when directly putting the `Box` in there, see the
/// [Rust Issue].
///
/// [`LayoutNode`]: enum.LayoutNode.html
/// [Rust Issue]: https://github.com/rust-lang/rust/issues/31740
pub struct Dynamic(pub Box<dyn DynNode>);
@ -102,8 +101,6 @@ impl PartialEq for Dynamic {
/// DynNode>` able to implement `Clone` and `PartialEq`. However, these are
/// automatically provided by a blanket impl as long as the type in question
/// implements[`Layout`], `Debug`, `PartialEq`, `Clone` and is `'static`.
///
/// [`Layout`]: ../trait.Layout.html
pub trait DynNode: Debug + Layout + 'static {
/// Convert into a `dyn Any` to enable downcasting.
fn as_any(&self) -> &dyn Any;

View File

@ -7,10 +7,8 @@ use super::*;
pub struct Spacing {
/// The amount of spacing to insert.
pub amount: Length,
/// Spacing interaction, see [Softness's] documentation for more
/// Spacing interaction, see [`Softness`]'s documentation for more
/// information.
///
/// [Softness's]: enum.Softness.html
pub softness: Softness,
}

View File

@ -3,30 +3,26 @@
//! # Steps
//! - **Parsing:** The parsing step first transforms a plain string into an
//! [iterator of tokens][tokens]. This token stream is [parsed] into a [syntax
//! tree]. The structures describing the tree can be found in the [AST]
//! tree]. The structures describing the tree can be found in the [syntax]
//! module.
//! - **Evaluation:** The next step is to [evaluate] the parsed "script" to a
//! [document], a high-level, fully styled representation. The [nodes] of the
//! [document], a high-level, fully styled representation. The nodes of the
//! document tree are fully self-contained and order-independent and thus much
//! better suited for layouting than the syntax tree.
//! - **Layouting:** The next step is to [layout] the document into a portable
//! version of the typeset document. The output of this is a vector of
//! [`BoxLayouts`] (corresponding to pages), ready for exporting.
//! [`BoxLayout`]s (corresponding to pages), ready for exporting.
//! - **Exporting:** The finished layout can be exported into a supported
//! format. Submodules for these formats are located in the [export] module.
//! Currently, the only supported output format is [_PDF_].
//!
//! [tokens]: parse/struct.Tokens.html
//! [parsed]: parse/fn.parse.html
//! [syntax tree]: syntax/ast/type.SynTree.html
//! [AST]: syntax/ast/index.html
//! [evaluate]: eval/fn.eval.html
//! [document]: layout/nodes/struct.Document.html
//! [nodes]: layout/nodes/index.html
//! [layout]: layout/fn.layout.html
//! [`BoxLayouts`]: layout/struct.BoxLayout.html
//! [export]: export/index.html
//! [_PDF_]: export/pdf/index.html
//! [tokens]: parse::Tokens
//! [parsed]: parse::parse
//! [syntax tree]: syntax::SynTree
//! [evaluate]: eval::eval
//! [document]: layout::Document
//! [layout]: layout::layout
//! [_PDF_]: export::pdf
#[macro_use]
pub mod diag;

View File

@ -59,8 +59,6 @@ impl Debug for Shaped {
}
/// Shape text into a box containing [`Shaped`] runs.
///
/// [`Shaped`]: struct.Shaped.html
pub fn shape(
loader: &mut FontLoader,
text: &str,

View File

@ -21,9 +21,7 @@ pub enum Lit {
/// A percent literal: `50%`.
///
/// _Note_: `50%` is stored as `50.0` here, but as `0.5` in the
/// corresponding [value].
///
/// [value]: ../../geom/struct.Relative.html
/// corresponding [value](crate::geom::Relative).
Percent(f64),
/// A color literal: `#ffccee`.
Color(RgbaColor),

View File

@ -76,9 +76,7 @@ pub enum Token<'s> {
/// A percentage: `50%`.
///
/// _Note_: `50%` is stored as `50.0` here, as in the corresponding
/// [literal].
///
/// [literal]: ../ast/enum.Lit.html#variant.Percent
/// [literal](super::Lit::Percent).
Percent(f64),
/// A hex value: `#20d82a`.
Hex(&'s str),