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

Generate API docs #1541

Merged
merged 4 commits into from
Dec 27, 2023
Merged

Generate API docs #1541

merged 4 commits into from
Dec 27, 2023

Conversation

tnozicka
Copy link
Contributor

@tnozicka tnozicka commented Nov 8, 2023

Description of your changes:
The PR add a tool (gen-api-reference) that can generate API docs from CRDs. While it has it's quirks, like the inlined objects from other or the same API group, it is marginally better then not having to the docs at all. Compared to native Swagger/OpenAPI this is aware of API groups and versions.

The next step would be to generate the docs base on Golang types that don't inline referenced objects but this still gets us 95% of the way and with the internal links to objects it's quite usable.

Which issue is resolved by this Pull Request:
Resolves #1526

@tnozicka tnozicka added kind/documentation Categorizes issue or PR as related to documentation. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. kind/machinery Categorizes issue or PR as related to Makefile, scripts or similar changes. labels Nov 8, 2023
@scylla-operator-bot scylla-operator-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 8, 2023
@scylla-operator-bot scylla-operator-bot bot added area/dependency Issues or PRs related to dependency changes approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 8, 2023
@scylla-operator-bot scylla-operator-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2023
@scylla-operator-bot scylla-operator-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2023
@tnozicka tnozicka force-pushed the api-ref branch 2 times, most recently from 5425578 to 17ca93a Compare November 16, 2023 16:54
@tnozicka tnozicka changed the title [WIP] Generate API docs Generate API docs Nov 16, 2023
@scylla-operator-bot scylla-operator-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 16, 2023
@rzetelskik
Copy link
Member

Two questions before I go into reviewing this:

  1. Why did you choose generating rst instead of markdown?

The next step would be to generate the docs base on Golang types

Couldn't it be handled similarly to how https://github.com/kubernetes-sigs/reference-docs/tree/master/gen-resourcesdocs handles it?

@tnozicka
Copy link
Contributor Author

Why did you choose generating rst instead of markdown?

We need the RST directives so embedding it in markdown just makes it harder or possibly bumping into "convertor" issues. Some like toc may not be even supported there. That said, it's limited to the templates.

Couldn't it be handled similarly to how https://github.com/kubernetes-sigs/reference-docs/tree/master/gen-resourcesdocs handles it?

I think we'll eventually use a similar generator from GoType, I didn't realize CRDs lack some of the information initially and this was quick to get. I'd like it to be slightly less manually but will see when I do v2 on types one day.

(You can cut this PR some slack as we'll eventually replace it.)

@rzetelskik
Copy link
Member

We need the RST directives so embedding it in markdown just makes it harder or possibly bumping into "convertor" issues. Some like toc may not be even supported there. That said, it's limited to the templates.

toc is supported - mystparser docs are dogfooding https://github.com/executablebooks/MyST-Parser/blob/master/docs/index.md. Having said that our indexes are still in rst so not an issue, this can be converted later, I was just curious if there was a known blocker. I'd personally rather see all our docs in markdown than the other way round but let's not get into this here.

@tnozicka
Copy link
Contributor Author

Good, I am fine if this eventually reconciles one way or the other, if we decide to unify the rest. If we sort it out for the rest, the templates are easy to switch.

@tnozicka
Copy link
Contributor Author

@rzetelskik gentle ping

@scylla-operator-bot scylla-operator-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2023
@scylla-operator-bot scylla-operator-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2023
@rzetelskik
Copy link
Member

@rzetelskik gentle ping

on it ;)

Copy link
Member

@rzetelskik rzetelskik left a comment

Choose a reason for hiding this comment

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

lgtm overall, a few comments.
I wonder - would it be possible to indent nested fields, like Kube API reference does? Or does that require moving to parsing go files?

image

docs/source/api-reference/index.rst Outdated Show resolved Hide resolved
pkg/cmd/generateapireference/run.go Outdated Show resolved Hide resolved
pkg/cmd/generateapireference/run_test.go Outdated Show resolved Hide resolved
docs/source/helm.md Outdated Show resolved Hide resolved
docs/source/manager.md Outdated Show resolved Hide resolved
@scylla-operator-bot scylla-operator-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2023
@scylla-operator-bot scylla-operator-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 18, 2023
@tnozicka
Copy link
Contributor Author

would it be possible to indent nested fields

I think they selectively inline some definitions and the others. This is tricky and you may end up defining some multiple times. I'd rather not go into it here.

@tnozicka
Copy link
Contributor Author

#1546 (comment)
/retest

@tnozicka tnozicka requested a review from rzetelskik December 18, 2023 12:10
Copy link
Member

@rzetelskik rzetelskik left a comment

Choose a reason for hiding this comment

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

one more comment, other than that lgtm
/assign zimnx

pkg/cmd/generateapireference/run.go Outdated Show resolved Hide resolved
@rzetelskik
Copy link
Member

/approve
and lgtm

Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rzetelskik, tnozicka

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tnozicka
Copy link
Contributor Author

one more comment, other than that lgtm
/assign zimnx

@rzetelskik based on your previous comment (and resolving the referenced nit) I suppose this is now only awaiting your official tag?

@rzetelskik
Copy link
Member

/unassign zimnx
/lgtm

@scylla-operator-bot scylla-operator-bot bot added the lgtm Indicates that a PR is ready to be merged. label Dec 27, 2023
@scylla-operator-bot scylla-operator-bot bot merged commit d496526 into scylladb:master Dec 27, 2023
@tnozicka tnozicka deleted the api-ref branch December 27, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/dependency Issues or PRs related to dependency changes kind/documentation Categorizes issue or PR as related to documentation. kind/machinery Categorizes issue or PR as related to Makefile, scripts or similar changes. lgtm Indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate API reference in docs
3 participants