diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-17 16:24:29 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-17 16:24:29 +0100 |
| commit | 35b16e545b4fce299edbc00c9a9754179fa51634 (patch) | |
| tree | eb1081e55187e59ff6482abc1ac2f1932606ef59 /library/src/text | |
| parent | b6202b646a0d5ecced301d9bac8bfcaf977d7ee4 (diff) | |
Document parameters in comment
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/deco.rs | 7 | ||||
| -rw-r--r-- | library/src/text/misc.rs | 58 | ||||
| -rw-r--r-- | library/src/text/mod.rs | 11 | ||||
| -rw-r--r-- | library/src/text/quotes.rs | 7 | ||||
| -rw-r--r-- | library/src/text/raw.rs | 11 | ||||
| -rw-r--r-- | library/src/text/shift.rs | 17 | ||||
| -rw-r--r-- | library/src/text/symbol.rs | 7 |
7 files changed, 96 insertions, 22 deletions
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index 86866715..d725697e 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -6,7 +6,12 @@ use crate::prelude::*; /// Typeset underline, stricken-through or overlined text. /// -/// Tags: text. +/// # Parameters +/// - body: Content (positional, required) +/// The content to decorate. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index fc4f7d73..20be156a 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -3,7 +3,8 @@ use crate::prelude::*; /// A text space. /// -/// Tags: text. +/// # Tags +/// - text #[func] #[capable(Unlabellable, Behave)] #[derive(Debug, Hash)] @@ -26,7 +27,12 @@ impl Behave for SpaceNode { /// A line break. /// -/// Tags: text. +/// # Parameters +/// - justify: bool (named) +/// Whether to justify the line before the break. +/// +/// # Tags +/// - text #[func] #[capable(Behave)] #[derive(Debug, Hash)] @@ -50,7 +56,12 @@ impl Behave for LinebreakNode { /// Strongly emphasizes content by increasing the font weight. /// -/// Tags: text. +/// # Parameters +/// - body: Content (positional, required) +/// The content to strongly emphasize. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] @@ -98,7 +109,12 @@ impl Fold for Delta { /// Emphasizes content by flipping the italicness. /// -/// Tags: text. +/// # Parameters +/// - body: Content (positional, required) +/// The content to emphasize. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] @@ -136,17 +152,27 @@ impl Fold for Toggle { } } -/// Convert a string or content to lowercase. +/// Convert text or content to lowercase. /// -/// Tags: text. +/// # Parameters +/// - text: ToCase (positional, required) +/// The text to convert to lowercase. +/// +/// # Tags +/// - text #[func] pub fn lower(args: &mut Args) -> SourceResult<Value> { case(Case::Lower, args) } -/// Convert a string or content to uppercase. +/// Convert text or content to uppercase. +/// +/// # Parameters +/// - text: ToCase (positional, required) +/// The text to convert to uppercase. /// -/// Tags: text. +/// # Tags +/// - text #[func] pub fn upper(args: &mut Args) -> SourceResult<Value> { case(Case::Upper, args) @@ -162,6 +188,15 @@ fn case(case: Case, args: &mut Args) -> SourceResult<Value> { }) } +/// A value whose case can be changed. +struct ToCase; + +castable! { + ToCase, + _: Str => Self, + _: Content => Self, +} + /// A case transformation on text. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Case { @@ -183,7 +218,12 @@ impl Case { /// Display text in small capitals. /// -/// Tags: text. +/// # Parameters +/// - text: Content (positional, required) +/// The text to display to small capitals. +/// +/// # Tags +/// - text #[func] pub fn smallcaps(args: &mut Args) -> SourceResult<Value> { let body: Content = args.expect("content")?; diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs index 7340e5de..21dea8af 100644 --- a/library/src/text/mod.rs +++ b/library/src/text/mod.rs @@ -25,9 +25,16 @@ use typst::util::EcoString; use crate::layout::ParNode; use crate::prelude::*; -/// A single run of text with the same style. +/// Stylable text. /// -/// Tags: text. +/// # Parameters +/// - family: EcoString (positional, variadic, settable) +/// A prioritized sequence of font families. +/// - body: Content (positional, required) +/// Content in which all text is styled according to the other arguments. +/// +/// # Tags +/// - text #[func] #[capable] #[derive(Clone, Hash)] diff --git a/library/src/text/quotes.rs b/library/src/text/quotes.rs index ab6f166c..4f65c7fd 100644 --- a/library/src/text/quotes.rs +++ b/library/src/text/quotes.rs @@ -4,7 +4,12 @@ use crate::prelude::*; /// A smart quote. /// -/// Tags: text. +/// # Parameters +/// - double: bool (named) +/// Whether to produce a smart double quote. +/// +/// # Tags +/// - text #[func] #[capable] #[derive(Debug, Hash)] diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 125a5da1..74626588 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -8,14 +8,21 @@ use crate::prelude::*; /// Raw text with optional syntax highlighting. /// -/// Tags: text. +/// # Parameters +/// - text: EcoString (positional, required) +/// The raw text. +/// - block: bool (named) +/// Whether the raw text is displayed as a separate block. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] pub struct RawNode { /// The raw text. pub text: EcoString, - /// Whether the node is block-level. + /// Whether the raw text is displayed as a separate block. pub block: bool, } diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs index ad4a6cd9..969dce68 100644 --- a/library/src/text/shift.rs +++ b/library/src/text/shift.rs @@ -4,14 +4,19 @@ use typst::util::EcoString; use super::{variant, SpaceNode, TextNode, TextSize}; use crate::prelude::*; -/// Sub or superscript text. +/// Sub- or superscript text. /// -/// The text is rendered smaller and its baseline is raised. To provide the best -/// typography possible, we first try to transform the text to superscript -/// codepoints. If that fails, we fall back to rendering shrunk normal letters -/// in a raised way. +/// The text is rendered smaller and its baseline is raised/lowered. To provide +/// the best typography possible, we first try to transform the text to +/// superscript codepoints. If that fails, we fall back to rendering shrunk +/// normal letters in a raised way. /// -/// Tags: text. +/// # Parameters +/// - body: Content (positional, required) +/// The text to display in sub- or superscript. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] diff --git a/library/src/text/symbol.rs b/library/src/text/symbol.rs index eece81ab..ccf1a55e 100644 --- a/library/src/text/symbol.rs +++ b/library/src/text/symbol.rs @@ -3,7 +3,12 @@ use crate::text::TextNode; /// A symbol identified by symmie notation. /// -/// Tags: text. +/// # Parameters +/// - notation: EcoString (positional, required) +/// The symbols symmie notation. +/// +/// # Tags +/// - text #[func] #[capable(Show)] #[derive(Debug, Hash)] |
