From e3bd39c9d156a4a02a8b7398ed5769100a3d877a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 4 Mar 2024 15:51:22 +0100 Subject: [PATCH] Add support for shortcut links in docs (#3547) --- crates/typst-macros/src/category.rs | 1 + crates/typst-macros/src/elem.rs | 1 + crates/typst-macros/src/func.rs | 1 + crates/typst-macros/src/ty.rs | 7 + crates/typst/src/foundations/bytes.rs | 8 +- crates/typst/src/foundations/content.rs | 9 +- crates/typst/src/foundations/datetime.rs | 4 +- crates/typst/src/foundations/duration.rs | 4 +- crates/typst/src/foundations/selector.rs | 17 +- crates/typst/src/foundations/styles.rs | 6 +- crates/typst/src/foundations/version.rs | 2 +- crates/typst/src/introspection/counter.rs | 17 +- crates/typst/src/introspection/here.rs | 19 +-- crates/typst/src/introspection/locate.rs | 10 +- crates/typst/src/introspection/location.rs | 16 +- crates/typst/src/introspection/metadata.rs | 10 +- crates/typst/src/introspection/mod.rs | 2 +- crates/typst/src/introspection/query.rs | 22 +-- crates/typst/src/layout/align.rs | 4 +- crates/typst/src/layout/fr.rs | 2 +- crates/typst/src/layout/layout.rs | 11 +- crates/typst/src/layout/length.rs | 2 +- crates/typst/src/layout/measure.rs | 17 +- crates/typst/src/layout/rel.rs | 6 +- crates/typst/src/loading/read.rs | 2 +- crates/typst/src/model/cite.rs | 4 +- crates/typst/src/model/figure.rs | 8 +- crates/typst/src/model/footnote.rs | 10 +- crates/typst/src/model/heading.rs | 12 +- crates/typst/src/model/link.rs | 12 +- crates/typst/src/model/outline.rs | 6 +- crates/typst/src/model/par.rs | 8 +- crates/typst/src/model/quote.rs | 3 +- crates/typst/src/model/reference.rs | 7 +- crates/typst/src/model/table.rs | 4 +- crates/typst/src/text/deco.rs | 6 +- crates/typst/src/text/mod.rs | 11 +- crates/typst/src/text/raw.rs | 9 +- crates/typst/src/text/smartquote.rs | 7 +- crates/typst/src/visualize/color.rs | 56 +++--- crates/typst/src/visualize/gradient.rs | 15 +- crates/typst/src/visualize/line.rs | 2 +- crates/typst/src/visualize/mod.rs | 2 +- crates/typst/src/visualize/path.rs | 5 +- crates/typst/src/visualize/pattern.rs | 9 +- crates/typst/src/visualize/polygon.rs | 2 +- crates/typst/src/visualize/shape.rs | 2 +- crates/typst/src/visualize/stroke.rs | 18 +- docs/changelog.md | 190 ++++++++++----------- docs/guides/guide-for-latex-users.md | 92 +++++----- docs/guides/page-setup.md | 38 ++--- docs/reference/context.md | 38 ++--- docs/reference/groups.yml | 12 +- docs/reference/scripting.md | 49 +++--- docs/reference/styling.md | 19 +-- docs/reference/syntax.md | 28 +-- docs/reference/welcome.md | 8 +- docs/roadmap.md | 2 +- docs/src/html.rs | 28 ++- docs/src/lib.rs | 3 +- docs/tutorial/1-writing.md | 15 +- docs/tutorial/2-formatting.md | 61 ++++--- docs/tutorial/3-advanced.md | 41 ++--- docs/tutorial/4-template.md | 22 +-- 64 files changed, 534 insertions(+), 530 deletions(-) diff --git a/crates/typst-macros/src/category.rs b/crates/typst-macros/src/category.rs index 399a0510f..ac8c813df 100644 --- a/crates/typst-macros/src/category.rs +++ b/crates/typst-macros/src/category.rs @@ -20,6 +20,7 @@ pub fn category(_: TokenStream, item: syn::Item) -> Result { Ok(quote! { #(#attrs)* + #[allow(rustdoc::broken_intra_doc_links)] #vis static #ident: #ty = { static DATA: #foundations::CategoryData = #foundations::CategoryData { name: #name, diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs index f14d33507..7734dd547 100644 --- a/crates/typst-macros/src/elem.rs +++ b/crates/typst-macros/src/elem.rs @@ -311,6 +311,7 @@ fn create_struct(element: &Elem) -> TokenStream { #[doc = #docs] #[derive(#debug Clone, Hash)] #[allow(clippy::derived_hash_with_manual_eq)] + #[allow(rustdoc::broken_intra_doc_links)] #vis struct #ident { #(#fields,)* } diff --git a/crates/typst-macros/src/func.rs b/crates/typst-macros/src/func.rs index 728ab05b6..b7a7ac63c 100644 --- a/crates/typst-macros/src/func.rs +++ b/crates/typst-macros/src/func.rs @@ -233,6 +233,7 @@ fn create(func: &Func, item: &syn::ItemFn) -> TokenStream { quote! { #[doc = #docs] #[allow(dead_code)] + #[allow(rustdoc::broken_intra_doc_links)] #item #[doc(hidden)] diff --git a/crates/typst-macros/src/ty.rs b/crates/typst-macros/src/ty.rs index 943bd4530..a6ae3f1c9 100644 --- a/crates/typst-macros/src/ty.rs +++ b/crates/typst-macros/src/ty.rs @@ -101,7 +101,14 @@ fn create(ty: &Type, item: Option<&syn::Item>) -> TokenStream { } }; + let attr = item.map(|_| { + quote! { + #[allow(rustdoc::broken_intra_doc_links)] + } + }); + quote! { + #attr #item #cast diff --git a/crates/typst/src/foundations/bytes.rs b/crates/typst/src/foundations/bytes.rs index 605af0650..4b8800e8d 100644 --- a/crates/typst/src/foundations/bytes.rs +++ b/crates/typst/src/foundations/bytes.rs @@ -17,10 +17,10 @@ use crate::util::LazyHash; /// using a [for loop]($scripting/#loops). /// /// You can convert -/// - a [string]($str) or an [array]($array) of integers to bytes with the -/// [`bytes`]($bytes) constructor -/// - bytes to a string with the [`str`]($str) constructor, with UTF-8 encoding -/// - bytes to an array of integers with the [`array`]($array) constructor +/// - a [string]($str) or an [array] of integers to bytes with the [`bytes`] +/// constructor +/// - bytes to a string with the [`str`] constructor, with UTF-8 encoding +/// - bytes to an array of integers with the [`array`] constructor /// /// When [reading]($read) data from a file, you can decide whether to load it /// as a string or as raw bytes. diff --git a/crates/typst/src/foundations/content.rs b/crates/typst/src/foundations/content.rs index 54789be08..83e94d302 100644 --- a/crates/typst/src/foundations/content.rs +++ b/crates/typst/src/foundations/content.rs @@ -67,7 +67,7 @@ use crate::util::{fat, BitSet, LazyHash}; /// /// In the web app, you can hover over a content variable to see exactly which /// elements the content is composed of and what fields they have. -/// Alternatively, you can inspect the output of the [`repr`]($repr) function. +/// Alternatively, you can inspect the output of the [`repr`] function. #[ty(scope, cast)] #[derive(Clone, Hash)] #[allow(clippy::derived_hash_with_manual_eq)] @@ -569,10 +569,9 @@ impl Content { } /// The location of the content. This is only available on content returned - /// by [query]($query) or provided by a - /// [show rule]($reference/styling/#show-rules), for other content it will - /// be `{none}`. The resulting location can be used with - /// [counters]($counter), [state]($state) and [queries]($query). + /// by [query] or provided by a [show rule]($reference/styling/#show-rules), + /// for other content it will be `{none}`. The resulting location can be + /// used with [counters]($counter), [state] and [queries]($query). #[func] pub fn location(&self) -> Option { self.inner.location diff --git a/crates/typst/src/foundations/datetime.rs b/crates/typst/src/foundations/datetime.rs index 053aa4226..9e4f00849 100644 --- a/crates/typst/src/foundations/datetime.rs +++ b/crates/typst/src/foundations/datetime.rs @@ -213,8 +213,8 @@ impl Datetime { impl Datetime { /// Creates a new datetime. /// - /// You can specify the [datetime]($datetime) using a year, month, day, - /// hour, minute, and second. + /// You can specify the [datetime] using a year, month, day, hour, minute, + /// and second. /// /// _Note_: Depending on which components of the datetime you specify, Typst /// will store it in one of the following three ways: diff --git a/crates/typst/src/foundations/duration.rs b/crates/typst/src/foundations/duration.rs index 83e3d962a..94d44fb2a 100644 --- a/crates/typst/src/foundations/duration.rs +++ b/crates/typst/src/foundations/duration.rs @@ -22,8 +22,8 @@ impl Duration { impl Duration { /// Creates a new duration. /// - /// You can specify the [duration]($duration) using weeks, days, hours, - /// minutes and seconds. You can also get a duration by subtracting two + /// You can specify the [duration] using weeks, days, hours, minutes and + /// seconds. You can also get a duration by subtracting two /// [datetimes]($datetime). /// /// ```example diff --git a/crates/typst/src/foundations/selector.rs b/crates/typst/src/foundations/selector.rs index 28c1967aa..92bfa8231 100644 --- a/crates/typst/src/foundations/selector.rs +++ b/crates/typst/src/foundations/selector.rs @@ -44,23 +44,22 @@ pub use crate::__select_where as select_where; /// A filter for selecting elements within the document. /// /// You can construct a selector in the following ways: -/// - you can use an element [function]($function) +/// - you can use an element [function] /// - you can filter for an element function with /// [specific fields]($function.where) /// - you can use a [string]($str) or [regular expression]($regex) /// - you can use a [`{