Skip to content

Commit 61d1004

Browse files
therveci.datadog-api-spec
andauthored
Improve docstring rendering (#677)
* Produce better docstrings Remove the HTML escape handled by typedoc and indent data correctly. * Remove from type as well. * Remove empty lines * Do models as well * pre-commit fixes Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent bc86867 commit 61d1004

File tree

208 files changed

+1691
-588
lines changed

Some content is hidden

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

208 files changed

+1691
-588
lines changed

.generator/src/generator/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli(input, output):
4545
env.filters["form_parameter"] = openapi.form_parameter
4646
env.filters["untitle_case"] = formatter.untitle_case
4747
env.filters["response_type"] = openapi.get_type_for_response
48-
env.filters["escape_html"] = formatter.escape_html
48+
env.filters["docstring"] = formatter.docstring
4949

5050
env.globals["get_references_for_model"] = openapi.get_references_for_model
5151
env.globals["package_name"] = package_name

.generator/src/generator/formatter.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@
7272
"yield",
7373
}
7474

75-
HTML_ESCAPE_CHARACTERS = {
76-
"&": "&amp;",
77-
"'": "&#39;",
78-
">": "&gt;",
79-
"<": "&lt;",
80-
'"': "&quot;",
81-
"`": "&#x60;",
82-
"=": "&#x3D;",
83-
"\\": "\\\\",
84-
}
85-
8675
with (pathlib.Path(__file__).parent / "replacement.json").open() as f:
8776
EDGE_CASES = json.load(f)
8877

@@ -397,11 +386,11 @@ def format_data_with_schema_dict(
397386
return f"{{\n{parameters}}}"
398387

399388

400-
def escape_html(text):
389+
def docstring(text, indent=3):
401390
if not text:
402391
return ""
403-
text = " ".join(text.splitlines())
404-
return "".join(HTML_ESCAPE_CHARACTERS.get(c, c) for c in text)
392+
blank = " " * indent
393+
return "\n".join("{}* {}".format(blank, line) for line in text.splitlines())
405394

406395

407396
def simple_type(schema):

.generator/src/generator/templates/api/api.j2

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,20 @@ export interface {{ className }}{{ operation.operationId }}Request {
224224
{%- for name, parameter in requiredParams %}
225225
{%- set parameterType = get_type_for_parameter(parameter) %}
226226
/**
227-
* {{ parameter.description|escape_html }}
228-
* @type {{ parameterType|escape_html }}
227+
{%- if parameter.description %}
228+
{{ parameter.description|docstring }}
229+
{%- endif %}
230+
* @type {{ parameterType }}
229231
*/
230232
{{ name|attribute_name }}{%- if not parameter.required %}?{%-endif %}: {{ parameterType }}
231233
{%-endfor %}
232234
{%- for name, parameter in optionalParams %}
233235
{%- set parameterType = get_type_for_parameter(parameter) %}
234236
/**
235-
* {{ parameter.description|escape_html }}
236-
* @type {{ parameterType|escape_html }}
237+
{%- if parameter.description %}
238+
{{ parameter.description|docstring }}
239+
{%- endif %}
240+
* @type {{ parameterType }}
237241
*/
238242
{{ name|attribute_name }}{%- if not parameter.required %}?{%-endif %}: {{ parameterType }}
239243
{%-endfor %}
@@ -261,7 +265,7 @@ export class {{ className }} {
261265

262266
/**
263267
{%- if operation.description %}
264-
* {{ operation.description|replace("\n", " ") }}
268+
{{ operation.description|docstring }}
265269
{%- endif %}
266270
* @param param The request object
267271
*/

.generator/src/generator/templates/model/model.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { AttributeTypeMap{%- if "oneOf" in model %}, UnparsedObject{% endif %} }
1414

1515
{% if "description" in model %}
1616
/**
17-
* {{ model.description|replace("\n", " ") }}
17+
{{ model.description|docstring(indent=1) }}
1818
*/
1919
{% endif %}
2020
{%- if "enum" not in model and "oneOf" not in model -%}
@@ -24,7 +24,7 @@ export class {{ name }} {
2424
{%- set isNullable = schema.nullable %}
2525
{%- if schema.description %}
2626
/**
27-
* {{ schema.description|replace("\n", " ") }}
27+
{{ schema.description|docstring }}
2828
*/
2929
{%- endif %}
3030
"{{ attr|attribute_name }}"{%- if not isRequired %}?{%- endif %}: {{ type_to_typescript(schema) }}{%- if isRequired and isNullable %}|null{%- endif %};

packages/datadog-api-client-v1/apis/AWSIntegrationApi.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,15 +1009,18 @@ export interface AWSIntegrationApiCreateAWSAccountRequest {
10091009

10101010
export interface AWSIntegrationApiCreateAWSTagFilterRequest {
10111011
/**
1012-
* Set an AWS tag filter using an &#x60;aws_account_identifier&#x60;, &#x60;namespace&#x60;, and filtering string. Namespace options are &#x60;application_elb&#x60;, &#x60;elb&#x60;, &#x60;lambda&#x60;, &#x60;network_elb&#x60;, &#x60;rds&#x60;, &#x60;sqs&#x60;, and &#x60;custom&#x60;.
1012+
* Set an AWS tag filter using an `aws_account_identifier`, `namespace`, and filtering string.
1013+
* Namespace options are `application_elb`, `elb`, `lambda`, `network_elb`, `rds`, `sqs`, and `custom`.
10131014
* @type AWSTagFilterCreateRequest
10141015
*/
10151016
body: AWSTagFilterCreateRequest;
10161017
}
10171018

10181019
export interface AWSIntegrationApiCreateNewAWSExternalIDRequest {
10191020
/**
1020-
* Your Datadog role delegation name. For more information about your AWS account Role name, see the [Datadog AWS integration configuration info](https://docs.datadoghq.com/integrations/amazon_web_services/#setup).
1021+
* Your Datadog role delegation name.
1022+
* For more information about your AWS account Role name,
1023+
* see the [Datadog AWS integration configuration info](https://docs.datadoghq.com/integrations/amazon_web_services/#setup).
10211024
* @type AWSAccount
10221025
*/
10231026
body: AWSAccount;
@@ -1033,15 +1036,15 @@ export interface AWSIntegrationApiDeleteAWSAccountRequest {
10331036

10341037
export interface AWSIntegrationApiDeleteAWSTagFilterRequest {
10351038
/**
1036-
* Delete a tag filtering entry for a given AWS account and &#x60;dd-aws&#x60; namespace.
1039+
* Delete a tag filtering entry for a given AWS account and `dd-aws` namespace.
10371040
* @type AWSTagFilterDeleteRequest
10381041
*/
10391042
body: AWSTagFilterDeleteRequest;
10401043
}
10411044

10421045
export interface AWSIntegrationApiListAWSAccountsRequest {
10431046
/**
1044-
* Only return AWS accounts that matches this &#x60;account_id&#x60;.
1047+
* Only return AWS accounts that matches this `account_id`.
10451048
* @type string
10461049
*/
10471050
accountId?: string;
@@ -1051,15 +1054,15 @@ export interface AWSIntegrationApiListAWSAccountsRequest {
10511054
*/
10521055
roleName?: string;
10531056
/**
1054-
* Only return AWS accounts that matches this &#x60;access_key_id&#x60;.
1057+
* Only return AWS accounts that matches this `access_key_id`.
10551058
* @type string
10561059
*/
10571060
accessKeyId?: string;
10581061
}
10591062

10601063
export interface AWSIntegrationApiListAWSTagFiltersRequest {
10611064
/**
1062-
* Only return AWS filters that matches this &#x60;account_id&#x60;.
1065+
* Only return AWS filters that matches this `account_id`.
10631066
* @type string
10641067
*/
10651068
accountId: string;
@@ -1072,17 +1075,19 @@ export interface AWSIntegrationApiUpdateAWSAccountRequest {
10721075
*/
10731076
body: AWSAccount;
10741077
/**
1075-
* Only return AWS accounts that matches this &#x60;account_id&#x60;.
1078+
* Only return AWS accounts that matches this `account_id`.
10761079
* @type string
10771080
*/
10781081
accountId?: string;
10791082
/**
1080-
* Only return AWS accounts that match this &#x60;role_name&#x60;. Required if &#x60;account_id&#x60; is specified.
1083+
* Only return AWS accounts that match this `role_name`.
1084+
* Required if `account_id` is specified.
10811085
* @type string
10821086
*/
10831087
roleName?: string;
10841088
/**
1085-
* Only return AWS accounts that matches this &#x60;access_key_id&#x60;. Required if none of the other two options are specified.
1089+
* Only return AWS accounts that matches this `access_key_id`.
1090+
* Required if none of the other two options are specified.
10861091
* @type string
10871092
*/
10881093
accessKeyId?: string;
@@ -1106,7 +1111,10 @@ export class AWSIntegrationApi {
11061111
}
11071112

11081113
/**
1109-
* Create a Datadog-Amazon Web Services integration. Using the `POST` method updates your integration configuration by adding your new configuration to the existing one in your Datadog organization. A unique AWS Account ID for role based authentication.
1114+
* Create a Datadog-Amazon Web Services integration.
1115+
* Using the `POST` method updates your integration configuration
1116+
* by adding your new configuration to the existing one in your Datadog organization.
1117+
* A unique AWS Account ID for role based authentication.
11101118
* @param param The request object
11111119
*/
11121120
public createAWSAccount(

packages/datadog-api-client-v1/apis/AWSLogsIntegrationApi.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,14 @@ export class AWSLogsIntegrationApi {
779779
}
780780

781781
/**
782-
* Test if permissions are present to add a log-forwarding triggers for the given services and AWS account. The input is the same as for Enable an AWS service log collection. Subsequent requests will always repeat the above, so this endpoint can be polled intermittently instead of blocking. - Returns a status of 'created' when it's checking if the Lambda exists in the account. - Returns a status of 'waiting' while checking. - Returns a status of 'checked and ok' if the Lambda exists. - Returns a status of 'error' if the Lambda does not exist.
782+
* Test if permissions are present to add a log-forwarding triggers for the given services and AWS account. The input
783+
* is the same as for Enable an AWS service log collection. Subsequent requests will always repeat the above, so this
784+
* endpoint can be polled intermittently instead of blocking.
785+
*
786+
* - Returns a status of 'created' when it's checking if the Lambda exists in the account.
787+
* - Returns a status of 'waiting' while checking.
788+
* - Returns a status of 'checked and ok' if the Lambda exists.
789+
* - Returns a status of 'error' if the Lambda does not exist.
783790
* @param param The request object
784791
*/
785792
public checkAWSLogsLambdaAsync(
@@ -802,7 +809,16 @@ export class AWSLogsIntegrationApi {
802809
}
803810

804811
/**
805-
* Test if permissions are present to add log-forwarding triggers for the given services and AWS account. Input is the same as for `EnableAWSLogServices`. Done async, so can be repeatedly polled in a non-blocking fashion until the async request completes. - Returns a status of `created` when it's checking if the permissions exists in the AWS account. - Returns a status of `waiting` while checking. - Returns a status of `checked and ok` if the Lambda exists. - Returns a status of `error` if the Lambda does not exist.
812+
* Test if permissions are present to add log-forwarding triggers for the
813+
* given services and AWS account. Input is the same as for `EnableAWSLogServices`.
814+
* Done async, so can be repeatedly polled in a non-blocking fashion until
815+
* the async request completes.
816+
*
817+
* - Returns a status of `created` when it's checking if the permissions exists
818+
* in the AWS account.
819+
* - Returns a status of `waiting` while checking.
820+
* - Returns a status of `checked and ok` if the Lambda exists.
821+
* - Returns a status of `error` if the Lambda does not exist.
806822
* @param param The request object
807823
*/
808824
public checkAWSLogsServicesAsync(

packages/datadog-api-client-v1/apis/AzureIntegrationApi.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export interface AzureIntegrationApiDeleteAzureIntegrationRequest {
543543

544544
export interface AzureIntegrationApiUpdateAzureHostFiltersRequest {
545545
/**
546-
* Update a Datadog-Azure integration&#39;s host filters request body.
546+
* Update a Datadog-Azure integration's host filters request body.
547547
* @type AzureAccount
548548
*/
549549
body: AzureAccount;
@@ -575,7 +575,13 @@ export class AzureIntegrationApi {
575575
}
576576

577577
/**
578-
* Create a Datadog-Azure integration. Using the `POST` method updates your integration configuration by adding your new configuration to the existing one in your Datadog organization. Using the `PUT` method updates your integration configuration by replacing your current configuration with the new one sent to your Datadog organization.
578+
* Create a Datadog-Azure integration.
579+
*
580+
* Using the `POST` method updates your integration configuration by adding your new
581+
* configuration to the existing one in your Datadog organization.
582+
*
583+
* Using the `PUT` method updates your integration configuration by replacing your
584+
* current configuration with the new one sent to your Datadog organization.
579585
* @param param The request object
580586
*/
581587
public createAzureIntegration(
@@ -656,7 +662,9 @@ export class AzureIntegrationApi {
656662
}
657663

658664
/**
659-
* Update a Datadog-Azure integration. Requires an existing `tenant_name` and `client_id`. Any other fields supplied will overwrite existing values. To overwrite `tenant_name` or `client_id`, use `new_tenant_name` and `new_client_id`. To leave a field unchanged, do not supply that field in the payload.
665+
* Update a Datadog-Azure integration. Requires an existing `tenant_name` and `client_id`.
666+
* Any other fields supplied will overwrite existing values. To overwrite `tenant_name` or `client_id`,
667+
* use `new_tenant_name` and `new_client_id`. To leave a field unchanged, do not supply that field in the payload.
660668
* @param param The request object
661669
*/
662670
public updateAzureIntegration(

packages/datadog-api-client-v1/apis/DashboardsApi.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,14 @@ export interface DashboardsApiGetDashboardRequest {
799799

800800
export interface DashboardsApiListDashboardsRequest {
801801
/**
802-
* When &#x60;true&#x60;, this query only returns shared custom created or cloned dashboards.
802+
* When `true`, this query only returns shared custom created
803+
* or cloned dashboards.
803804
* @type boolean
804805
*/
805806
filterShared?: boolean;
806807
/**
807-
* When &#x60;true&#x60;, this query returns only deleted custom-created or cloned dashboards. This parameter is incompatible with &#x60;filter[shared]&#x60;.
808+
* When `true`, this query returns only deleted custom-created
809+
* or cloned dashboards. This parameter is incompatible with `filter[shared]`.
808810
* @type boolean
809811
*/
810812
filterDeleted?: boolean;
@@ -849,7 +851,8 @@ export class DashboardsApi {
849851
}
850852

851853
/**
852-
* Create a dashboard using the specified options. When defining queries in your widgets, take note of which queries should have the `as_count()` or `as_rate()` modifiers appended. Refer to the following [documentation](https://docs.datadoghq.com/developers/metrics/type_modifiers/?tab=count#in-application-modifiers) for more information on these modifiers.
854+
* Create a dashboard using the specified options. When defining queries in your widgets, take note of which queries should have the `as_count()` or `as_rate()` modifiers appended.
855+
* Refer to the following [documentation](https://docs.datadoghq.com/developers/metrics/type_modifiers/?tab=count#in-application-modifiers) for more information on these modifiers.
853856
* @param param The request object
854857
*/
855858
public createDashboard(
@@ -933,7 +936,10 @@ export class DashboardsApi {
933936
}
934937

935938
/**
936-
* Get all dashboards. **Note**: This query will only return custom created or cloned dashboards. This query will not return preset dashboards.
939+
* Get all dashboards.
940+
*
941+
* **Note**: This query will only return custom created or cloned dashboards.
942+
* This query will not return preset dashboards.
937943
* @param param The request object
938944
*/
939945
public listDashboards(

packages/datadog-api-client-v1/apis/EventsApi.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export interface EventsApiListEventsRequest {
404404
*/
405405
end: number;
406406
/**
407-
* Priority of your events, either &#x60;low&#x60; or &#x60;normal&#x60;.
407+
* Priority of your events, either `low` or `normal`.
408408
* @type EventPriority
409409
*/
410410
priority?: EventPriority;
@@ -419,17 +419,21 @@ export interface EventsApiListEventsRequest {
419419
*/
420420
tags?: string;
421421
/**
422-
* Set unaggregated to &#x60;true&#x60; to return all events within the specified [&#x60;start&#x60;,&#x60;end&#x60;] timeframe. Otherwise if an event is aggregated to a parent event with a timestamp outside of the timeframe, it won&#39;t be available in the output. Aggregated events with &#x60;is_aggregate&#x3D;true&#x60; in the response will still be returned unless exclude_aggregate is set to &#x60;true.&#x60;
422+
* Set unaggregated to `true` to return all events within the specified [`start`,`end`] timeframe.
423+
* Otherwise if an event is aggregated to a parent event with a timestamp outside of the timeframe,
424+
* it won't be available in the output. Aggregated events with `is_aggregate=true` in the response will still be returned unless exclude_aggregate is set to `true.`
423425
* @type boolean
424426
*/
425427
unaggregated?: boolean;
426428
/**
427-
* Set &#x60;exclude_aggregate&#x60; to &#x60;true&#x60; to only return unaggregated events where &#x60;is_aggregate&#x3D;false&#x60; in the response. If the &#x60;exclude_aggregate&#x60; parameter is set to &#x60;true&#x60;, then the unaggregated parameter is ignored and will be &#x60;true&#x60; by default.
429+
* Set `exclude_aggregate` to `true` to only return unaggregated events where `is_aggregate=false` in the response. If the `exclude_aggregate` parameter is set to `true`,
430+
* then the unaggregated parameter is ignored and will be `true` by default.
428431
* @type boolean
429432
*/
430433
excludeAggregate?: boolean;
431434
/**
432-
* By default 1000 results are returned per request. Set page to the number of the page to return with &#x60;0&#x60; being the first page. The page parameter can only be used when either unaggregated or exclude_aggregate is set to &#x60;true.&#x60;
435+
* By default 1000 results are returned per request. Set page to the number of the page to return with `0` being the first page. The page parameter can only be used
436+
* when either unaggregated or exclude_aggregate is set to `true.`
433437
* @type number
434438
*/
435439
page?: number;
@@ -453,7 +457,8 @@ export class EventsApi {
453457
}
454458

455459
/**
456-
* This endpoint allows you to post events to the stream. Tag them, set priority and event aggregate them with other events.
460+
* This endpoint allows you to post events to the stream.
461+
* Tag them, set priority and event aggregate them with other events.
457462
* @param param The request object
458463
*/
459464
public createEvent(
@@ -474,7 +479,10 @@ export class EventsApi {
474479
}
475480

476481
/**
477-
* This endpoint allows you to query for event details. **Note**: If the event you’re querying contains markdown formatting of any kind, you may see characters such as `%`,`\`,`n` in your output.
482+
* This endpoint allows you to query for event details.
483+
*
484+
* **Note**: If the event you’re querying contains markdown formatting of any kind,
485+
* you may see characters such as `%`,`\`,`n` in your output.
478486
* @param param The request object
479487
*/
480488
public getEvent(
@@ -495,7 +503,15 @@ export class EventsApi {
495503
}
496504

497505
/**
498-
* The event stream can be queried and filtered by time, priority, sources and tags. **Notes**: - If the event you’re querying contains markdown formatting of any kind, you may see characters such as `%`,`\`,`n` in your output. - This endpoint returns a maximum of `1000` most recent results. To return additional results, identify the last timestamp of the last result and set that as the `end` query time to paginate the results. You can also use the page parameter to specify which set of `1000` results to return.
506+
* The event stream can be queried and filtered by time, priority, sources and tags.
507+
*
508+
* **Notes**:
509+
* - If the event you’re querying contains markdown formatting of any kind,
510+
* you may see characters such as `%`,`\`,`n` in your output.
511+
*
512+
* - This endpoint returns a maximum of `1000` most recent results. To return additional results,
513+
* identify the last timestamp of the last result and set that as the `end` query time to
514+
* paginate the results. You can also use the page parameter to specify which set of `1000` results to return.
499515
* @param param The request object
500516
*/
501517
public listEvents(

packages/datadog-api-client-v1/apis/GCPIntegrationApi.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,10 @@ export class GCPIntegrationApi {
522522
}
523523

524524
/**
525-
* Update a Datadog-GCP integrations host_filters and/or auto-mute. Requires a `project_id` and `client_email`, however these fields cannot be updated. If you need to update these fields, delete and use the create (`POST`) endpoint. The unspecified fields will keep their original values.
525+
* Update a Datadog-GCP integrations host_filters and/or auto-mute.
526+
* Requires a `project_id` and `client_email`, however these fields cannot be updated.
527+
* If you need to update these fields, delete and use the create (`POST`) endpoint.
528+
* The unspecified fields will keep their original values.
526529
* @param param The request object
527530
*/
528531
public updateGCPIntegration(

0 commit comments

Comments
 (0)