Skip to content

Commit 543241f

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/add-changelog-translation
2 parents 56a2607 + 9e9e3d1 commit 543241f

File tree

18 files changed

+271
-263
lines changed

18 files changed

+271
-263
lines changed

crates/typst-library/src/foundations/func.rs

Lines changed: 50 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ use crate::foundations::{
1616
PluginFunc, Scope, Selector, Type, Value,
1717
};
1818

19-
/// A mapping from argument values to a return value.
19+
/// 引数値から戻り値への写像。
2020
///
21-
/// You can call a function by writing a comma-separated list of function
22-
/// _arguments_ enclosed in parentheses directly after the function name.
23-
/// Additionally, you can pass any number of trailing content blocks arguments
24-
/// to a function _after_ the normal argument list. If the normal argument list
25-
/// would become empty, it can be omitted. Typst supports positional and named
26-
/// arguments. The former are identified by position and type, while the latter
27-
/// are written as `name: value`.
21+
/// 関数名の直後に括弧で囲まれたカンマ区切りの関数の _引数_ のリストを書くことにより関数を呼び出すことができます。
22+
/// 加えて、通常の引数リストの後に任意の数のコンテンツブロック引数を関数に渡すこともできます。
23+
/// 通常の引数リストが空の場合は省略が可能です。
24+
/// Typstは位置引数とキーワード引数をサポートしています。
25+
/// 前者は位置と型によって識別され、後者は`name: value`のように書きます。
2826
///
29-
/// Within math mode, function calls have special behaviour. See the
30-
/// [math documentation]($category/math) for more details.
27+
/// 数式モードでは、関数呼び出しは特殊な振る舞いをします。
28+
/// 詳細は[数式のドキュメント]($category/math)を参照して下さい。
3129
///
32-
/// # Example
30+
/// #
3331
/// ```example
3432
/// // Call a function.
3533
/// #list([A], [B])
@@ -42,47 +40,35 @@ use crate::foundations::{
4240
/// #list[A][B]
4341
/// ```
4442
///
45-
/// Functions are a fundamental building block of Typst. Typst provides
46-
/// functions for a variety of typesetting tasks. Moreover, the markup you write
47-
/// is backed by functions and all styling happens through functions. This
48-
/// reference lists all available functions and how you can use them. Please
49-
/// also refer to the documentation about [set]($styling/#set-rules) and
50-
/// [show]($styling/#show-rules) rules to learn about additional ways you can
51-
/// work with functions in Typst.
43+
/// 関数はTypstにおいて基礎となる構成要素です。
44+
/// Typstは様々な組版タスクに応じた関数を提供しています。
45+
/// さらには、作成されるマークアップの裏側では関数が用いられており、すべてのスタイル設定は関数を介して行われます。
46+
/// このリファレンスでは利用可能なすべての関数とその使い方を示します。
47+
/// Typstで関数をさらに活用する方法については、[setルール]($styling/#set-rules)および[showルール]($styling/#show-rules)のドキュメントも参照して下さい。
5248
///
53-
/// # Element functions
54-
/// Some functions are associated with _elements_ like [headings]($heading) or
55-
/// [tables]($table). When called, these create an element of their respective
56-
/// kind. In contrast to normal functions, they can further be used in [set
57-
/// rules]($styling/#set-rules), [show rules]($styling/#show-rules), and
58-
/// [selectors]($selector).
49+
/// # 要素関数
50+
/// [見出し]($heading)や[表]($table)のような、いくつかの関数は _要素_ と結びついており、呼び出すとその種類に応じた要素を作成します。
51+
/// さらに、通常の関数とは異なり、要素関数は[setルール]($styling/#set-rules)、[showルール]($styling/#show-rules)および [セレクター]($selector)で使用可能です。
5952
///
60-
/// # Function scopes
61-
/// Functions can hold related definitions in their own scope, similar to a
62-
/// [module]($scripting/#modules). Examples of this are
63-
/// [`assert.eq`]($assert.eq) or [`list.item`]($list.item). However, this
64-
/// feature is currently only available for built-in functions.
53+
/// # 関数スコープ
54+
/// 関数は、[モジュール]($scripting/#modules)と同様に自身のスコープ内に関連する定義を保持できます。
55+
/// この例は[`assert.eq`]($assert.eq)や[`list.item`]($list.item)です。
56+
/// しかし、現在この機能が利用可能なのは組み込み関数のみです。
6557
///
66-
/// # Defining functions
67-
/// You can define your own function with a [let binding]($scripting/#bindings)
68-
/// that has a parameter list after the binding's name. The parameter list can
69-
/// contain mandatory positional parameters, named parameters with default
70-
/// values and [argument sinks]($arguments).
58+
/// # ユーザー定義関数
59+
/// [letバインディング]($scripting/#bindings)を用いることで、バインディング名の後に引数リストを持ったユーザー定義関数を定義することができます。
60+
/// 引数リストには必須の位置引数、デフォルト値を持つキーワード引数および[可変長引数]($arguments)を用いることができます。
7161
///
72-
/// The right-hand side of a function binding is the function body, which can be
73-
/// a block or any other expression. It defines the function's return value and
74-
/// can depend on the parameters. If the function body is a [code
75-
/// block]($scripting/#blocks), the return value is the result of joining the
76-
/// values of each expression in the block.
62+
/// 関数バインディングの右辺は関数本体で、ブロックか任意の式です。
63+
/// 関数の戻り値を定義し、引数に依存させることができます。
64+
/// 関数本体が[コードブロック]($scripting/#blocks)の場合、戻り値はブロック内のすべての式を連結させた結果になります。
7765
///
78-
/// Within a function body, the `return` keyword can be used to exit early and
79-
/// optionally specify a return value. If no explicit return value is given, the
80-
/// body evaluates to the result of joining all expressions preceding the
81-
/// `return`.
66+
/// 関数本体内では、`return`キーワードを用いて処理を途中で抜け出したり、必要に応じて戻り値を指定して返したりできます。
67+
/// 戻り値が明示的に与えられない場合、本体は`return`の前の式すべてを連結した結果として評価されます。
8268
///
83-
/// Functions that don't return any meaningful value return [`none`] instead.
84-
/// The return type of such functions is not explicitly specified in the
85-
/// documentation. (An example of this is [`array.push`]).
69+
/// 意味のある値を何も返さない関数は、代わりに[`none`]を返します。
70+
/// このような関数の戻り値の型はドキュメント中では明示的に指定されていません
71+
/// (この例としては[`array.push`]が該当します)。
8672
///
8773
/// ```example
8874
/// #let alert(body, fill: red) = {
@@ -105,33 +91,28 @@ use crate::foundations::{
10591
/// ]
10692
/// ```
10793
///
108-
/// # Importing functions
109-
/// Functions can be imported from one file ([`module`]($scripting/#modules)) into
110-
/// another using `{import}`. For example, assume that we have defined the `alert`
111-
/// function from the previous example in a file called `foo.typ`. We can import
112-
/// it into another file by writing `{import "foo.typ": alert}`.
94+
/// # 関数のインポート
95+
/// 関数は、`{import}`を用いてあるファイル([`module`]($scripting/#modules))から別のファイルにインポートすることができます。
96+
/// 例えば、上記の例にある`alert`関数を`foo.typ`というファイルに定義したとします。
97+
/// この場合、`{import "foo.typ": alert}`と書くことで別のファイルにインポートできます。
11398
///
114-
/// # Unnamed functions { #unnamed }
115-
/// You can also created an unnamed function without creating a binding by
116-
/// specifying a parameter list followed by `=>` and the function body. If your
117-
/// function has just one parameter, the parentheses around the parameter list
118-
/// are optional. Unnamed functions are mainly useful for show rules, but also
119-
/// for settable properties that take functions like the page function's
120-
/// [`footer`]($page.footer) property.
99+
/// # 無名関数 { #unnamed }
100+
/// 引数リストに続けて `=>` と関数本体を指定することで、バインディングを作らずに無名関数も作成できます。
101+
/// もし関数の引数が1つだけならば、引数リストの周りの括弧は必須ではありません。
102+
/// 無名関数は主にshowルールで用いると便利ですが、page関数の[`footer`]($page.footer)プロパティのような、関数を引数に取る設定可能プロパティにも便利です。
121103
///
122104
/// ```example
123105
/// #show "once?": it => [#it #it]
124106
/// once?
125107
/// ```
126108
///
127-
/// # Note on function purity
128-
/// In Typst, all functions are _pure._ This means that for the same
129-
/// arguments, they always return the same result. They cannot "remember" things to
130-
/// produce another value when they are called a second time.
109+
/// # 関数の純粋性に関する注意
110+
/// Typstにおいて関数はすべて _純粋_ です。
111+
/// これは同じ引数からは常に同じ結果が返ってくることを意味します。
112+
/// 純粋関数は2回目の呼び出し時に別の値を生成するために何かを「記憶」することはできません。
131113
///
132-
/// The only exception are built-in methods like
133-
/// [`array.push(value)`]($array.push). These can modify the values they are
134-
/// called on.
114+
/// 唯一の例外は[`array.push(value)`]($array.push)のような組み込みメソッドです。
115+
/// これらは呼び出された対象を変更できます。
135116
#[ty(scope, cast, name = "function")]
136117
#[derive(Clone, Hash)]
137118
#[allow(clippy::derived_hash_with_manual_eq)]
@@ -357,12 +338,12 @@ impl Func {
357338

358339
#[scope]
359340
impl Func {
360-
/// Returns a new function that has the given arguments pre-applied.
341+
/// 指定した引数を事前に適用した新しい関数を返します。
361342
#[func]
362343
pub fn with(
363344
self,
364345
args: &mut Args,
365-
/// The arguments to apply to the function.
346+
/// 関数に適用する引数。
366347
#[external]
367348
#[variadic]
368349
arguments: Vec<Value>,
@@ -374,8 +355,7 @@ impl Func {
374355
}
375356
}
376357

377-
/// Returns a selector that filters for elements belonging to this function
378-
/// whose fields have the values of the given arguments.
358+
/// この関数に属する要素のうち、与えられた引数と同じ値のフィールドを持つものを絞り込むセレクターを返します。
379359
///
380360
/// ```example
381361
/// #show heading.where(level: 2): set text(blue)
@@ -387,7 +367,7 @@ impl Func {
387367
pub fn where_(
388368
self,
389369
args: &mut Args,
390-
/// The fields to filter for.
370+
/// 絞り込むフィールド。
391371
#[variadic]
392372
#[external]
393373
fields: Vec<Value>,

crates/typst-library/src/layout/align.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::text::TextElem;
5050
/// ```
5151
///
5252
/// # 配置のネスト
53-
/// レイアウトコンテナおよびその内部要素に様々な配置設定を適用できます
53+
/// レイアウトコンテナおよびその内部の要素に様々な配置設定を適用できます
5454
/// このようにすることで複雑なレイアウトを作成できます。
5555
///
5656
/// ```example

crates/typst-library/src/layout/pad.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use crate::engine::Engine;
33
use crate::foundations::{elem, Content, NativeElement, Packed, Show, StyleChain};
44
use crate::layout::{BlockElem, Length, Rel};
55

6-
/// Adds spacing around content.
6+
/// コンテンツの周囲に空白を追加。
77
///
8-
/// The spacing can be specified for each side individually, or for all sides at
9-
/// once by specifying a positional argument.
8+
/// 空白は各辺を独立に指定するか、位置変数を用いて全辺を一括指定できます。
109
///
11-
/// # Example
10+
/// #
1211
/// ```example
1312
/// #set align(center)
1413
///
@@ -18,7 +17,7 @@ use crate::layout::{BlockElem, Length, Rel};
1817
/// ```
1918
#[elem(title = "Padding", Show)]
2019
pub struct PadElem {
21-
/// The padding at the left side.
20+
/// 左辺のパディング。
2221
#[parse(
2322
let all = args.named("rest")?.or(args.find()?);
2423
let x = args.named("x")?.or(all);
@@ -27,31 +26,31 @@ pub struct PadElem {
2726
)]
2827
pub left: Rel<Length>,
2928

30-
/// The padding at the top side.
29+
/// 上辺のパディング。
3130
#[parse(args.named("top")?.or(y))]
3231
pub top: Rel<Length>,
3332

34-
/// The padding at the right side.
33+
/// 右辺のパディング。
3534
#[parse(args.named("right")?.or(x))]
3635
pub right: Rel<Length>,
3736

38-
/// The padding at the bottom side.
37+
/// 下辺のパディング。
3938
#[parse(args.named("bottom")?.or(y))]
4039
pub bottom: Rel<Length>,
4140

42-
/// A shorthand to set `left` and `right` to the same value.
41+
/// `left``right`を同じ値で設定するための省略記法。
4342
#[external]
4443
pub x: Rel<Length>,
4544

46-
/// A shorthand to set `top` and `bottom` to the same value.
45+
/// `top``bottom`を同じ値で設定するための省略記法。
4746
#[external]
4847
pub y: Rel<Length>,
4948

50-
/// A shorthand to set all four sides to the same value.
49+
/// 四辺すべてを同じ値で設定するための省略記法。
5150
#[external]
5251
pub rest: Rel<Length>,
5352

54-
/// The content to pad at the sides.
53+
/// パディングを追加するコンテンツ。
5554
#[required]
5655
pub body: Content,
5756
}

0 commit comments

Comments
 (0)