Skip to content

Commit 29c3b02

Browse files
authored
[R] Update R6 object documentation (#19679)
* Remove @export and titles from R6 methods * Remove redundant methods docs from R api.mustache * Build project
1 parent a6581e8 commit 29c3b02

File tree

125 files changed

+1450
-6122
lines changed

Some content is hidden

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

125 files changed

+1450
-6122
lines changed

modules/openapi-generator/src/main/resources/r/ApiResponse.mustache

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ ApiResponse <- R6::R6Class(
1717
status_code = NULL,
1818
status_code_desc = NULL,
1919
headers = NULL,
20-
#' Initialize a new ApiResponse class.
21-
#'
20+
2221
#' @description
2322
#' Initialize a new ApiResponse class.
2423
#'
@@ -27,7 +26,6 @@ ApiResponse <- R6::R6Class(
2726
#' @param status_code The HTTP response status code.
2827
#' @param status_code_desc The brief description of the HTTP response status code.
2928
#' @param headers The HTTP response headers.
30-
#' @export
3129
initialize = function(content = NULL,
3230
response = NULL,
3331
status_code = NULL,
@@ -40,15 +38,13 @@ ApiResponse <- R6::R6Class(
4038
self$headers <- headers
4139
},
4240

43-
#' Return the response as text
44-
#'
41+
4542
#' @description
4643
#' The response is stored as a raw vector. Use this to access the response after
4744
#' converting it to text. If the response is not coercible to text NA is returned.
4845
#'
4946
#' @param from_encoding The encoding of the raw response.
5047
#' @param to_encoding The target encoding of the return value.
51-
#' @export
5248
response_as_text = function(from_encoding = "", to_encoding = "UTF-8") {
5349
if (is.null(self$response)) {
5450
self$response <- charToRaw(jsonlite::toJSON("NULL"))

modules/openapi-generator/src/main/resources/r/api.mustache

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,6 @@
66
#' @format An \code{R6Class} generator object
77
#' @field api_client Handles the client-server communication.
88
#'
9-
#' @section Methods:
10-
{{! Adding the below changes for generating documentation for the api methods. }}
11-
#' \describe{
12-
{{#operation}}
13-
#' \strong{ {{operationId}} } \emph{ {{#lambdaRdocEscape}}{{summary}}{{/lambdaRdocEscape}} }
14-
{{#notes}}
15-
#' {{#lambdaRdocEscape}}{{{.}}}{{/lambdaRdocEscape}}
16-
{{/notes}}
17-
#'
18-
#' \itemize{
19-
{{#allParams}}
20-
{{#isEnum}}
21-
#' \item \emph{ @param } {{paramName}} Enum < {{#allowableValues}}{{values}}{{/allowableValues}} >
22-
{{/isEnum}}
23-
{{^isEnum}}
24-
{{#isContainer}}
25-
{{#isArray}}
26-
{{#items}}
27-
{{#isPrimitiveType}}
28-
#' \item \emph{ @param } {{paramName}} list( {{dataType}} )
29-
{{/isPrimitiveType}}
30-
{{^isPrimitiveType}}
31-
#' \item \emph{ @param } {{paramName}} list( \link{{=<% %>=}}{<%dataType%>}<%={{ }}=%> )
32-
{{/isPrimitiveType}}
33-
{{/items}}
34-
{{/isArray}}
35-
{{#isMap}}
36-
{{#isPrimitiveType}}
37-
#' \item \emph{ @param } {{paramName}} named list( {{dataType}} )
38-
{{/isPrimitiveType}}
39-
{{^isPrimitiveType}}
40-
#' \item \emph{ @param } {{paramName}} named list( \link{{=<% %>=}}{<%dataType%>}<%={{ }}=%> )
41-
{{/isPrimitiveType}}
42-
{{/isMap}}
43-
{{/isContainer}}
44-
{{^isContainer}}
45-
{{#isPrimitiveType}}
46-
#' \item \emph{ @param } {{paramName}} {{dataType}}
47-
{{/isPrimitiveType}}
48-
{{^isPrimitiveType}}
49-
#' \item \emph{ @param } {{paramName}} \link{{=<% %>=}}{<%dataType%>}<%={{ }}=%>
50-
{{/isPrimitiveType}}
51-
{{/isContainer}}
52-
{{/isEnum}}
53-
{{/allParams}}
54-
{{#returnType}}
55-
{{^returnTypeIsPrimitive}}
56-
#' \item \emph{ @returnType } {{#returnContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/returnContainer}}\link{{=<% %>=}}{<%#returnContainer%><%={{ }}=%>{{returnBaseType}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{=<% %>=}}<%/returnContainer%>}<%={{ }}=%>{{#returnContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/returnContainer}} \cr
57-
{{/returnTypeIsPrimitive}}
58-
{{/returnType}}
59-
#'
60-
{{#useRlangExceptionHandling}}
61-
#' \item On encountering errors, an error of subclass ApiException will be thrown.
62-
{{/useRlangExceptionHandling}}
63-
#'
64-
{{#responses}}
65-
#' \item status code : {{code}} | {{{message}}}
66-
#'
67-
#'{{#dataType}} \item return type : {{{.}}}{{/dataType}}
68-
#' \item response headers :
69-
#'
70-
#' \tabular{ll}{
71-
{{#headers}}
72-
#' {{name}} \tab {{{description}}} \cr
73-
{{/headers}}
74-
#' }
75-
{{/responses}}
76-
#' }
77-
#'
78-
{{/operation}}
79-
#' }
80-
#'
81-
#'
829
#' @examples
8310
#' \dontrun{
8411
{{#operation}}
@@ -185,13 +112,11 @@
185112
"{{classname}}",
186113
public = list(
187114
api_client = NULL,
188-
#' Initialize a new {{{classname}}}.
189-
#'
115+
190116
#' @description
191117
#' Initialize a new {{{classname}}}.
192118
#'
193119
#' @param api_client An instance of API client.
194-
#' @export
195120
initialize = function(api_client) {
196121
if (!missing(api_client)) {
197122
self$api_client <- api_client
@@ -200,8 +125,7 @@
200125
}
201126
},
202127
{{#operation}}
203-
#' {{{summary}}}
204-
#'
128+
205129
#' @description
206130
#' {{{description}}}{{^description}}{{{summary}}}{{/description}}
207131
#'
@@ -218,8 +142,8 @@
218142
#' @param data_file (optional) name of the data file to save the result
219143
{{/returnType}}
220144
#' @param ... Other optional arguments
145+
#'
221146
#' @return {{{returnType}}}{{^returnType}}void{{/returnType}}
222-
#' @export
223147
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
224148
local_var_response <- self${{{operationId}}}{{WithHttpInfo}}({{#allParams}}{{paramName}}, {{/allParams}}{{#vendorExtensions.x-streaming}}stream_callback = stream_callback, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = data_file, {{/returnType}}...)
225149
{{#vendorExtensions.x-streaming}}
@@ -238,8 +162,7 @@
238162
local_var_response
239163
}
240164
},
241-
#' {{{summary}}}
242-
#'
165+
243166
#' @description
244167
#' {{{description}}}{{^description}}{{{summary}}}{{/description}}
245168
#'
@@ -256,8 +179,8 @@
256179
#' @param data_file (optional) name of the data file to save the result
257180
{{/returnType}}
258181
#' @param ... Other optional arguments
182+
#'
259183
#' @return API response ({{{returnType}}}{{^returnType}}void{{/returnType}}) with additional information such as HTTP status code, headers
260-
#' @export
261184
{{{operationId}}}{{WithHttpInfo}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
262185
args <- list(...)
263186
query_params <- list()

modules/openapi-generator/src/main/resources/r/api_client.mustache

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ ApiClient <- R6::R6Class(
158158
self$max_retry_attempts <- max_retry_attempts
159159
}
160160
},
161-
#' Prepare to make an API call with the retry logic.
162-
#'
161+
163162
#' @description
164163
#' Prepare to make an API call with the retry logic.
165164
#'
@@ -174,8 +173,8 @@ ApiClient <- R6::R6Class(
174173
#' @param body The HTTP request body.
175174
#' @param stream_callback Callback function to process the data stream
176175
#' @param ... Other optional arguments.
176+
#'
177177
#' @return HTTP response
178-
#' @export
179178
CallApi = function(url, method, query_params, header_params, form_params,
180179
file_params, accepts, content_types,
181180
body, stream_callback = NULL, ...) {
@@ -205,8 +204,7 @@ ApiClient <- R6::R6Class(
205204
206205
resp
207206
},
208-
#' Make an API call
209-
#'
207+
210208
#' @description
211209
#' Make an API call
212210
#'
@@ -221,8 +219,8 @@ ApiClient <- R6::R6Class(
221219
#' @param body The HTTP request body.
222220
#' @param stream_callback Callback function to process data stream
223221
#' @param ... Other optional arguments.
222+
#'
224223
#' @return HTTP response
225-
#' @export
226224
Execute = function(url, method, query_params, header_params,
227225
form_params, file_params,
228226
accepts, content_types,
@@ -316,40 +314,39 @@ ApiClient <- R6::R6Class(
316314
317315
# return ApiResponse
318316
api_response <- ApiResponse$new()
319-
api_response$status_code <- httr::status_code(httr_response)
317+
api_response$status_code <- httr::status_code(httr_response)
320318
api_response$status_code_desc <- httr::http_status(httr_response)$reason
321319
api_response$response <- httr::content(httr_response, "raw")
322320
api_response$headers <- httr::headers(httr_response)
323321
324322
api_response
325323
}
326324
},
327-
#' Deserialize the content of API response to the given type.
328-
#'
325+
329326
#' @description
330327
#' Deserialize the content of API response to the given type.
331328
#'
332329
#' @param raw_response Raw response.
333330
#' @param return_type R return type.
334331
#' @param pkg_env Package environment.
332+
#'
335333
#' @return Deserialized object.
336-
#' @export
337334
deserialize = function(raw_response, return_type, pkg_env) {
338335
resp_obj <- jsonlite::fromJSON(raw_response)
339336
self$deserializeObj(resp_obj, return_type, pkg_env)
340337
},
341-
#' Deserialize the response from jsonlite object based on the given type
342-
#'
338+
343339
#' @description
344340
#' Deserialize the response from jsonlite object based on the given type
345341
#' by handling complex and nested types by iterating recursively
346-
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
342+
#' Example return_types will be like "array[integer]", "map(Pet)",
343+
#' "array[map(Tag)]", etc.,
347344
#'
348345
#' @param obj Response object.
349346
#' @param return_type R return type.
350347
#' @param pkg_env Package environment.
348+
#'
351349
#' @return Deserialized object.
352-
#' @export
353350
deserializeObj = function(obj, return_type, pkg_env) {
354351
return_obj <- NULL
355352
primitive_types <- c("character", "numeric", "integer", "logical", "complex")
@@ -411,15 +408,14 @@ ApiClient <- R6::R6Class(
411408
}
412409
return_obj
413410
},
414-
#' Return a property header (for accept or content-type).
415-
#'
411+
416412
#' @description
417413
#' Return a property header (for accept or content-type). If JSON-related MIME is found,
418414
#' return it. Otherwise, return the first one, if any.
419415
#'
420416
#' @param headers A list of headers
417+
#'
421418
#' @return A header (e.g. 'application/json')
422-
#' @export
423419
select_header = function(headers) {
424420
if (length(headers) == 0) {
425421
return(invisible(NULL))

modules/openapi-generator/src/main/resources/r/api_exception.mustache

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ ApiException <- R6::R6Class(
2222
{{#errorObjectType}}
2323
error_object = NULL,
2424
{{/errorObjectType}}
25-
#' Initialize a new ApiException class.
26-
#'
25+
2726
#' @description
28-
#' Initialize a new ApiExceptino class.
27+
#' Initialize a new ApiException class.
2928
#'
3029
#' @param status HTTP status.
3130
#' @param reason Reason of the ApiException.
3231
#' @param http_response HTTP response object.
33-
#' @export
3432
initialize = function(status = NULL, reason = NULL, http_response = NULL) {
3533
if (!is.null(http_response)) {
3634
self$status <- http_response$status_code
@@ -54,13 +52,11 @@ ApiException <- R6::R6Class(
5452
{{/errorObjectType}}
5553
}
5654
},
57-
#' Returns the string format of ApiException.
58-
#'
55+
5956
#' @description
6057
#' Returns the string format of ApiException.
6158
#'
6259
#' @return the string format of ApiException.
63-
#' @export
6460
toString = function() {
6561
errorMsg <- ""
6662
errorMsg <- paste("status : ", self$status, "\n", sep = "")

0 commit comments

Comments
 (0)