Skip to content

cmd/docgen: add HTTP extractor#51803

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
madelynnblue:docgen
Aug 5, 2020
Merged

cmd/docgen: add HTTP extractor#51803
craig[bot] merged 1 commit intocockroachdb:masterfrom
madelynnblue:docgen

Conversation

@madelynnblue
Copy link
Copy Markdown
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
Copy Markdown
Member

This change is Reviewable

@madelynnblue
Copy link
Copy Markdown
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
Copy Markdown
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>

@madelynnblue
Copy link
Copy Markdown
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
Copy Markdown
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?

@madelynnblue
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@madelynnblue
Copy link
Copy Markdown
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
@madelynnblue
Copy link
Copy Markdown
Contributor Author

RFAL. Any more comments on the markdown?

Copy link
Copy Markdown
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!

@madelynnblue
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 5, 2020

Build succeeded:

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