Skip to content

Commit ad49f21

Browse files
nataliasitkommitoraja-thaler
authored
Update README instructions (#18869)
* Update README instructions * Update README.md * Apply suggestions from code review Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com> * Apply review suggestions * Update README.md * Apply suggestions from code review Co-authored-by: Andreas Thaler <andreas.thaler01@sap.com> * remove information on labels Removed redundant text about creating labels in the README. --------- Co-authored-by: Małgorzata Świeca <malgorzata.swieca@sap.com> Co-authored-by: Andreas Thaler <andreas.thaler01@sap.com>
1 parent dc56069 commit ad49f21

1 file changed

Lines changed: 38 additions & 22 deletions

File tree

hack/table-gen/README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,56 @@
1-
# The Table Generator: Generate Documentation Tables Automatically from CRDs
1+
# Table Generator: Autogenerate CRD Documentation Tables
22

33
## Overview
44

55
This package contains a tool that automatically generates a documentation table documenting a CRD, and writes it to specified `.md` files.
66

7-
## Parameters
7+
## Generate Tables
88

9-
You must specify the following parameters:
9+
You can run the table generator in two ways:
1010

11-
- `crd-filename` - full or relative path to the `.yaml` file containing the CRD
12-
- `md-filename` - full or relative path to the `.md` file in which to insert the table rows
11+
- [Use Makefile (Recommended)](#use-makefile-recommended): Configure your CRD once and generate tables with simple `make` commands.
12+
- [Run from command line](#use-command-line): Execute directly with `go run` for quick testing or ad-hoc documentation.
1313

14-
## Set Up the Table Generator
14+
### Use Makefile (Recommended)
15+
Follow the steps:
1516

16-
Open the `.md` file you want to generate table in, and in the place where you want to insert a table, enter the tags `TABLE-START` and `TABLE-END`.
17+
1. Prepare the parameters' descriptions in the CR's specification file. For example, for the Telemetry CR, prepare the description in [`operator.kyma-project.io_telemetries.yaml`](https://github.com/kyma-project/telemetry-manager/blob/main/helm/charts/default/templates/operator.kyma-project.io_telemetries.yaml).
1718

18-
```
19-
<!-- TABLE-START -->
19+
2. Set up the table generator in the `.md` file in which you want to generate the table. Add the `TABLE-START` and `TABLE-END` tags in the exact place in the document where you want to generate the table.
2020

21-
<!-- TABLE-END -->
22-
```
21+
```bash
22+
<!-- TABLE-START -->
23+
24+
<!-- TABLE-END -->
25+
```
2326

24-
### Call the Table Generator
27+
3. Build the table generator as a binary named `table-gen`, and add a new target to your module's Makefile that calls this binary. See the following example:
2528

26-
You can call the table generator either from the command line, or with the makefile:
29+
```makefile
30+
.PHONY: crd-docs-gen
31+
crd-docs-gen:
32+
table-gen --crd-filename ./path/to/your-crd.yaml --md-filename ./docs/user/your-doc.md
33+
table-gen --crd-filename ./path/to/your-crd-2.yaml --md-filename ./docs/user/your-doc-2.md
34+
...
35+
```
36+
37+
Use the following parameters:
38+
- **--crd-filename**: Path to the CRD YAML file
39+
- **--md-filename**: Path to the Markdown file where the table will be inserted
40+
41+
For a complete example, see the [Telemetry module's Makefile](https://github.com/kyma-project/telemetry-manager/blob/main/Makefile#L185).
2742

28-
- If you want to call the table generator from the command line, you can either build it and start it, or use `go run`. See the following example:
29-
`go run main.go --crd-filename ../../installation/resources/crds/telemetry/logpipelines.crd.yaml --md-filename ../../docs/05-technical-reference/00-custom-resources/telemetry-01-logpipeline.md`
43+
4. In the terminal, run the following command from root:
3044

31-
- If you update a CRD that is already present in the makefile, you can just call `make generate`.
45+
```bash
46+
make crd-docs-gen
47+
```
48+
To verify the result, go to the `.md` files and check that the table has been generated as specified.
3249

33-
If you want to compare only a particular operator or a specific CRD, specify the label you need while calling `make`; for example, `make telemetry-docs`.
3450

35-
To update the makefile, just introduce a new label for your CRD, and then add it to the `generate`.
36-
Alternatively, if you want to group your `go run` commands, you can create different labels, group them under the one, and include it to the `generate`, the same way as with `make telemetry-docs`.
51+
### Use Command Line
3752

38-
## Verifying the Result
39-
40-
Go to the `.md` files and check that the table has been generated as specified.
53+
You can also call the table generator from the command line, without needing to add it to the Makefile. To do this, you can either build it and start it, or use `go run`. See the following example:
54+
```bash
55+
go run main.go --crd-filename ../../installation/resources/crds/telemetry/logpipelines.crd.yaml --md-filename ../../docs/05-technical-reference/00-custom-resources/telemetry-01-logpipeline.md
56+
```

0 commit comments

Comments
 (0)