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

📖 Add API reference documentation generation #1702

Merged

Conversation

alexandrevilain
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1694

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 2, 2023
@netlify
Copy link

netlify bot commented Oct 2, 2023

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit af5545c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/65df61829516790008d807be
😎 Deploy Preview https://deploy-preview-1702--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 2, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @alexandrevilain. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 2, 2023
@wwentland
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 2, 2023
@alexandrevilain
Copy link
Contributor Author

/retest

@jichenjc
Copy link
Contributor

jichenjc commented Oct 3, 2023

Thanks for the PR
where can we check the output of the newly added PR? e.g some test doc etc?

@alexandrevilain
Copy link
Contributor Author

Thanks for the PR where can we check the output of the newly added PR? e.g some test doc etc?

You can check it here: https://deploy-preview-1702--kubernetes-sigs-cluster-api-openstack.netlify.app/api/v1alpha7/api

@mdbooth
Copy link
Contributor

mdbooth commented Oct 4, 2023

Thank you! I will try to review this properly asap if nobody gets to it before me.

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

This looks fantastic. Couple of questions inline, but I think we can merge this soon.

Thank you!

Comment on lines +215 to +216
// +genclient
// +genclient:Namespaced
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know why these are required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because complete support for kubebuilder v2 is still missing in the tool ahmetb/gen-crd-api-reference-docs#15

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you hand-craft these templates, or were they copied from somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't suppose there's any way to generate this? No worries if not, it can be hand-crafted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea, maybe we can create a tool to generate this after generating apis doc in the makefile

@alexandrevilain alexandrevilain force-pushed the docs/add-api-reference branch 2 times, most recently from 0b4f229 to b64855a Compare October 5, 2023 08:11
Copy link
Contributor

@wwentland wwentland left a comment

Choose a reason for hiding this comment

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

Thank you, this is indeed very nice!

Alternative approaches

I just had a look at gen-crd-api-reference-docs and noticed the following comment:

Nowadays, I don't have a lot of time to maintain this tool. So consider using one of the above in case this repo does not work for you.
If you're an open source project, consider exposing your CRD API Reference via https://doc.crds.dev/ without much effort.

Which reminds me of https://xkcd.com/2347/ and I have, in fact, used the CRD API references on https://doc.crds.dev/ countless times as a user myself:

Those are always up-to-date and you can also browse earlier versions easily. Including a link to that website, might be a viable alternative to generating the reference documentation ourselves.

That being said, I do like the outcome, generating the reference documentation ourselves means we are not depending on an external service, and the tool appears to be well adopted within the community.

Licensing

Is there anything we need to do when copy & pasting templates from gen-crd-api-reference-docs/tree/master/template from a licensing perspective?

I see that the project does not include its own copyright notice, which makes it a bit harder to comply with the license requirement to retain the original statement.

generate-api-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Generate api documentation
$(GEN_CRD_API_REFERENCE_DOCS) \
-api-dir=./api/v1alpha7 \
-config=./docs/book/gen-crd-api-reference-docs/config.json \
Copy link
Contributor

Choose a reason for hiding this comment

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

This files seems to be missing and I see the following error in the test results:

 	-template-dir=./docs/book/gen-crd-api-reference-docs/template \
	-out-file=./docs/book/src/api/v1alpha6/api.md
F1005 08:16:40.577071   16819 main.go:123] failed to open config file: open ./docs/book/gen-crd-api-reference-docs/config.json: no such file or directory
make[1]: *** [Makefile:288: generate-api-docs] Error 255
make[1]: Leaving directory '/home/prow/go/src/sigs.k8s.io/cluster-api-provider-openstack'
make: *** [Makefile:255: generate] Error 2 

Do we have to provide it or would the tool fall back to reasonable defaults if we don't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh! I understand why CI was failing ... config.json is gitignored ! Fixing this !

Copy link
Contributor

Choose a reason for hiding this comment

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

I also happened to discover we're ignoring '*.json' just last week. We should get rid of that rule; it's weird.

@jichenjc
Copy link
Contributor

jichenjc commented Oct 9, 2023

/test pull-cluster-api-provider-openstack-test

@alexandrevilain alexandrevilain force-pushed the docs/add-api-reference branch 2 times, most recently from 40b025d to 694416b Compare October 9, 2023 08:09
@alexandrevilain
Copy link
Contributor Author

/retest

@mdbooth
Copy link
Contributor

mdbooth commented Oct 13, 2023

Not sure what that test failure is about. I really want to get this merged, so if I get some time I'll investigate myself if nobody beats me to it.

@alexandrevilain
Copy link
Contributor Author

Not sure what that test failure is about. I really want to get this merged, so if I get some time I'll investigate myself if nobody beats me to it.

No idea why test are failing ... I tried rebase in case of failing CI on the main branch. I'll try to investigate on Monday too.

@alexandrevilain
Copy link
Contributor Author

Ok it was only a bad rebase on my side.

/remove-hold

@alexandrevilain
Copy link
Contributor Author

alexandrevilain commented Nov 2, 2023

I had to rebase to make the CI pass.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 15, 2023
@alexandrevilain
Copy link
Contributor Author

Will try to do the rebase today.

@EmilienM
Copy link
Contributor

Hello, could we add v1alpha8 please and rebase? Thanks a lot :)

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2024
@alexandrevilain
Copy link
Contributor Author

Hello @EmilienM !

Done, waiting for CI to pass.

@alexandrevilain
Copy link
Contributor Author

@alexandrevilain alexandrevilain force-pushed the docs/add-api-reference branch 2 times, most recently from 3066a8c to e80879c Compare February 22, 2024 10:29
@EmilienM
Copy link
Contributor

      unable to install CRDs onto control plane: unable to create CRD instances: unable to create CRD "openstackclustertemplates.infrastructure.cluster.x-k8s.io": CustomResourceDefinition.apiextensions.k8s.io "openstackclustertemplates.infrastructure.cluster.x-k8s.io" is invalid: [spec.versions: Invalid value: []apiextensions.CustomResourceDefinitionVersion{apiextensions.CustomResourceDefinitionVersion{Name:"v1alpha5", Served:false, Storage:false, Deprecated:true, DeprecationWarning:(*string)(0xc0038adfd0), Schema:(*apiextensions.CustomResourceValidation)(0xc0008d4a58), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}, apiextensions.CustomResourceDefinitionVersion{Name:"v1alpha6", Served:true, Storage:false, Deprecated:false, DeprecationWarning:(*string)(nil), Schema:(*apiextensions.CustomResourceValidation)(0xc0008d4b98), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}, apiextensions.CustomResourceDefinitionVersion{Name:"v1alpha7", Served:true, Storage:true, Deprecated:false, DeprecationWarning:(*string)(nil), Schema:(*apiextensions.CustomResourceValidation)(0xc0008d4bb0), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}, apiextensions.CustomResourceDefinitionVersion{Name:"v1alpha8", Served:true, Storage:true, Deprecated:false, DeprecationWarning:(*string)(nil), Schema:(*apiextensions.CustomResourceValidation)(0xc0008d4c50), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}}: must have exactly one version marked as storage version, status.storedVersions: Invalid value: []string{"v1alpha7"}: must have the storage version v1alpha8]

I'm not sure why we have this error, let us know if you need help on this one.

@mdbooth I would love to get this one at some point, not blocking anything but I'm glad @alexandrevilain can still work on it.
Thanks

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2024
@alexandrevilain
Copy link
Contributor Author

@EmilienM I rebased and re-run make generate. Will see if it works

api/v1alpha8/doc.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2024
@alexandrevilain alexandrevilain force-pushed the docs/add-api-reference branch 2 times, most recently from 0fe9409 to 69baa16 Compare February 28, 2024 16:34
Signed-off-by: alexandre.vilain <alexandre.vilain@corp.ovh.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2024
@alexandrevilain
Copy link
Contributor Author

@EmilienM CI is now green 👍

@EmilienM
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2024
@k8s-ci-robot k8s-ci-robot merged commit 36e94d9 into kubernetes-sigs:main Feb 28, 2024
9 checks passed
@alexandrevilain alexandrevilain deleted the docs/add-api-reference branch February 29, 2024 08:48
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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 reference documentation automatically from godocs in the API
7 participants