Skip to content

Commit

Permalink
doc add type (#1150)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hellertang authored Jul 12, 2022
1 parent 017f37f commit 1b9445c
Show file tree
Hide file tree
Showing 390 changed files with 3,586 additions and 3,532 deletions.
58 changes: 56 additions & 2 deletions gendoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
}
if v.Required {
opt := "Required"
sub := getSubStruct(0, k, v)
subStruct = append(subStruct, sub...)
// get type
res := parseSubtract(v, sub)
valueType := parseType(v)
if res == "" {
opt += fmt.Sprintf(", %s", valueType)
} else {
opt += fmt.Sprintf(", %s: [`%s`]", valueType, res)
}
if v.ForceNew {
opt += ", ForceNew"
}
Expand All @@ -210,9 +220,18 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
v.Description = fmt.Sprintf("%s %s", v.Deprecated, v.Description)
}
requiredArgs = append(requiredArgs, fmt.Sprintf("* `%s` - (%s) %s", k, opt, v.Description))
subStruct = append(subStruct, getSubStruct(0, k, v)...)
} else if v.Optional {
opt := "Optional"
sub := getSubStruct(0, k, v)
subStruct = append(subStruct, sub...)
// get type
res := parseSubtract(v, sub)
valueType := parseType(v)
if res == "" {
opt += fmt.Sprintf(", %s", valueType)
} else {
opt += fmt.Sprintf(", %s: [`%s`]", valueType, res)
}
if v.ForceNew {
opt += ", ForceNew"
}
Expand All @@ -221,7 +240,6 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
v.Description = fmt.Sprintf("%s %s", v.Deprecated, v.Description)
}
optionalArgs = append(optionalArgs, fmt.Sprintf("* `%s` - (%s) %s", k, opt, v.Description))
subStruct = append(subStruct, getSubStruct(0, k, v)...)
} else {
attrs := getAttributes(0, k, v)
if len(attrs) > 0 {
Expand Down Expand Up @@ -348,12 +366,16 @@ func getSubStruct(step int, k string, v *schema.Schema) []string {
for kk, vv := range v.Elem.(*schema.Resource).Schema {
if vv.Required {
opt := "Required"
valueType := parseType(vv)
opt += fmt.Sprintf(", %s", valueType)
if vv.ForceNew {
opt += ", ForceNew"
}
requiredArgs = append(requiredArgs, fmt.Sprintf("* `%s` - (%s) %s", kk, opt, vv.Description))
} else if vv.Optional {
opt := "Optional"
valueType := parseType(vv)
opt += fmt.Sprintf(", %s", valueType)
if vv.ForceNew {
opt += ", ForceNew"
}
Expand Down Expand Up @@ -451,3 +473,35 @@ func message(msg string, v ...interface{}) {
color.White(fmt.Sprintf(msg, v...))
}
}

func parseType(v *schema.Schema) string {
res := ""
switch v.Type {
case schema.TypeBool:
res = "Bool"
case schema.TypeInt:
res = "Int"
case schema.TypeFloat:
res = "Float64"
case schema.TypeString:
res = "String"
case schema.TypeList:
res = "List"
case schema.TypeMap:
res = "Map"
case schema.TypeSet:
res = "Set"
}
return res
}

func parseSubtract(v *schema.Schema, subStruct []string) string {
res := ""
if v.Type == schema.TypeSet || v.Type == schema.TypeList {
if len(subStruct) == 0 {
vv := v.Elem.(*schema.Schema)
res = parseType(vv)
}
}
return res
}
6 changes: 3 additions & 3 deletions website/docs/d/address_template_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data "tencentcloud_address_template_groups" "name" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/address_templates.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data "tencentcloud_address_templates" "name" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/api_gateway_api_keys.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ data "tencentcloud_api_gateway_api_keys" "id" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/api_gateway_apis.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ data "tencentcloud_api_gateway_apis" "name" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/api_gateway_customer_domains.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ data "tencentcloud_api_gateway_customer_domains" "id" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/api_gateway_ip_strategies.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ data "tencentcloud_api_gateway_ip_strategies" "name" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/api_gateway_services.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ data "tencentcloud_api_gateway_services" "id" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/api_gateway_throttling_apis.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ data "tencentcloud_api_gateway_throttling_apis" "foo" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/api_gateway_throttling_services.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ data "tencentcloud_api_gateway_throttling_services" "id" {

The following arguments are supported:

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

## Attributes Reference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ data "tencentcloud_api_gateway_usage_plan_environments" "environment_test" {

The following arguments are supported:

* `usage_plan_id` - (Required) ID of the usage plan to be queried.
* `bind_type` - (Optional) Binding type. Valid values: `API`, `SERVICE`. Default value: `SERVICE`.
* `result_output_file` - (Optional) Used to save results.
* `usage_plan_id` - (Required, String) ID of the usage plan to be queried.
* `bind_type` - (Optional, String) Binding type. Valid values: `API`, `SERVICE`. Default value: `SERVICE`.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/api_gateway_usage_plans.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ data "tencentcloud_api_gateway_usage_plans" "id" {

The following arguments are supported:

* `result_output_file` - (Optional) Used to save results.
* `usage_plan_id` - (Optional) ID of the usage plan.
* `usage_plan_name` - (Optional) Name of the usage plan.
* `result_output_file` - (Optional, String) Used to save results.
* `usage_plan_id` - (Optional, String) ID of the usage plan.
* `usage_plan_name` - (Optional, String) Name of the usage plan.

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/as_scaling_configs.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ data "tencentcloud_as_scaling_configs" "as_configs" {

The following arguments are supported:

* `configuration_id` - (Optional) Launch configuration ID.
* `configuration_name` - (Optional) Launch configuration name.
* `result_output_file` - (Optional) Used to save results.
* `configuration_id` - (Optional, String) Launch configuration ID.
* `configuration_name` - (Optional, String) Launch configuration name.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
10 changes: 5 additions & 5 deletions website/docs/d/as_scaling_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ data "tencentcloud_as_scaling_groups" "as_scaling_groups" {

The following arguments are supported:

* `configuration_id` - (Optional) Filter results by launch configuration ID.
* `result_output_file` - (Optional) Used to save results.
* `scaling_group_id` - (Optional) A specified scaling group ID used to query.
* `scaling_group_name` - (Optional) A scaling group name used to query.
* `tags` - (Optional) Tags used to query.
* `configuration_id` - (Optional, String) Filter results by launch configuration ID.
* `result_output_file` - (Optional, String) Used to save results.
* `scaling_group_id` - (Optional, String) A specified scaling group ID used to query.
* `scaling_group_name` - (Optional, String) A scaling group name used to query.
* `tags` - (Optional, Map) Tags used to query.

## Attributes Reference

Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/as_scaling_policies.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ data "tencentcloud_as_scaling_policies" "as_scaling_policies" {

The following arguments are supported:

* `policy_name` - (Optional) Scaling policy name.
* `result_output_file` - (Optional) Used to save results.
* `scaling_group_id` - (Optional) Scaling group ID.
* `scaling_policy_id` - (Optional) Scaling policy ID.
* `policy_name` - (Optional, String) Scaling policy name.
* `result_output_file` - (Optional, String) Used to save results.
* `scaling_group_id` - (Optional, String) Scaling group ID.
* `scaling_policy_id` - (Optional, String) Scaling policy ID.

## Attributes Reference

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/audit_cos_regions.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data "tencentcloud_audit_cos_regions" "foo" {

The following arguments are supported:

* `result_output_file` - (Optional) Used to save results.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/audit_key_alias.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ data "tencentcloud_audit_key_alias" "all" {

The following arguments are supported:

* `region` - (Required) Region.
* `result_output_file` - (Optional) Used to save results.
* `region` - (Required, String) Region.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/audits.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ data "tencentcloud_audits" "audits" {

The following arguments are supported:

* `name` - (Optional) Name of the audits.
* `result_output_file` - (Optional) Used to save results.
* `name` - (Optional, String) Name of the audits.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/availability_regions.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data "tencentcloud_availability_regions" "my_favourite_region" {

The following arguments are supported:

* `include_unavailable` - (Optional) A bool variable indicates that the query will include `UNAVAILABLE` regions.
* `name` - (Optional) When specified, only the region with the exactly name match will be returned. `default` value means it consistent with the provider region.
* `result_output_file` - (Optional) Used to save results.
* `include_unavailable` - (Optional, Bool) A bool variable indicates that the query will include `UNAVAILABLE` regions.
* `name` - (Optional, String) When specified, only the region with the exactly name match will be returned. `default` value means it consistent with the provider region.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/availability_zones.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data "tencentcloud_availability_zones" "my_favourite_zone" {

The following arguments are supported:

* `include_unavailable` - (Optional) A bool variable indicates that the query will include `UNAVAILABLE` zones.
* `name` - (Optional) When specified, only the zone with the exactly name match will be returned.
* `result_output_file` - (Optional) Used to save results.
* `include_unavailable` - (Optional, Bool) A bool variable indicates that the query will include `UNAVAILABLE` zones.
* `name` - (Optional, String) When specified, only the zone with the exactly name match will be returned.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/availability_zones_by_product.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ data "tencentcloud_availability_zones_by_product" "all" {

The following arguments are supported:

* `product` - (Required) A string variable indicates that the query will use product information.
* `include_unavailable` - (Optional) A bool variable indicates that the query will include `UNAVAILABLE` zones.
* `name` - (Optional) When specified, only the zone with the exactly name match will be returned.
* `result_output_file` - (Optional) Used to save results.
* `product` - (Required, String) A string variable indicates that the query will use product information.
* `include_unavailable` - (Optional, Bool) A bool variable indicates that the query will include `UNAVAILABLE` zones.
* `name` - (Optional, String) When specified, only the zone with the exactly name match will be returned.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/cam_group_memberships.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ data "tencentcloud_cam_group_memberships" "foo" {

The following arguments are supported:

* `group_id` - (Optional) ID of CAM group to be queried.
* `result_output_file` - (Optional) Used to save results.
* `group_id` - (Optional, String) ID of CAM group to be queried.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
10 changes: 5 additions & 5 deletions website/docs/d/cam_group_policy_attachments.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ data "tencentcloud_cam_group_policy_attachments" "bar" {

The following arguments are supported:

* `group_id` - (Required) ID of the attached CAM group to be queried.
* `create_mode` - (Optional) Mode of creation of the CAM user policy attachment. 1 means the cam policy attachment is created by production, and the others indicate syntax strategy ways.
* `policy_id` - (Optional) ID of CAM policy to be queried.
* `policy_type` - (Optional) Type of the policy strategy. 'User' means customer strategy and 'QCS' means preset strategy.
* `result_output_file` - (Optional) Used to save results.
* `group_id` - (Required, String) ID of the attached CAM group to be queried.
* `create_mode` - (Optional, Int) Mode of creation of the CAM user policy attachment. 1 means the cam policy attachment is created by production, and the others indicate syntax strategy ways.
* `policy_id` - (Optional, String) ID of CAM policy to be queried.
* `policy_type` - (Optional, String) Type of the policy strategy. 'User' means customer strategy and 'QCS' means preset strategy.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
8 changes: 4 additions & 4 deletions website/docs/d/cam_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ data "tencentcloud_cam_groups" "bar" {

The following arguments are supported:

* `group_id` - (Optional) ID of CAM group to be queried.
* `name` - (Optional) Name of the CAM group to be queried.
* `remark` - (Optional) Description of the cam group to be queried.
* `result_output_file` - (Optional) Used to save results.
* `group_id` - (Optional, String) ID of CAM group to be queried.
* `name` - (Optional, String) Name of the CAM group to be queried.
* `remark` - (Optional, String) Description of the cam group to be queried.
* `result_output_file` - (Optional, String) Used to save results.

## Attributes Reference

Expand Down
Loading

0 comments on commit 1b9445c

Please sign in to comment.