1# Advanced TS Component Reference Template
2
3## General Writing Instructions
4
5|      | Item            | Writing Instruction                                                        |
6| ---- | ------------------ | ------------------------------------------------------------ |
7| 1    | Customer-oriented mindset| **Stand in the shoes of developers and provide the use cases, parameter selection principles, recommendations/tips, sample code, and anything else that a developer will need to develop the component.**|
8| 2    | Upload path          | Upload markdown files to **docs/en/application-dev/reference/apis-*ExampleKit*-kit/**.<br>Upload images to **docs/en/application-dev/reference/apis-*ExampleKit*-kit/figures**. In addition, reference the image path in the markdown file as follows: **\![]\(figures/exampleImage.jpg)**, **\![]\(figures/exampleImage.png)**, or **\![]\(figures/exampleImage.gif)**.|
9| 3    | File name          | Provide one advanced TS component reference document for each .d.ets file. Name the reference document the same as the .d.ets file name, except by changing the dots (.) to hyphens (-).<br>Example:<br>ohos-arkui-advanced-Chip.md |
10| 4    | Directory update          | After uploading an advanced TS component reference document, update the **Readme-EN.md** file in **docs/en/application-dev/reference/apis-*exampleKit*-kit**.|
11| 5    | Document structure          | - Component description<br>- Initial version description<br>- Modules to import/Usage description<br>- Child components<br>- API description (properties, constants, methods, enums, and custom types)<br>The order in which APIs are described in the document must be consistent with that in which they appear in the code. If some APIs have a logical sequence, pay attention to their sequence in the document.|
12| 6   | Sample code programming language      | Use code blocks to provide sample code, and mark the programming language ts by adding `// xxx.ets` at the beginning of every sample code block.|
13| 7   | Link          | Link format: [Link text]\(Link content)<br>Cross-folder link format: [markdown file name]\(\.\./../xxx/xxx.md). One `../` indicates one upper-level folder.<br>Intra-topic link format: [Interface A<sup>7+</sup>]\(#xxxa7). The text in the intra-topic link must be the same as the title to be linked. In the link, all letters must be in lowercase, and no special character (except the hyphen) or tag is included.|
14
15## Mappings Between .d.ets Tags and Document Fields
16
17Except for @since, document fields mapping to the following tags must be provided under each API.
18
19For a property or interface table, if a tag has the same value for all the items in the table, you can place the tag description above the table. Otherwise, place the tag under **NOTE** for each item.
20
21| .d.ets Tag                    | Description    | Document Field                                                    |
22| ------------------------------ | -------- | ------------------------------------------------------------ |
23| @since                         | Version description| 1. Use the greater-than sign (>) followed by a space to indent the description about the initial version of the component. Unless otherwise marked, all APIs in the component have the same initial version.<br>2. When introducing an API to an existing component, use the `<sup>` tag to mark its initial version. The format is `<sup>versionNumber+</sup>`, for example, `<sup>7+</sup>`.  <br>When introducing a property to an existing component, suffix the `<sup>` tag to the new properties name, for example, `newProperty<sup>7+</sup>`.<br>When introducing a method to an existing component, suffix the `<sup>` tag to the method name, for example, `getSimIccId<sup>7+</sup>`. The same rule applies to new interfaces, classes, and enums.|
24| @deprecated                    | Deprecated description| Do not delete the deprecated content from the document. Instead, suffix `deprecated` as a superscript to the content, and use the greater-than sign (>) to introduce the initial version and deprecated version. If there is no substitute API, provide the substitute solution.<br>Example: abandonmentMethod<sup>(deprecated)</sup><br>> This API is supported since API version 4 and deprecated since API version 7. You are advised to use [newMethod]\(#newmethod) instead.|
25| @FAModelOnly / @StageModelOnly | Model restriction description| **Model restriction**: This API can be used only in the FA model. **Model restriction**: This API can be used only in the stage model.|
26| @form                          | Widget capability description| **Widget capability**: Since API version *x*, this feature is supported in ArkTS widgets.|
27| @systemapi                     | System API description| **System API**: This is a system API.                           |
28| @syscap                        | System capability description| **System capability**: SystemCapability.*A.B*                      |
29| @permission                    | Permission    | 1. If only one permission is required for using the component, use the following format:<br>**Required permissions**: ohos.permission.examplePermission<br>2. If multiple permissions are required for using the component, provide the permissions with **and** or **or** in the following format:<br>**Required permissions**: ohos.permission.examplePermissionA and ohos.permission.examplePermissionB<br>**Required permissions**: ohos.permission.examplePermissionA or ohos.permission.examplePermissionB|
30| @extends                       | Inheritance    | If the tag is carried or the extends relationship exists but the tag is not carried, clearly state the following information: *ExampleA* inherits from *ExampleB* (provide the link of *ExampleB*).|
31
32The following describes the instructions for writing a specific component reference document.
33
34***
35
36# Document Title
37
38> *Writing Instructions*
39>
40> - **Document title**: Use phrases that summarize the component functionalities. Examples: `Button` and `Slider`.
41> - **Heading levels**: Use the document title as the level-1 heading, which is prefixed with `#` followed by a space. Use the functions, classes, interfaces, enums, and types as level-2 headings, which are prefixed with `##` followed by a space. Use the properties and functions under classes as level-3 headings, which are prefixed with `###` followed by a space.
42> - **Initial version description**: Use the greater-than symbol (>) to indent the description about the initial version of the component. Use a line break after **NOTE**.<br>Place the version description after the component description. A component has only one initial version.<br>Use the following sentence: "This component is supported since API version *x*. Newly added APIs will be marked with a superscript to indicate their earliest API version." Change ***x*** to the actual version number.
43
44Describe the component from its functionalities, use cases, and recommendations in this section.
45
46**Example**: @ohos.arkui.advanced.EditableTitleBar (Editable Title Bar)
47
48The editable title bar is a title bar that comes with button icons, typically **Cancel** on the left and **Confirm** on the right, on a multi-select or editing page.
49
50## Modules to Import
51
52> *Writing Instructions*
53>
54> This section is mandatory. Write the modules to import based on the actual conditions. Provide the `import` statement in the form of a code block.<br>**Example:**
55>
56
57```js
58import { EditableTitleBar } from "@ohos.arkui.advanced.EditableTitleBar"
59```
60
61## Child Components
62
63> *Writing Instructions*
64>
65> If there are restrictions on the use of child components, describe them here.
66
67Example: The *ExampleA* component can contain the child component *ExampleB*.
68
69
70## Properties
71
72> *Writing Instructions*
73>
74> This section is mandatory. Specify whether universal properties are supported (with links provided).
75
76Example:
77
78Universal properties are not supported.
79
80## Events
81
82> *Writing Instructions*
83>
84> 1. This section is mandatory. Specify whether universal events are supported (with links provided).
85
86Example:
87
88Universal events are not supported.
89
90## Structs
91
92> *Writing Instructions*
93>
94> - This section is optional. Delete it if there is no property. If there are multiple classes or interfaces, describe them in separate level-2 headings, prefixed with `##` followed by a space.
95> - The writing requirements are the same as those provided in [Methods](js-template.md#methods).
96> - Use the actual struct name as the level-2 heading.
97> - If the struct or its parameters are modified by a decorator, specify the decorator type.
98
99Example:
100
101ComposeListItem({contentItem?: ContentItem, operateItem?: OperateItem})
102
103**Decorator**: \@Component
104
105
106**Parameters**
107
108
109| Name       | Type                       | Mandatory| Decorator| Description                  |
110| ----------- | --------------------------- | ---- | ---------- | ---------------------- |
111| contentItem | [ContentItem](#contentitem) | No  | \@Prop     | Defines the left and middle elements.|
112| operateItem | [OperateItem](#operateitem) | No  | \@Prop     | Defines the right element.        |
113
114## Methods
115
116> *Writing Instructions*
117>
118> - This section is optional. Delete it if there is no method. The writing requirements are the same as those provided in [Methods](js-template.md#methods).
119> - No sample code is required.
120
121
122## Classes
123
124> *Writing Instructions*
125>
126> - This section is optional. Delete it if there is no class. If there are multiple classes, describe them in separate level-2 headings, prefixed with `##` followed by a space.
127> - Use the actual class or interface name as the level-2 heading.
128> - If the class or interface contains both properties and methods, write the properties above the methods. Write their actual names in separate level-3 headings. If the API contains only properties, you do not need to create a level-3 heading. Instead, use a table to display the properties.
129
130### Properties
131
132> *Writing Instructions*
133>
134> This section is optional. Delete it if there is no property. The writing requirements are the same as those provided in [Properties](js-template.md#properties).
135
136### Methods in Classes
137
138> *Writing Instructions*
139>
140> This section is optional. Delete it if there is no method in the class. The writing requirements are the same as those provided in [Methods](js-template.md#methods).
141
142## Enums
143
144> *Writing Instructions*
145>
146> This section is optional. Delete it if there is no enum. The writing requirements are the same as those provided in [Enums](js-template.md#enums).
147
148## Types
149
150> *Writing Instructions*
151>
152> This section is optional. Delete it if there is no type. The writing requirements are the same as those provided in [Types](js-template.md#types).
153
154## Example
155
156Provide the display effect of the example.
157
158> *Writing Instructions*
159>
160> - This section is mandatory. Use a level-2 or level-3 heading, and provide sample codes and figures under the heading.
161> - Use multiple level-3 headings to present the function of a component or module one by one, if the functions are complex.
162>
163> ```tsx
164> // This section is mandatory.
165>
166> // Check all sample code provided in the example.
167> // Minor errors such as missing symbols and variable inconsistency are unacceptable.
168> // Declare all variables that are used.
169> // Mark the programming language of the sample code.
170>
171> // Write an actual case that can be easily used, rather than the parameter names themselves. Use comments to describe the content that are not user-defined.
172> // Example: var result = xxx.createExample(parameterOne); // parameterOne is automatically obtained by scanning.
173>
174> // The layout of the image must be clear, the color must be simple and elegant, and the image must be copyrighted.
175>
176> // Provide clear and concise comments in the following typical scenarios:
177> // 1. The meaning of a variable name or the code logic is not self-explanatory.
178> // 2. A complex algorithm or special syntax is involved.
179> ```
180
181Example:
182
183```ts
184// xxx.ets
185@Entry
186@Component
187struct CheckboxExample {
188  build() {
189    Row() {
190      // Generate a check box that is selected by default and can be clicked to display its status.
191      Checkbox({name: 'checkbox1',  group: 'checkboxGroup'})
192        .select(true)
193        .selectedColor(0xed6f21)
194        .onChange((value: boolean) => {
195          console.info('Checkbox1 change is'+ value)
196        })
197      // Generate a check box that is not selected by default and can be clicked to display its status.
198      Checkbox({name: 'checkbox2',  group: 'checkboxGroup'})
199        .select(false)
200        .selectedColor(0x39a2db)
201        .onChange((value: boolean) => {
202          console.info('Checkbox2 change is'+ value)
203        })
204    }
205  }
206}
207```
208<!--no_check-->
209