Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/docgen: add HTTP extractor #51803

Merged
merged 1 commit into from
Aug 5, 2020
Merged

cmd/docgen: add HTTP extractor #51803

merged 1 commit into from
Aug 5, 2020

Conversation

maddyblue
Copy link
Contributor

Add a way to extract docs from the status.proto HTTP endpoint. These
can be imported into the docs project as needed.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@maddyblue
Copy link
Contributor Author

@taroface there's 2 markdown files here. Please comment on them and I can adjust. The current format is bad and I think you'll have a better idea of what you want.

@taroface
Copy link
Collaborator

taroface commented Jul 23, 2020

@mjibson Thanks for generating these. I went ahead and mocked up some Markdown templates, because it seemed easier. I'm open to your feedback on any of this:

full.md

  • I like the utility of the endpoints table at the top, but it may be more efficient to make each endpoint an h2 and have them appear in the article nav.
  • Is there a way to scrape the error codes for each endpoint? I made up a placeholder for this, just in case.
{{site.data.alerts.callout_success}}
This page describes...
{{site.data.alerts.end}}

## Certificates

`GET /_status/certificates/{node_id}`

Brief description of this endpoint.

<a name="cockroach.server.serverpb.CertificatesRequest"></a>
### Request Parameters

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| node_id | [string](#string) |  | node_id is a string so that "local" can be used to specify that no forwarding is necessary. |

<a name="cockroach.server.serverpb.CertificatesResponse"></a>
### Response Parameters

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| certificates | [CertificateDetails](#cockroach.server.serverpb.CertificateDetails) | repeated |  |

<a name="cockroach.server.serverpb.CertificatesError"></a>
### Error Responses

| Error | Code | Description |
| ----- | ---- | ----------- |
...

## Details

`GET /_status/details/{node_id}`

...

hotranges.md

  • Assuming this is one of the endpoint pages that will be mostly manual:
---
title: HotRanges
summary: The HotRanges endpoint returns hot ranges.
toc: true
---

Description of this endpoint.

### Method

`GET /_status/hotranges`

### Example Request

...

### Request Parameters

<div>
  {% include {{ page.version.version }}/path-to-hotrangesrequest %}
</div>

### Example Response

...

### Response Parameters

<div>
  {% include {{ page.version.version }}/path-to-hotrangesresponse %}
</div>

### Error Responses

<div>
  {% include {{ page.version.version }}/path-to-hotrangeserror %}
</div>

@maddyblue
Copy link
Contributor Author

Ok I think the full markdown will work like that. How about for the single pages one, instead of including multiple separate generated pages, it just includes a single page that has all of the request/response/error data in it? I also don't think there's a way to do error responses. Those I think happen at a higher level, like there's one generic error response or something? It's not in the proto in any case.

@taroface
Copy link
Collaborator

For e.g. hotranges.md, the reason I'd want to have separate includes is to have the request/response parameter tables come after the example request or response. Is it much harder or messier to do it this way?

@maddyblue
Copy link
Contributor Author

RFAL. I combined the response and request sections into one for the single page template so you should be able to do it in one include. Error responses are all the same:

message ResponseError {

@taroface
Copy link
Collaborator

@mjibson Looking at #50126, are there any per-endpoint authorization parameters we can also include in the markdown files?

@maddyblue
Copy link
Contributor Author

Nope, auth is done in go files, not listed in protos.

Add a way to extract docs from the status.proto HTTP endpoint. These
can be imported into the docs project as needed.

Release note: None
@maddyblue
Copy link
Contributor Author

RFAL. Any more comments on the markdown?

Copy link
Collaborator

@taroface taroface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. thank you!

@maddyblue
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 5, 2020

Build succeeded:

@craig craig bot merged commit 67a92cd into cockroachdb:master Aug 5, 2020
@maddyblue maddyblue deleted the docgen branch August 5, 2020 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants