Skip to content

Commit 29df140

Browse files
committed
update readme
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
1 parent c983e8b commit 29df140

2 files changed

Lines changed: 39 additions & 14 deletions

File tree

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
1-
# Knative API Reference Docs generator
1+
# Kubernetes Custom Resource API Reference Docs generator
22

3-
## Why?
3+
If you have a project that is Custom Resource Definitions and wanted to generate
4+
API Reference Docs [like this][ar] this tool is for you.
45

5-
Normally we would want to use [Kubernetes API
6-
reference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/)
7-
which is auto-generated. But for the time being, Kubernetes API does not provide
8-
OpenAPI specs for CRDs (e.g. Knative), therefore we cannot use the same
9-
generator.
6+
[ar]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/
107

11-
Proposal for generating API Reference docs for Knative:
12-
https://github.com/knative/docs/issues/636.
8+
## Why
139

14-
## How?
10+
Normally you would want to use the same [docs generator][dg] as [Kubernetes API
11+
reference][ar], but here's why I wrote a different parser/generator:
1512

16-
This is a custom API Reference Docs generator that uses the
13+
1. Today, Kubernetes API [does not][pr] provide OpenAPI specs for CRDs (e.g.
14+
Knative), therefore the [gen-apidocs][ga]
15+
generator used by Kubernetes won't work.
16+
17+
2. Even when Kubernetes API starts providing OpenAPI specs for CRDs, your CRD
18+
must have a validation schema (e.g. Knative API doesn't!)
19+
20+
3. Kubernetes [gen-apidocs][ga] parser relies on running a `kube-apiserver` and
21+
calling `/apis` endpoint to get OpenAPI specs to generate docs. **This tool
22+
doesn't need that!**
23+
24+
[dg]: https://github.com/kubernetes-incubator/reference-docs/
25+
[ga]: https://github.com/kubernetes-incubator/reference-docs/tree/master/gen-apidocs/generators
26+
[pr]: https://github.com/kubernetes/kubernetes/pull/71192
27+
28+
## How
29+
30+
This is a custom API reference docs generator that uses the
1731
[k8s.io/gengo](https://godoc.org/k8s.io/gengo) project to parse types and
1832
generate API documentation from it.
1933

34+
Capabilities of this tool include:
35+
36+
- Doesn't depend on OpenAPI specs, or kube-apiserver, or a running cluster.
37+
- Relies only on the Go source code (pkg/apis/**/*.go) to parse API types.
38+
- Can link to other sites for external APIs. For example, if your types have a
39+
reference to Kubernetes core/v1.PodSpec, you can link to it.
40+
- [Configurable](./example-config.json) settings to hide certain fields or types
41+
entirely from the generated output.
42+
- Either output to a file or start a live http-server (for rapid iteration).
43+
2044
## Try it out
2145

2246
1. Clone this repository.
2347

24-
2. Make sure you have go1.11+ instaled.
48+
2. Make sure you have go1.11+ instaled. Then run `go build`, you should get a
49+
`refdocs` binary executable.
2550

2651
3. Clone a Knative repository, set GOPATH correctly,
2752
and call the compiled binary within that directory.
@@ -31,8 +56,8 @@ generate API documentation from it.
3156
# goclone(1) to have a separate GOPATH for each repo I clone.)
3257
$ goclone knative/build
3358

34-
$ refdocs \
35-
-config "/path/to/knative-config.json" \
59+
$ /path/to/refdocs \
60+
-config "/path/to/example-config.json" \
3661
-api-dir "github.com/knative/build/pkg/apis/build/v1alpha1" \
3762
-out-file docs.html
3863
```
File renamed without changes.

0 commit comments

Comments
 (0)