Skip to content

Commit 1b9445c

Browse files
authored
doc add type (#1150)
* doc add type * set/list add detail type * set/list add detail type * set/list add detail type * set/list add detail type * fix gendoc bug
1 parent 017f37f commit 1b9445c

File tree

390 files changed

+3586
-3532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

390 files changed

+3586
-3532
lines changed

gendoc/main.go

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
202202
}
203203
if v.Required {
204204
opt := "Required"
205+
sub := getSubStruct(0, k, v)
206+
subStruct = append(subStruct, sub...)
207+
// get type
208+
res := parseSubtract(v, sub)
209+
valueType := parseType(v)
210+
if res == "" {
211+
opt += fmt.Sprintf(", %s", valueType)
212+
} else {
213+
opt += fmt.Sprintf(", %s: [`%s`]", valueType, res)
214+
}
205215
if v.ForceNew {
206216
opt += ", ForceNew"
207217
}
@@ -210,9 +220,18 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
210220
v.Description = fmt.Sprintf("%s %s", v.Deprecated, v.Description)
211221
}
212222
requiredArgs = append(requiredArgs, fmt.Sprintf("* `%s` - (%s) %s", k, opt, v.Description))
213-
subStruct = append(subStruct, getSubStruct(0, k, v)...)
214223
} else if v.Optional {
215224
opt := "Optional"
225+
sub := getSubStruct(0, k, v)
226+
subStruct = append(subStruct, sub...)
227+
// get type
228+
res := parseSubtract(v, sub)
229+
valueType := parseType(v)
230+
if res == "" {
231+
opt += fmt.Sprintf(", %s", valueType)
232+
} else {
233+
opt += fmt.Sprintf(", %s: [`%s`]", valueType, res)
234+
}
216235
if v.ForceNew {
217236
opt += ", ForceNew"
218237
}
@@ -221,7 +240,6 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
221240
v.Description = fmt.Sprintf("%s %s", v.Deprecated, v.Description)
222241
}
223242
optionalArgs = append(optionalArgs, fmt.Sprintf("* `%s` - (%s) %s", k, opt, v.Description))
224-
subStruct = append(subStruct, getSubStruct(0, k, v)...)
225243
} else {
226244
attrs := getAttributes(0, k, v)
227245
if len(attrs) > 0 {
@@ -348,12 +366,16 @@ func getSubStruct(step int, k string, v *schema.Schema) []string {
348366
for kk, vv := range v.Elem.(*schema.Resource).Schema {
349367
if vv.Required {
350368
opt := "Required"
369+
valueType := parseType(vv)
370+
opt += fmt.Sprintf(", %s", valueType)
351371
if vv.ForceNew {
352372
opt += ", ForceNew"
353373
}
354374
requiredArgs = append(requiredArgs, fmt.Sprintf("* `%s` - (%s) %s", kk, opt, vv.Description))
355375
} else if vv.Optional {
356376
opt := "Optional"
377+
valueType := parseType(vv)
378+
opt += fmt.Sprintf(", %s", valueType)
357379
if vv.ForceNew {
358380
opt += ", ForceNew"
359381
}
@@ -451,3 +473,35 @@ func message(msg string, v ...interface{}) {
451473
color.White(fmt.Sprintf(msg, v...))
452474
}
453475
}
476+
477+
func parseType(v *schema.Schema) string {
478+
res := ""
479+
switch v.Type {
480+
case schema.TypeBool:
481+
res = "Bool"
482+
case schema.TypeInt:
483+
res = "Int"
484+
case schema.TypeFloat:
485+
res = "Float64"
486+
case schema.TypeString:
487+
res = "String"
488+
case schema.TypeList:
489+
res = "List"
490+
case schema.TypeMap:
491+
res = "Map"
492+
case schema.TypeSet:
493+
res = "Set"
494+
}
495+
return res
496+
}
497+
498+
func parseSubtract(v *schema.Schema, subStruct []string) string {
499+
res := ""
500+
if v.Type == schema.TypeSet || v.Type == schema.TypeList {
501+
if len(subStruct) == 0 {
502+
vv := v.Elem.(*schema.Schema)
503+
res = parseType(vv)
504+
}
505+
}
506+
return res
507+
}

website/docs/d/address_template_groups.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ data "tencentcloud_address_template_groups" "name" {
2323

2424
The following arguments are supported:
2525

26-
* `id` - (Optional) Id of the address template group to query.
27-
* `name` - (Optional) Name of the address template group to query.
28-
* `result_output_file` - (Optional) Used to save results.
26+
* `id` - (Optional, String) Id of the address template group to query.
27+
* `name` - (Optional, String) Name of the address template group to query.
28+
* `result_output_file` - (Optional, String) Used to save results.
2929

3030
## Attributes Reference
3131

website/docs/d/address_templates.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ data "tencentcloud_address_templates" "name" {
2323

2424
The following arguments are supported:
2525

26-
* `id` - (Optional) ID of the address template to query.
27-
* `name` - (Optional) Name of the address template to query.
28-
* `result_output_file` - (Optional) Used to save results.
26+
* `id` - (Optional, String) ID of the address template to query.
27+
* `name` - (Optional, String) Name of the address template to query.
28+
* `result_output_file` - (Optional, String) Used to save results.
2929

3030
## Attributes Reference
3131

website/docs/d/api_gateway_api_keys.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ data "tencentcloud_api_gateway_api_keys" "id" {
3232

3333
The following arguments are supported:
3434

35-
* `api_key_id` - (Optional) Created API key ID, this field is exactly the same as ID.
36-
* `result_output_file` - (Optional) Used to save results.
37-
* `secret_name` - (Optional) Custom key name.
35+
* `api_key_id` - (Optional, String) Created API key ID, this field is exactly the same as ID.
36+
* `result_output_file` - (Optional, String) Used to save results.
37+
* `secret_name` - (Optional, String) Custom key name.
3838

3939
## Attributes Reference
4040

website/docs/d/api_gateway_apis.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ data "tencentcloud_api_gateway_apis" "name" {
5656

5757
The following arguments are supported:
5858

59-
* `service_id` - (Required) Service ID for query.
60-
* `api_id` - (Optional) Created API ID.
61-
* `api_name` - (Optional) Custom API name.
62-
* `result_output_file` - (Optional) Used to save results.
59+
* `service_id` - (Required, String) Service ID for query.
60+
* `api_id` - (Optional, String) Created API ID.
61+
* `api_name` - (Optional, String) Custom API name.
62+
* `result_output_file` - (Optional, String) Used to save results.
6363

6464
## Attributes Reference
6565

website/docs/d/api_gateway_customer_domains.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ data "tencentcloud_api_gateway_customer_domains" "id" {
3333

3434
The following arguments are supported:
3535

36-
* `service_id` - (Required) The service ID.
37-
* `result_output_file` - (Optional) Used to save results.
36+
* `service_id` - (Required, String) The service ID.
37+
* `result_output_file` - (Optional, String) Used to save results.
3838

3939
## Attributes Reference
4040

website/docs/d/api_gateway_ip_strategies.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ data "tencentcloud_api_gateway_ip_strategies" "name" {
4343

4444
The following arguments are supported:
4545

46-
* `service_id` - (Required) The service ID to be queried.
47-
* `result_output_file` - (Optional) Used to save results.
48-
* `strategy_name` - (Optional) Name of IP policy.
46+
* `service_id` - (Required, String) The service ID to be queried.
47+
* `result_output_file` - (Optional, String) Used to save results.
48+
* `strategy_name` - (Optional, String) Name of IP policy.
4949

5050
## Attributes Reference
5151

website/docs/d/api_gateway_services.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ data "tencentcloud_api_gateway_services" "id" {
3535

3636
The following arguments are supported:
3737

38-
* `result_output_file` - (Optional) Used to save results.
39-
* `service_id` - (Optional) Service ID for query.
40-
* `service_name` - (Optional) Service name for query.
38+
* `result_output_file` - (Optional, String) Used to save results.
39+
* `service_id` - (Optional, String) Service ID for query.
40+
* `service_name` - (Optional, String) Service name for query.
4141

4242
## Attributes Reference
4343

website/docs/d/api_gateway_throttling_apis.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ data "tencentcloud_api_gateway_throttling_apis" "foo" {
7474

7575
The following arguments are supported:
7676

77-
* `environment_names` - (Optional) Environment list.
78-
* `result_output_file` - (Optional) Used to save results.
79-
* `service_id` - (Optional) Unique service ID of API.
77+
* `environment_names` - (Optional, List: [`String`]) Environment list.
78+
* `result_output_file` - (Optional, String) Used to save results.
79+
* `service_id` - (Optional, String) Unique service ID of API.
8080

8181
## Attributes Reference
8282

website/docs/d/api_gateway_throttling_services.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ data "tencentcloud_api_gateway_throttling_services" "id" {
3434

3535
The following arguments are supported:
3636

37-
* `result_output_file` - (Optional) Used to save results.
38-
* `service_id` - (Optional) Service ID for query.
37+
* `result_output_file` - (Optional, String) Used to save results.
38+
* `service_id` - (Optional, String) Service ID for query.
3939

4040
## Attributes Reference
4141

0 commit comments

Comments
 (0)