documentation examples sometimes are not formatted properly (#303)

This commit is contained in:
Adam Leventhal 2023-01-13 10:59:21 -08:00 committed by GitHub
parent 582e20c397
commit 96af7b5a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 348 additions and 200 deletions

View File

@ -1706,8 +1706,7 @@ impl Generator {
// be validated by doc tests, but in order to use the Client we need
// to import it, and in order to import it we need to know the name of
// the containing crate... which we can't from this context.
let doc =
format!("{}\n```ignore\n{}\n```", make_doc_comment(method), eg);
let doc = format!("{}```ignore\n{}\n```", make_doc_comment(method), eg);
let sig = quote! {
fn #operation_id(&self) -> builder:: #struct_ident
@ -1945,7 +1944,7 @@ fn make_doc_comment(method: &OperationMethod) -> String {
}
buf.push_str(&format!(
"Sends a `{}` request to `{}`",
"Sends a `{}` request to `{}`\n\n",
method.method.as_str().to_ascii_uppercase(),
method.path.to_string(),
));
@ -1957,7 +1956,7 @@ fn make_doc_comment(method: &OperationMethod) -> String {
.count()
> 0
{
buf.push_str("\n\nArguments:\n");
buf.push_str("Arguments:\n");
for param in &method.params {
buf.push_str(&format!("- `{}`", param.name));
if let Some(description) = &param.description {
@ -1984,7 +1983,7 @@ fn make_stream_doc_comment(method: &OperationMethod) -> String {
}
buf.push_str(&format!(
"Sends repeated `{}` requests to `{}` until there are no more results.",
"Sends repeated `{}` requests to `{}` until there are no more results.\n\n",
method.method.as_str().to_ascii_uppercase(),
method.path.to_string(),
));
@ -1997,7 +1996,7 @@ fn make_stream_doc_comment(method: &OperationMethod) -> String {
.count()
> 0
{
buf.push_str("\n\nArguments:\n");
buf.push_str("Arguments:\n");
for param in &method.params {
if param.api_name.as_str() == "page_token" {
continue;

View File

@ -1316,6 +1316,7 @@ impl Client {
impl Client {
///Sends a `POST` request to `/v1/control/hold`
///
///```ignore
/// let response = client.control_hold()
/// .send()
@ -1326,6 +1327,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/control/resume`
///
///```ignore
/// let response = client.control_resume()
/// .send()
@ -1336,6 +1338,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/task/{task}`
///
///```ignore
/// let response = client.task_get()
/// .task(task)
@ -1347,6 +1350,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks`
///
///```ignore
/// let response = client.tasks_get()
/// .send()
@ -1357,6 +1361,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/tasks`
///
///```ignore
/// let response = client.task_submit()
/// .body(body)
@ -1368,6 +1373,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/events`
///
///```ignore
/// let response = client.task_events_get()
/// .task(task)
@ -1380,6 +1386,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/outputs`
///
///```ignore
/// let response = client.task_outputs_get()
/// .task(task)
@ -1391,6 +1398,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}`
///
///```ignore
/// let response = client.task_output_download()
/// .task(task)
@ -1403,6 +1411,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/users`
///
///```ignore
/// let response = client.user_create()
/// .body(body)
@ -1414,6 +1423,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/whoami`
///
///```ignore
/// let response = client.whoami()
/// .send()
@ -1424,6 +1434,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/bootstrap`
///
///```ignore
/// let response = client.worker_bootstrap()
/// .body(body)
@ -1435,6 +1446,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/worker/ping`
///
///```ignore
/// let response = client.worker_ping()
/// .send()
@ -1445,6 +1457,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/append`
///
///```ignore
/// let response = client.worker_task_append()
/// .task(task)
@ -1457,6 +1470,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/chunk`
///
///```ignore
/// let response = client.worker_task_upload_chunk()
/// .task(task)
@ -1469,6 +1483,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/complete`
///
///```ignore
/// let response = client.worker_task_complete()
/// .task(task)
@ -1481,6 +1496,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/output`
///
///```ignore
/// let response = client.worker_task_add_output()
/// .task(task)
@ -1493,6 +1509,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/workers`
///
///```ignore
/// let response = client.workers_list()
/// .send()
@ -1503,6 +1520,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/workers/recycle`
///
///```ignore
/// let response = client.workers_recycle()
/// .send()

View File

@ -1316,6 +1316,7 @@ impl Client {
impl Client {
///Sends a `POST` request to `/v1/control/hold`
///
///```ignore
/// let response = client.control_hold()
/// .send()
@ -1326,6 +1327,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/control/resume`
///
///```ignore
/// let response = client.control_resume()
/// .send()
@ -1336,6 +1338,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/task/{task}`
///
///```ignore
/// let response = client.task_get()
/// .task(task)
@ -1347,6 +1350,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks`
///
///```ignore
/// let response = client.tasks_get()
/// .send()
@ -1357,6 +1361,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/tasks`
///
///```ignore
/// let response = client.task_submit()
/// .body(body)
@ -1368,6 +1373,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/events`
///
///```ignore
/// let response = client.task_events_get()
/// .task(task)
@ -1380,6 +1386,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/outputs`
///
///```ignore
/// let response = client.task_outputs_get()
/// .task(task)
@ -1391,6 +1398,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}`
///
///```ignore
/// let response = client.task_output_download()
/// .task(task)
@ -1403,6 +1411,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/users`
///
///```ignore
/// let response = client.user_create()
/// .body(body)
@ -1414,6 +1423,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/whoami`
///
///```ignore
/// let response = client.whoami()
/// .send()
@ -1424,6 +1434,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/bootstrap`
///
///```ignore
/// let response = client.worker_bootstrap()
/// .body(body)
@ -1435,6 +1446,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/worker/ping`
///
///```ignore
/// let response = client.worker_ping()
/// .send()
@ -1445,6 +1457,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/append`
///
///```ignore
/// let response = client.worker_task_append()
/// .task(task)
@ -1457,6 +1470,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/chunk`
///
///```ignore
/// let response = client.worker_task_upload_chunk()
/// .task(task)
@ -1469,6 +1483,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/complete`
///
///```ignore
/// let response = client.worker_task_complete()
/// .task(task)
@ -1481,6 +1496,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/worker/task/{task}/output`
///
///```ignore
/// let response = client.worker_task_add_output()
/// .task(task)
@ -1493,6 +1509,7 @@ impl Client {
}
///Sends a `GET` request to `/v1/workers`
///
///```ignore
/// let response = client.workers_list()
/// .send()
@ -1503,6 +1520,7 @@ impl Client {
}
///Sends a `POST` request to `/v1/workers/recycle`
///
///```ignore
/// let response = client.workers_recycle()
/// .send()

View File

@ -784,7 +784,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.enrol()
/// .authorization(authorization)
@ -800,7 +799,6 @@ impl Client {
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///
///```ignore
/// let response = client.global_jobs()
/// .authorization(authorization)
@ -815,7 +813,6 @@ impl Client {
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///
///```ignore
/// let response = client.ping()
/// .authorization(authorization)
@ -831,7 +828,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_finish()
/// .authorization(authorization)
@ -848,7 +844,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_output()
/// .authorization(authorization)
@ -865,7 +860,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_start()
/// .authorization(authorization)

View File

@ -784,7 +784,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.enrol()
/// .authorization(authorization)
@ -800,7 +799,6 @@ impl Client {
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///
///```ignore
/// let response = client.global_jobs()
/// .authorization(authorization)
@ -815,7 +813,6 @@ impl Client {
///
///Arguments:
/// - `authorization`: Authorization header (bearer token)
///
///```ignore
/// let response = client.ping()
/// .authorization(authorization)
@ -831,7 +828,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_finish()
/// .authorization(authorization)
@ -848,7 +844,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_output()
/// .authorization(authorization)
@ -865,7 +860,6 @@ impl Client {
///Arguments:
/// - `authorization`: Authorization header (bearer token)
/// - `body`
///
///```ignore
/// let response = client.report_start()
/// .authorization(authorization)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,6 @@ impl Client {
/// parameter
/// - `unique_key`: A key parameter that will not be overridden by the path
/// spec
///
///```ignore
/// let response = client.key_get()
/// .key(key)

View File

@ -68,7 +68,6 @@ impl Client {
/// parameter
/// - `unique_key`: A key parameter that will not be overridden by the path
/// spec
///
///```ignore
/// let response = client.key_get()
/// .key(key)

View File

@ -1550,6 +1550,7 @@ impl Client {
impl Client {
///Sends a `GET` request to `/instance`
///
///```ignore
/// let response = client.instance_get()
/// .send()
@ -1560,6 +1561,7 @@ impl Client {
}
///Sends a `PUT` request to `/instance`
///
///```ignore
/// let response = client.instance_ensure()
/// .body(body)
@ -1573,6 +1575,7 @@ impl Client {
///Issue a snapshot request to a crucible backend
///
///Sends a `POST` request to `/instance/disk/{id}/snapshot/{snapshot_id}`
///
///```ignore
/// let response = client.instance_issue_crucible_snapshot_request()
/// .id(id)
@ -1587,6 +1590,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/migrate/status`
///
///```ignore
/// let response = client.instance_migrate_status()
/// .body(body)
@ -1598,6 +1602,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/serial`
///
///```ignore
/// let response = client.instance_serial()
/// .send()
@ -1608,6 +1613,7 @@ impl Client {
}
///Sends a `PUT` request to `/instance/state`
///
///```ignore
/// let response = client.instance_state_put()
/// .body(body)
@ -1619,6 +1625,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/state-monitor`
///
///```ignore
/// let response = client.instance_state_monitor()
/// .body(body)

View File

@ -1556,6 +1556,7 @@ impl Client {
impl Client {
///Sends a `GET` request to `/instance`
///
///```ignore
/// let response = client.instance_get()
/// .send()
@ -1566,6 +1567,7 @@ impl Client {
}
///Sends a `PUT` request to `/instance`
///
///```ignore
/// let response = client.instance_ensure()
/// .body(body)
@ -1579,6 +1581,7 @@ impl Client {
///Issue a snapshot request to a crucible backend
///
///Sends a `POST` request to `/instance/disk/{id}/snapshot/{snapshot_id}`
///
///```ignore
/// let response = client.instance_issue_crucible_snapshot_request()
/// .id(id)
@ -1593,6 +1596,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/migrate/status`
///
///```ignore
/// let response = client.instance_migrate_status()
/// .body(body)
@ -1604,6 +1608,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/serial`
///
///```ignore
/// let response = client.instance_serial()
/// .send()
@ -1614,6 +1619,7 @@ impl Client {
}
///Sends a `PUT` request to `/instance/state`
///
///```ignore
/// let response = client.instance_state_put()
/// .body(body)
@ -1625,6 +1631,7 @@ impl Client {
}
///Sends a `GET` request to `/instance/state-monitor`
///
///```ignore
/// let response = client.instance_state_monitor()
/// .body(body)

View File

@ -238,6 +238,7 @@ impl Client {
impl Client {
///Sends a `POST` request to `/`
///
///```ignore
/// let response = client.default_params()
/// .body(body)