docs: support parameter suffix * (#7946)

* docs: support parameter suffix `*`

`*` denotes a zero or more parameter matches, so the parameter including `*` is optional. (https://github.com/pillarjs/path-to-regexp#zero-or-more)

* docs: mention the parameter suffix `*`

* docs: support parameter suffix `+`

* docs: add document of parameter suffixs

* docs: fix having / at the end of parameter

* docs: add missing changes in en docs

* docs: typo

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
Hagb (Junyu Guo 郭俊余)
2022-05-07 17:18:35 +08:00
committed by GitHub
parent 2441ef91f0
commit eb79456f40
6 changed files with 11 additions and 9 deletions

View File

@@ -16,7 +16,7 @@
<p> <p>
参数: 参数:
</p> </p>
<ul><li class="params" v-for="(item, index) in path.match(/:.*?(\/|$)/g)"><code>{{item.replace(':','').replace('/','').replace('?','')}}</code>, {{(item.includes('?'))?'可选':'必选'}} - <span v-html="renderMarkdown(paramsDesc[index])"></span></li></ul> <ul><li class="params" v-for="(item, index) in path.match(/:.*?(\/|$)/g)"><code>{{item.replace(/:|\?|\+|\*|\//g,'')}}</code>, {{{'?':'可选','*':'零个或多个','+':'单个或多个'}[item[item.length-1]]||'必选'}} - <span v-html="renderMarkdown(paramsDesc[index])"></span></li></ul>
</div> </div>
<div v-else><p>参数: </p></div> <div v-else><p>参数: </p></div>
<slot></slot> <slot></slot>

View File

@@ -16,7 +16,7 @@
<p> <p>
Parameters: Parameters:
</p> </p>
<ul><li class="params" v-for="(item, index) in path.match(/(?<=:).*?(?=\/|$)/g)"><code>{{item.replace('?','')}}</code>, {{(item.includes('?'))?'optional':'required'}} - <span v-html="renderMarkdown(paramsDesc[index])"></span></li></ul> <ul><li class="params" v-for="(item, index) in path.match(/(?<=:).*?(?=\/|$)/g)"><code>{{item.replace(/:|\?|\+|\*/g,'')}}</code>, {{{'?':'optional','*':'zero or more','+':'one or more'}[item[item.length-1]]||'required'}} - <span v-html="renderMarkdown(paramsDesc[index])"></span></li></ul>
</div> </div>
<div v-else><p>Parameters: N/A</p></div> <div v-else><p>Parameters: N/A</p></div>
<slot></slot> <slot></slot>

View File

@@ -421,9 +421,9 @@ ctx.state.data = {
- `path`: route path - `path`: route path
- `:paramsDesc`: route parameters description, in array, supports markdown - `:paramsDesc`: route parameters description, in array, supports markdown
1. parameter description must be in the order of its appearance in route path 1. parameter description must be in the order of its appearance in route path
1. missing description will cause errors in `npm run docs:dev` 2. missing description will cause errors in `npm run docs:dev`
1. `'` `"` must be escaped as `\'` `\"` 3. `'` `"` must be escaped as `\'` `\"`
1. it's redundant to indicate `optional/required` as the component will prepend based on `?` 4. route parameters ending with `?`, `*`, `+`, and a word represent `optional`, `zero or more`, `one or more`, and `mandatory` respectively. They are automatically determined by Vue component and do not need to be explicitly mentioned in the description
- Documentation examples: - Documentation examples:
1. No parameter: 1. No parameter:
@@ -480,9 +480,9 @@ ctx.state.data = {
* * * * * *
1. Please be sure to close the tag of `<Route>`! 2. Please be sure to close the tag of `<Route>`!
1. Execute `npm run format` to lint the code before you commit and open a pull request 3. Execute `npm run format` to lint the code before you commit and open a pull request
## Submit new RSSHub Radar rule ## Submit new RSSHub Radar rule

View File

@@ -12,7 +12,7 @@ pageClass: routes
### App Store/Mac App Store ### App Store/Mac App Store
[#app-store-mac-app-store](/en/program-update.html#app-store-mac-app-store) See [#app-store-mac-app-store](/en/program-update.html#app-store-mac-app-store)
## AutoTrader ## AutoTrader

View File

@@ -70,6 +70,8 @@ Software id
Language Language
| Language | key |
| -------- | --- |
| English | en | | English | en |
| 中文 (简体) | cn | | 中文 (简体) | cn |
| 中文 (繁體) | tw | | 中文 (繁體) | tw |

View File

@@ -424,7 +424,7 @@ ctx.state.data = {
1. 参数说明必须对应其在路径中出现的顺序 1. 参数说明必须对应其在路径中出现的顺序
2. 如缺少说明将会导致`npm run docs:dev`报错 2. 如缺少说明将会导致`npm run docs:dev`报错
3. 说明中的 `'` `"` 必须通过反斜杠转义 `\'` `\"` 3. 说明中的 `'` `"` 必须通过反斜杠转义 `\'` `\"`
4. 不必在说明中标注`可选 / 必选`,组件会根据路由`?`自动判断 4. 路由参数以 `?`、`*`、`+`、普通字符结尾分别表示 “可选”、“零个或多个”、“单个或多个”、“必选”,由组件自动判断,不必在说明中标注
- 文档样例: - 文档样例:
1. 无参数: 1. 无参数: