generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 597
Improve apiref with experimental and ignored CRD description #4132
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
Open
rikatz
wants to merge
5
commits into
kubernetes-sigs:main
Choose a base branch
from
rikatz:fix-ref-doc-tmpl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−275
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
47d554f
Improve apiref with experimental and ignored CRD description
rikatz ddff277
Add warning icon on experimental API
rikatz 8134f0b
Improve table readability
rikatz 2990a97
Add experimental warning on the type field
rikatz 66c0ffe
Fix makefile, ignore specx.md properly
rikatz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,5 @@ go.work.sum | |
.venv/ | ||
release/ | ||
site-src/reference/spec.md | ||
site-src/reference/specx.md | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The templates contained in this directory were copied from https://github.com/elastic/crd-ref-docs/tree/master/templates/markdown | ||
and had the following modifications: | ||
|
||
- `type.tpl` - Adds an "experimental" marker in case the API field is marked as "experimental" | ||
- `type_members.tpl` - Removes the text between tags `<gateway:util:excludeFromCRD></gateway:util:excludeFromCRD>` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{- define "gvDetails" -}} | ||
{{- $gv := . -}} | ||
|
||
## {{ $gv.GroupVersionString }} | ||
|
||
{{ $gv.Doc }} | ||
|
||
{{- if $gv.Kinds }} | ||
### Resource Types | ||
{{- range $gv.SortedKinds }} | ||
- {{ $gv.TypeForKind . | markdownRenderTypeLink }} | ||
{{- end }} | ||
{{ end }} | ||
|
||
{{ range $gv.SortedTypes }} | ||
{{ template "type" . }} | ||
{{ end }} | ||
|
||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- define "gvList" -}} | ||
{{- $groupVersions := . -}} | ||
--- | ||
hide: | ||
- toc | ||
--- | ||
# API Reference | ||
|
||
{{- range $groupVersions }} | ||
- {{ markdownRenderGVLink . }} | ||
{{- end }} | ||
|
||
{{ range $groupVersions }} | ||
{{ template "gvDetails" . }} | ||
{{ end }} | ||
|
||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{- define "type" -}} | ||
{{- $type := . -}} | ||
{{- if markdownShouldRenderType $type -}} | ||
|
||
#### {{ $type.Name }} | ||
|
||
{{ if $type.IsAlias }}_Underlying type:_ _{{ markdownRenderTypeLink $type.UnderlyingType }}_{{ end }} | ||
|
||
{{ $type.Doc }} | ||
|
||
{{ if $type.Validation -}} | ||
_Validation:_ | ||
{{- range $type.Validation }} | ||
- {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{ if $type.References -}} | ||
_Appears in:_ | ||
{{ range $type.SortedReferences }} | ||
- {{ markdownRenderTypeLink . }} | ||
{{- range .Fields -}} | ||
{{- if eq .Type.Name $type.Name -}} | ||
{{- if contains "<gateway:experimental>" .Doc }} :warning: Experimental in `{{.Name}}` field {{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{ end }} | ||
{{- end }} | ||
|
||
{{ if $type.Members -}} | ||
| Field | Description | Default | Validation | | ||
| --- | --- | --- | --- | | ||
{{ if $type.GVK -}} | ||
| `apiVersion` _string_ | `{{ $type.GVK.Group }}/{{ $type.GVK.Version }}` | | | | ||
| `kind` _string_ | `{{ $type.GVK.Kind }}` | | | | ||
{{ end -}} | ||
|
||
{{ range $type.Members -}} | ||
| `{{ .Name }}` _{{ markdownRenderType .Type }}_ {{- if contains "<gateway:experimental>" .Doc -}}<br /> :warning: **Experimental**{{ end -}}| {{ template "type_members" . }} | {{ markdownRenderDefault .Default }} | {{ range .Validation -}} {{ markdownRenderFieldDoc . }} <br />{{ end }} | | ||
{{ end -}} | ||
|
||
{{ end -}} | ||
|
||
{{ if $type.EnumValues -}} | ||
| Field | Description | | ||
| --- | --- | | ||
{{ range $type.EnumValues -}} | ||
| `{{ .Name }}` | {{ markdownRenderFieldDoc .Doc }} | | ||
{{ end -}} | ||
{{ end -}} | ||
|
||
|
||
{{- end -}} | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{- define "type_members" -}} | ||
{{- $field := . -}} | ||
{{- if eq $field.Name "metadata" -}} | ||
Refer to Kubernetes API documentation for fields of `metadata`. | ||
{{- else -}} | ||
{{- $cleanDoc := regexReplaceAllLiteral "(?s)<gateway:util:excludeFromCRD>.*?</gateway:util:excludeFromCRD>" $field.Doc "" -}} | ||
{{ markdownRenderFieldDoc $cleanDoc }} | ||
{{- end -}} | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I think that Default and Validation could well live in the first cell of the row, under the Experimental warning, and then we can have only two columns, which should make the descriptions a lot more readable.
Maybe something like:
Ideally, we can find a way to make the table take up more of the page as well, maybe by removing the in-page TOC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last famous words: seem simple. I have tried changing the defaults and validations to first field, but the misalignment caused by some validations that are huge are worst than the current situation.
The markdown tables are not really very configurable (https://squidfunk.github.io/mkdocs-material/reference/data-tables/#column-alignment) unless we do some CSS change, so I think changing the defaults and validations here will be harder.
Removing the TOC OTOH was doable and things got a bit more clear (I will push it soon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another approach I have tried was to move defaults and validations to a tooltip/annotation like, where when you hover over an information icon it would show each of them, but still the gain is not great on the Markdown tables.
We have fields that have a type of "LocalObjectReferenceWithNamespacesAndLasers" and rendering this still makes the first column be bigger than the second