Skip to content

Commit 68596e1

Browse files
authored
Merge pull request #3435 from xrstf/improve-docs
fix docs validation in Pull Requests
2 parents 88e5a3e + 1484463 commit 68596e1

File tree

11 files changed

+104
-85
lines changed

11 files changed

+104
-85
lines changed

.github/workflows/docs-gen-and-push.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Generate and push docs
1+
name: Documentation
22

33
on:
44
# So we can trigger manually if needed
@@ -24,7 +24,7 @@ concurrency:
2424

2525
jobs:
2626
generate-and-push:
27-
name: Generate and push docs
27+
name: Generate and push
2828
runs-on: ubuntu-latest
2929
steps:
3030
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
@@ -42,4 +42,10 @@ jobs:
4242
python-version: '3.10'
4343
cache: 'pip'
4444

45+
# mike does not support giving CLI flags for mkdocs, but we also do not
46+
# want to permanently enable strict mode, so here we enable it just for this
47+
# task
48+
- run: |
49+
echo "strict: true" >> docs/mkdocs.yml
50+
4551
- run: make generate-cli-docs generate-api-docs deploy-docs

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,11 @@ update-contextual-logging: $(LOGCHECK) ## Update contextual logging
163163
.PHONY: generate-cli-docs
164164
generate-cli-docs: ## Generate cli docs
165165
git clean -fdX docs/content/reference/cli
166-
pushd . && cd docs/generators/cli-doc && go build . && popd
167-
./docs/generators/cli-doc/cli-doc -output docs/content/reference/cli
166+
cd ./docs/generators/cli-doc && go run . -output ../../content/reference/cli
168167

169168
.PHONY: generate-api-docs
170169
generate-api-docs: ## Generate api docs
171-
git clean -fdX docs/content/reference/api
170+
git clean -fdX docs/content/reference/crd
172171
docs/generators/crd-ref/run-crd-ref-gen.sh
173172

174173
VENVDIR=$(abspath docs/venv)

cli/pkg/bind/cmd/cmd.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import (
2828

2929
var (
3030
bindExampleUses = `
31-
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace.
32-
%[1]s bind apiexport root:my-service:my-export --name my-binding
31+
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace.
32+
%[1]s bind apiexport root:my-service:my-export --name my-binding
3333
34-
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace with accepted permission claims.
35-
%[1]s bind apiexport root:my-service:my-export --name my-binding --accept-permission-claim secrets.core,configmaps.core
34+
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace with accepted permission claims.
35+
%[1]s bind apiexport root:my-service:my-export --name my-binding --accept-permission-claim secrets.core,configmaps.core
3636
37-
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace with rejected permission claims.
38-
%[1]s bind apiexport root:my-service:my-export --name my-binding --reject-permission-claim secrets.core,configmaps.core
39-
`
37+
# Create an APIBinding named "my-binding" that binds to the APIExport "my-export" in the "root:my-service" workspace with rejected permission claims.
38+
%[1]s bind apiexport root:my-service:my-export --name my-binding --reject-permission-claim secrets.core,configmaps.core
39+
`
4040
)
4141

4242
func New(streams genericclioptions.IOStreams) *cobra.Command {

cli/pkg/claims/cmd/cmd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import (
3030
// TODO: Add examples for edit and update claims.
3131
var (
3232
claimsExample = `
33-
# Lists the permission claims and their respective status related to a specific APIBinding.
34-
%[1]s claims get apibinding cert-manager
33+
# Lists the permission claims and their respective status related to a specific APIBinding.
34+
%[1]s claims get apibinding cert-manager
3535
36-
# List permission claims and their respective status for all APIBindings in current workspace.
37-
%[1]s claims get apibinding
38-
`
36+
# List permission claims and their respective status for all APIBindings in current workspace.
37+
%[1]s claims get apibinding
38+
`
3939
)
4040

4141
// New returns a cobra.Command for claims related actions.

cli/pkg/crd/cmd/cmd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import (
2828

2929
var (
3030
crdExample = `
31-
# Convert a CRD in a yaml file to an APIResourceSchema. For a CRD named widgets.example.io, and a prefix value of
32-
# 'today', the new APIResourceSchema's name will be today.widgets.example.io.
33-
%[1]s crd snapshot -f crd.yaml --prefix 2022-05-07 > api-resource-schema.yaml
31+
# Convert a CRD in a yaml file to an APIResourceSchema. For a CRD named widgets.example.io, and a prefix value of
32+
# 'today', the new APIResourceSchema's name will be today.widgets.example.io.
33+
%[1]s crd snapshot -f crd.yaml --prefix 2022-05-07 > api-resource-schema.yaml
3434
35-
# Convert a CRD from STDIN
36-
kubectl get crd foo -o yaml | %[1]s crd snapshot -f - --prefix today > output.yaml
35+
# Convert a CRD from STDIN
36+
kubectl get crd foo -o yaml | %[1]s crd snapshot -f - --prefix today > output.yaml
3737
`
3838
)
3939

cli/pkg/workspace/cmd/cmd.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,44 @@ import (
3030

3131
var (
3232
workspaceExample = `
33-
# shows the workspace you are currently using
34-
%[1]s workspace .
33+
# shows the workspace you are currently using
34+
%[1]s workspace .
3535
36-
# enter a given workspace (this will change the current-context of your current KUBECONFIG)
37-
%[1]s workspace use my-workspace
36+
# enter a given workspace (this will change the current-context of your current KUBECONFIG)
37+
%[1]s workspace use my-workspace
3838
39-
# short-hand for the use syntax
40-
%[1]s workspace my-workspace
39+
# short-hand for the use syntax
40+
%[1]s workspace my-workspace
4141
42-
# enter a given absolute workspace
43-
%[1]s workspace :root:default:my-workspace
42+
# enter a given absolute workspace
43+
%[1]s workspace :root:default:my-workspace
4444
45-
# short-hand for the current root workspace
46-
%[1]s workspace :
45+
# short-hand for the current root workspace
46+
%[1]s workspace :
4747
48-
# enter a given relative workspace
49-
%[1]s workspace some:nested:workspace
48+
# enter a given relative workspace
49+
%[1]s workspace some:nested:workspace
5050
51-
# enter the parent workspace
52-
%[1]s workspace ..
51+
# enter the parent workspace
52+
%[1]s workspace ..
5353
54-
# enter the grand parent workspace
55-
%[1]s workspace ..:..
54+
# enter the grand parent workspace
55+
%[1]s workspace ..:..
5656
57-
# enter the previous workspace
58-
%[1]s workspace -
57+
# enter the previous workspace
58+
%[1]s workspace -
5959
60-
# go to your home workspace
61-
%[1]s workspace
60+
# go to your home workspace
61+
%[1]s workspace
6262
63-
# create a workspace and immediately enter it
64-
%[1]s workspace create my-workspace --enter
63+
# create a workspace and immediately enter it
64+
%[1]s workspace create my-workspace --enter
6565
66-
# create a context with the current workspace, e.g. root:default:my-workspace
67-
%[1]s workspace create-context
66+
# create a context with the current workspace, e.g. root:default:my-workspace
67+
%[1]s workspace create-context
6868
69-
# create a context with the current workspace, named context-name
70-
%[1]s workspace create-context context-name
69+
# create a context with the current workspace, named context-name
70+
%[1]s workspace create-context context-name
7171
`
7272
)
7373

docs/content/concepts/apis/exporting-apis.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ exported APIs need to know and reference it.
159159

160160
Given 2 Workspaces, each with its own `APIExport` that exports `widgets.example.kcp.io`, kcp uses the identity hash (in
161161
a mostly transparent manner) to ensure the correct instances associated with the appropriate `APIResourceSchema` are
162-
served to clients. See [Run Your Controller](#Run-Your-Controller) for more information.
162+
served to clients. See [Build Your Controller](#build-your-controller) for more information.
163163

164164
### Permission Claims
165165

166166
When a consumer creates an `APIBinding` that binds to an `APIExport`, the API provider who owns the `APIExport`
167167
implicitly has access to instances of the exported APIs in the consuming workspace. There are also times when the API
168168
provider needs to access additional resource data in a consuming workspace. These resources might come from other
169-
APIExports the consumer has created `APIBindings` for, or from APIs that are built in to kcp. The API provider
170-
requests access to these additional resources by adding `PermissionClaims` for the desired API's group, resource, and
171-
identity hash to their `APIExport`. Let's take the example `APIExport` from above and add permission claims for
169+
APIExports the consumer has created `APIBindings` for, or from APIs that are built in to kcp. The API provider
170+
requests access to these additional resources by adding `PermissionClaims` for the desired API's group, resource, and
171+
identity hash to their `APIExport`. Let's take the example `APIExport` from above and add permission claims for
172172
`ConfigMaps` and `Things`:
173173

174174
```yaml
@@ -196,9 +196,9 @@ spec:
196196
3. To claim another exported API, you must include its `identityHash`
197197
4. If you aren't claiming access to individual instances, you must specify `all` instead
198198

199-
This is essentially a request from the APIProvider, asking each consumer to grant permission for the claimed
199+
This is essentially a request from the APIProvider, asking each consumer to grant permission for the claimed
200200
resources. If the consumer does not accept a permission claim, the API Provider is not allowed to access the claimed
201-
resources. Consumer acceptance of permission claims is part of the `APIBinding` spec. For more details, see the
201+
resources. Consumer acceptance of permission claims is part of the `APIBinding` spec. For more details, see the
202202
section on [APIBindings](#apibinding).
203203

204204
### Maximal Permission Policy
@@ -207,7 +207,7 @@ If you want to set an upper bound on what is allowed for a consumer of your expo
207207
permission policy" using standard RBAC resources. This is optional; if the policy is not set, no upper bound is applied,
208208
and a consuming user is authorized based on the RBAC configuration in the consuming workspace.
209209

210-
The maximal permission policy consists of RBAC `(Cluster)Roles` and `(Cluster)RoleBindings`. Incoming requests to a
210+
The maximal permission policy consists of RBAC `(Cluster)Roles` and `(Cluster)RoleBindings`. Incoming requests to a
211211
workspace that binds to an APIExport are additionally checked against
212212
these rules, with the username and groups prefixed with `apis.kcp.io:binding:`.
213213

@@ -227,7 +227,7 @@ spec:
227227
local: {} # (1)
228228
```
229229

230-
1. `local` is the only supported option at the moment. "Local" means the RBAC policy is defined in the same
230+
1. `local` is the only supported option at the moment. "Local" means the RBAC policy is defined in the same
231231
workspace as the `APIExport`.
232232

233233
We don't want users to be able to mutate the `status` subresource, so we set up
@@ -269,14 +269,14 @@ subjects:
269269
name: apis.kcp.io:binding:system:authenticated # (1)
270270
```
271271

272-
1. Note the `apis.kcp.io:binding:` prefix; this identifies this `ClusterRoleBinding` as part of the maximal
272+
1. Note the `apis.kcp.io:binding:` prefix; this identifies this `ClusterRoleBinding` as part of the maximal
273273
permission policy. It applies to `system:authenticated`.
274274

275-
Now imagine a user named `unicorn` with group `system:authenticated`. They create a workspace named
276-
`magic` and bind to the `tenancy.kcp.io` APIExport from the workspace `root`. What actions `unicorn` is allowed to
275+
Now imagine a user named `unicorn` with group `system:authenticated`. They create a workspace named
276+
`magic` and bind to the `tenancy.kcp.io` APIExport from the workspace `root`. What actions `unicorn` is allowed to
277277
perform in the `magic` workspace must be granted by **both**:
278278

279-
1. the standard RBAC authorization flow in the `magic` workspace; i.e., `(Cluster)Roles` and `(Cluster)RoleBindings`
279+
1. the standard RBAC authorization flow in the `magic` workspace; i.e., `(Cluster)Roles` and `(Cluster)RoleBindings`
280280
in the `magic` workspace itself, **and**
281281
2. the maximal permission policy RBAC settings configured in the `root` workspace for the `tenancy` APIExport
282282

docs/content/concepts/terminology.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where different logical clusters can be used by different users in the organizat
2323
The kcp server only provides resources to accomplish this, such as `LogicalCluster`, `Workspace`, `APIBinding` and
2424
`APIExport`, on top of some core Kubernetes resources, like `ConfigMap` and `Secret`. It doesn't provide Kubernetes
2525
resources for managing and orchestrating workloads, such as Pods and Deployments. The list of resources provided by
26-
default can be found in the [Built-in APIs document](../apis/built-in).
26+
default can be found in the [Built-in APIs document](apis/built-in.md).
2727

2828
kcp follows the Kubernetes API semantics in each logical cluster, i.e. kcp should be conformant to the subset of the
2929
Kubernetes conformance suite that applies to the APIs available in kcp. In other words, if you're building a platform
@@ -107,7 +107,7 @@ A Workspace's path is based on the hierarchy and the user provided name. For exa
107107

108108
The workspace path is used for building the workspace URL and for accessing the workspace via the `ws` kubectl plugin.
109109

110-
More information, including examples, can be found in the the [Workspaces document](../workspaces).
110+
More information, including examples, can be found in the the [Workspaces document](workspaces/index.md).
111111

112112
### Workspace Types
113113

@@ -118,10 +118,10 @@ Workspaces have types, which are mostly oriented around a set of default or opti
118118
- a workspace intended for building Knative functions might expose only the Knative serving APIs, ConfigMaps, Secrets,
119119
and optionally enable Knative Eventing APIs.
120120

121-
By default, each workspace has the [built-in APIs installed and available to its users](./apis/built-in).
121+
By default, each workspace has the [built-in APIs installed and available to its users](apis/built-in.md).
122122

123123
More information, including a list of Workspace Types and examples, can be found in the
124-
[Workspace Types document](../workspaces/workspace-types/).
124+
[Workspace Types document](workspaces/workspace-types.md).
125125

126126
## Virtual Workspaces
127127

@@ -131,7 +131,7 @@ HTTP path structure, with each (virtual) logical cluster having its own HTTP end
131131
As with kcp itself, each of these endpoints looks like a Kubernetes cluster on its own, i.e. with `/api/v1` and API
132132
groups under `/apis/<group>/<version>`.
133133

134-
The Virtual Logical Clusters are called virtual because they don’t actually have their own storage, i.e. they are not
134+
The Virtual Logical Clusters are called virtual because they don’t actually have their own storage, i.e. they are not
135135
a source of truth, instead they are just proxied representations of the real logical clusters from kcp. In the process
136136
of proxying, the Virtual Workspace API server might filter the visible objects, hide certain API groups completely, or
137137
even transform objects depending on the use case (e.g. strip the sensitive data). Also, the permission semantics might
@@ -157,7 +157,7 @@ the objects for the resources they provide and potentially other related objects
157157
It's important to note that the Virtual Workspaces are not necessarily read-only, but that they can also mutate
158158
resources in the corresponding real logical cluster.
159159

160-
**Finally, for brevity, the Virtual Workspace API server is often simply called the Virtual Workspace.**
160+
**Finally, for brevity, the Virtual Workspace API server is often simply called the Virtual Workspace.**
161161
The Virtual Workspace doesn't exist as a resource in kcp, it's purely a very flexible API (server) that can connect to
162162
the kcp server for the sake of gathering and mutating the needed objects.
163163

@@ -170,7 +170,7 @@ binary alongside the kcp server.
170170
In a sharded setup, you need to run the Virtual Workspace (API server) for each kcp shard/server that you have.
171171

172172
More information, including concrete examples and a list of frequently asked questions, can be found in the
173-
[Virtual Workspaces document](../workspaces/virtual-workspaces/).
173+
[Virtual Workspaces document](workspaces/virtual-workspaces.md).
174174

175175
## Exporting/Binding APIs
176176

@@ -207,7 +207,7 @@ In the sense of kcp, sharding involves:
207207

208208
A shard hosts its own set of Workspaces. The sharding mechanism in kcp allows you to make the workspace hierarchy span
209209
many shards transparently, while ensuring you can bind APIs from logical clusters running in different shards.
210-
The [Sharding documentation](./sharding/shards/) has more details about possibilities of sharding, and we strongly
210+
The [Sharding documentation](sharding/shards.md) has more details about possibilities of sharding, and we strongly
211211
recommend reading this document if you want to shard your kcp setup.
212212

213213
In a sharded setup, you'll be sending requests to a component called Front Proxy (`kcp-front-proxy`) instead to a

docs/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import copy
16+
import os.path
1617

1718
def define_env(env):
1819
"""
@@ -55,10 +56,10 @@ def section_items(page, nav, config):
5556

5657
# Copy so we don't modify the original
5758
child = copy.deepcopy(child)
58-
59-
# Subsection nesting that works across any level of nesting
60-
# Replaced mkdocs fix_url function
61-
child.file.url = child.url.replace(page.url, "./")
59+
60+
# mkdocs hates if a link in the generated Markdown (!) is already a fully-fledged URL
61+
# and not a link to a file anymore, so we replace the URL with the file path here.
62+
child.file.url = os.path.basename(child.file.src_uri)
6263
siblings.append(child)
6364

6465
return siblings

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mike==2.1.3
22
mkdocs==1.5.3
33
mkdocs-awesome-pages-plugin==2.9.2
4-
mkdocs-macros-plugin==1.0.5
4+
mkdocs-macros-plugin==1.3.7
55
mkdocs-material==9.5.17
66
mkdocs-material-extensions==1.3.1
77
mkdocs-static-i18n==1.2.2

0 commit comments

Comments
 (0)