参数

描述函數和 API 的參數定義,這對文檔非常有用。

語法

1{{% params [data] %}}

參數

data

名稱上下文類型必填默認值版本示例
data-string---

數據文件名。

heading

名稱上下文類型必填默認值版本示例
heading-string-Parameters--

標題。

headingStartLevel

名稱上下文類型必填默認值版本示例
headingStartLevel-number-2--

開始標題的級別。

context

名稱上下文類型必填默認值版本示例
context-string--0.20.0-

所有參數的默認上下文。

數據條目屬性

name

名稱上下文類型必填默認值版本示例
name-string---

參數名。

type

名稱上下文類型必填默認值版本示例
type-string/array-string--

參數類型。

required

名稱上下文類型必填默認值版本示例
required-boolean-false--

表示參數是否必填。

default

名稱上下文類型必填默認值版本示例
default-string----

參數默認值。

since

名稱上下文類型必填默認值版本示例
since-string----

表示添加參數的版本。

description

名稱上下文類型必填默認值版本示例
description-string/object---

參數說明,支持 Markdown。

description.default

名稱上下文類型必填默認值版本示例
description.default-string----

默認的參數說明。

description.[lang]

名稱上下文類型必填默認值版本示例
description.[lang]-string----

特定語言的描述。

options

名稱上下文類型必填默認值版本示例
options-array----

可選項。

deprecated

名稱上下文類型必填默認值版本示例
deprecated-string-false--

表示參數是否已被棄用。

示例

data/example-params.yaml
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="ln"> 1</span><span class="cl">- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">foo</span><span class="w">

2 required: true 3 description: 4 default: Foo description. 5 zh-hans: Foo 描述。 6 zh-hant: Foo 描述。 7 8- name: bar 9 type: number 10 since: v0.2.0 11 deprecated: true 12 description: 13 default: Bar description. 14 zh-hans: Bar 描述。 15 zh-hant: Bar 描述。 16 17- name: fizz 18 description: Single description without translations. 19 options: 20 - one 21 - two

Result as follows.

源碼
1{{% params data="data/example-params.yaml" heading="Example Parameters" headingStartLevel=3 %}}
結果

Example Parameters

foo

名稱上下文類型必填默認值版本示例
foo-string---

Foo 描述。

bar

名稱上下文類型必填默認值版本示例
bar-number--v0.2.0-

Bar 描述。

fizz

名稱上下文類型必填默認值版本示例
fizz-string----

Single description without translations.

可選項:one, two