kubernetes-sigs / kubernetes-sigs/reference-docs

Emit API reference as structured Hugo shortcodes instead of HTML tables

Open
#440 13 comments 1 reaction 1 assignee Claimed by @Caesarsage View on GitHub
Dominant language
HTML
Stars
130
Forks
135
Avg merge
16h 27m
Merged PRs (30d)
3

Description

## Motivation

The current gen-apidocs markdown backend emits API reference pages as HTML tables. This works, but couples presentation to content.

A shortcode-based approach would separate structured data (field metadata) from presentation (template rendering):

```
{{< api-reference-subfield >}}
---
apiKind: Deployment
topLevelFieldName: spec
childFieldName: selector
fieldType: LabelSelector
fieldRequired: true
---
Field description here.
{{< /api-reference-subfield >}}
```

Benefits:
- Structured data accessible to Hugo templates (enables different rendering modes from the same source)
- Presentation changes via one template, not N pages
- Responsive layouts per device via Hugo template logic

## Prerequisites

- New shortcodes defined in k/website: api-reference-toplevel, api-reference-description, api-reference-subfield,
- gen-apidocs markdown backend updated to emit these instead of
- Cross-repo coordination (design RFC → shortcodes land in k/website → gen-apidocs output updated)

## Related

- Follow-up to https://github.com/kubernetes-sigs/reference-docs/issues/434 completion (markdown backend consolidation): This will give direction
- Suggested by @lmktfy https://github.com/kubernetes-sigs/reference-docs/pull/435#issuecomment-4306610705

Phase 1 is up in #458 (response code tables → markdown + class attribute, opt-in via `--backend=hugo-md`). Remaining phases under the same flag:

| # | Scope (working plan) |
|---|---|
| 2 | Query / path / body parameter tables → markdown + class |
| 3 | Operations wrapped in `{{< api-reference-http-request >}}` paired shortcode |
| 4 | Split resource-scoped vs collection-scoped operations; add `{{< api-reference-common-definition >}}` for shared types like `Status` |
| 5 | Field tables → markdown + `{{< api-field >}}` per cell + `{{< api-field-text >}}` wrapper |
| 6 | Heading restructure (`## Node object API type {#resource}`, `` ## `.spec` {#NodeSpec} ``, and similar) |
| 7 | Front matter additions: `api_metadata.apiGroup`, `code_import.go` |
| 8 | Preamble shortcodes (`api-object-preamble`, `api-collection-preamble`, `api-type-preamble`, `api-operations-preamble`) |

Suggested order: 2 + 8 first (small wins), then 3, then 7 + 6, then 5 (largest), then 4. Each phase ships as a separate PR and is a no-op when `--backend=hugo-md` is off, so default release output stays portable.

@Mike-4-prog is taking the website side in parallel: render hooks, skeleton shortcode templates, and a custom `api_reference` layout. Skeleton templates can land ahead of the matching reference-docs phases.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.