From 761931405c68efe0a35d96524df797dda7155723 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 24 Nov 2020 16:12:41 +0100 Subject: [PATCH] =?UTF-8?q?Use=20newly=20stabilized=20intra=20doc=20links?= =?UTF-8?q?=20=E2=86=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/diag.rs | 12 +++--------- src/eval/args.rs | 4 +--- src/eval/convert.rs | 5 +---- src/eval/mod.rs | 13 +++---------- src/eval/value.rs | 1 - src/export/pdf.rs | 3 +-- src/geom/relative.rs | 4 +--- src/layout/document.rs | 4 +--- src/layout/mod.rs | 4 +--- src/layout/node.rs | 3 --- src/layout/spacing.rs | 4 +--- src/lib.rs | 24 ++++++++++-------------- src/shaping.rs | 2 -- src/syntax/lit.rs | 4 +--- src/syntax/token.rs | 4 +--- 15 files changed, 25 insertions(+), 66 deletions(-) diff --git a/src/diag.rs b/src/diag.rs index 9f109be98..c3bef75e7 100644 --- a/src/diag.rs +++ b/src/diag.rs @@ -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 { /// 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)*) => { diff --git a/src/eval/args.rs b/src/eval/args.rs index dda6fedf7..e9bf378bc 100644 --- a/src/eval/args.rs +++ b/src/eval/args.rs @@ -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, diff --git a/src/eval/convert.rs b/src/eval/convert.rs index 4885b72f2..81e426941 100644 --- a/src/eval/convert.rs +++ b/src/eval/convert.rs @@ -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 for String { diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 5a8b857a0..c45e46aeb 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -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) { 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(&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(&mut self) -> (T, Vec) { if let Some(&LayoutNode::Spacing(spacing)) = self.inner.last() { if spacing.softness == Softness::Soft { diff --git a/src/eval/value.rs b/src/eval/value.rs index c6850f439..e897fa75e 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -134,7 +134,6 @@ pub type ValueDict = Dict>; /// [`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); diff --git a/src/export/pdf.rs b/src/export/pdf.rs index cb05dee0d..c5d8d8716 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -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 { PdfExporter::new(layouts, loader).write() } diff --git a/src/geom/relative.rs b/src/geom/relative.rs index d87cfac73..ce473e3d8 100644 --- a/src/geom/relative.rs +++ b/src/geom/relative.rs @@ -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); diff --git a/src/layout/document.rs b/src/layout/document.rs index 52d0d124b..112457d67 100644 --- a/src/layout/document.rs +++ b/src/layout/document.rs @@ -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, } diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 5586a1fdc..2d4553b43 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -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. diff --git a/src/layout/node.rs b/src/layout/node.rs index 6b264eb01..35e742a5c 100644 --- a/src/layout/node.rs +++ b/src/layout/node.rs @@ -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); @@ -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; diff --git a/src/layout/spacing.rs b/src/layout/spacing.rs index c44f92e4a..1ba3b54a2 100644 --- a/src/layout/spacing.rs +++ b/src/layout/spacing.rs @@ -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, } diff --git a/src/lib.rs b/src/lib.rs index a4e0ef3f3..7d54da4cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/shaping.rs b/src/shaping.rs index 45ab6ff8c..efc24d071 100644 --- a/src/shaping.rs +++ b/src/shaping.rs @@ -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, diff --git a/src/syntax/lit.rs b/src/syntax/lit.rs index 40b360da9..e86479650 100644 --- a/src/syntax/lit.rs +++ b/src/syntax/lit.rs @@ -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), diff --git a/src/syntax/token.rs b/src/syntax/token.rs index 5b055e39f..e630c50cc 100644 --- a/src/syntax/token.rs +++ b/src/syntax/token.rs @@ -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),