-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
template.eta
103 lines (73 loc) · 2.86 KB
/
template.eta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<% if (it.hasDocusaurusHeader) { %>
---
id: <%= it.command %>
title: <%= it.command %>
<% if (it.customEditUrl) { %>custom_edit_url: <%= it.customEditUrl %><% } %>
---
<% } else if (it.hasHeader) { %>
## <%= it.command %>
<% } %>
<%= it.description %>
<% if (it.deprecated) { %>
:::caution
<%= it.deprecated %>
:::
<% } %>
<% if (it.alternativeCommands && it.alternativeCommands.length) { %>
:::info
This protocol command is embedded in the following convenient method<%= it.alternativeCommands.length > 1 ? 's' : '' %>: <%= it.alternativeCommands.map((command) => `[${command.split('/').pop()}}](/docs/api/${command})`).join(', ') %>. It is recommended to use <%= it.alternativeCommands.length > 1 ? 'these commands' : 'this command' %> instead.
:::
<% } %>
##### Usage
```js
<% if (it.isElementScope) { %>
$(selector).<%= it.command %>(<%= it.paramString %>)
<% } else if (it.isMockScope) { %>
mock.<%= it.command %>(<%= it.paramString %>)
<% } else { %>
<%= it.isMobile ? 'driver' : 'browser' %>.<%= it.command %>(<%= it.paramString %>)
<% } %>
```
<% if (it.paramTags.length) { %>
##### Parameters
| Name | Type | Details |
| ---- | ---- | ------- |
<% it.paramTags.forEach((paramTag) => { %>
| <code><var><%= paramTag.name %></var></code><% if ((!paramTag.required && typeof paramTag.optional === 'undefined') || paramTag.optional) { %><br /><span className="label labelWarning">optional</span><% } %> | <%= Array.isArray(paramTag.types) ? paramTag.types.map((type) => `<code>${type.replace(/>/g, ">").replace(/</g, "<")}</code>`).join(', ') : paramTag.type.split('|').join(', ').replace('(', '').replace(')', '') %> | <%= paramTag.description %> |
<% }) %>
<% } %>
<%
const allExamples = [...it.examples, ...it.exampleReferences];
if (allExamples.length) {
%>
##### Example<%= allExamples.length > 1 ? 's' : '' %>
<% it.exampleReferences.forEach(function(ref) {
const filename = it.path.basename(ref.split('#')[0]);
const ext = it.path.extname(filename).slice(1);
%>
```<%= ext %> reference title="<%= filename %>" useHTTPS
<%= ref %>
```
<% }); %>
<% it.examples.forEach(function(example) { %>
```<%= example.format %><% if (example.file) { %> title="<%= example.file %>"<%}%>
<% = example.code %>
```
<% }); %>
<% } %>
<% if (it.returns) { %>
##### Returns
- **<<%= it.returns.type %>> <code><var><%= it.returns.name %></var></code>:** <%= it.returns.description %>
<% } %>
<% if (it.throwsTags.length) { %>
##### Throws
<% it.throwsTags.forEach(function(throwsTag) { %>- **<%= throwsTag.type %>**: <%= throwsTag.description %><% }) %>
<% } %>
<% if (it.support && Object.keys(it.support).length) { %>
##### Support
<% Object.keys(it.support).forEach(function(platform) { %>
![Support for <%= Object.keys(it.support[platform]).map(function(driver) {
return driver + " (" + it.support[platform][driver] + ")";
}).join(", ") %>](/img/icons/<%= platform %>.svg)
<% }) %>
<% } %>