Skip to content

Commit 4b587fa

Browse files
authored
Merge pull request #122 from Peefy/split-code-block-cmd-output
feat: split code block cmd input and output for the convenience of copying commands.
2 parents c7f1746 + c831840 commit 4b587fa

File tree

92 files changed

+581
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+581
-258
lines changed

blog/2022-12-06-kcl-0.4.4-release-blog/index.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,13 @@ x1 = Person {
128128

129129
Execute the following command and get the output:
130130

131-
```bash
132-
$ python3 -m kclvm hello.k
131+
```shell
132+
python3 -m kclvm hello.k
133+
```
134+
135+
The expect output is
136+
137+
```yaml
133138
name: kcl
134139
age: 1
135140
x0:
@@ -155,8 +160,13 @@ print(planner.plan(kclvm_exec.Run(["hello.k"]).filter_by_path_selector()))
155160

156161
Execute the following command and get the output:
157162

158-
```bash
159-
$ python3 main.py
163+
```shell
164+
python3 main.py
165+
```
166+
167+
The expect output is
168+
169+
```yaml
160170
name: kcl
161171
age: 1
162172
x0:

blog/2023-04-14-kcl-0.4.6-release/index.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ metadata = {
4949
Execute the following KCL command, then you can see the syntax errors including the unterminated string and the brace mismatch errors.
5050

5151
```shell
52-
$ kcl main.k
52+
kcl main.k
53+
```
54+
55+
The output is
56+
57+
```shell
5358
error[E1001]: InvalidSyntax
5459
--> main.k:2:21
5560
|
@@ -121,7 +126,12 @@ person = Person {
121126
We run the following command:
122127

123128
```shell
124-
$ kcl main.k -S person
129+
kcl main.k -S person
130+
```
131+
132+
The output is
133+
134+
```yaml
125135
name: Alice
126136
age: 18
127137
```
@@ -215,7 +225,12 @@ apps.Deployment {
215225
Execute the following command to run the KCL code to obtain an nginx deployment YAML output.
216226

217227
```shell
218-
$ kpm run
228+
kpm run
229+
```
230+
231+
The output is
232+
233+
```yaml
219234
apiVersion: apps/v1
220235
kind: Deployment
221236
metadata:

blog/2023-04-27-new-version-feature-interpretation-kclvm-go-feature-overview/index.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ spec = {
5858

5959
And then execute the KCL directly from the command line with:
6060

61-
```bash
62-
$ kcl-go run ./hello.k
61+
```shell
62+
kcl-go run ./hello.k
63+
```
64+
65+
The output is
66+
67+
```yaml
6368
apiVersion: apps/v1
6469
kind: Deployment
6570
metadata:
@@ -112,8 +117,13 @@ go get kusionstack.io/kclvm-go@main
112117

113118
The following command runs the Go program:
114119

115-
```bash
116-
$ go run main.go
120+
```shell
121+
go run main.go
122+
```
123+
124+
The output is
125+
126+
```yaml
117127
apiVersion: apps/v1
118128
kind: Deployment
119129
metadata:

blog/2023-05-20-vs-kustomize/index.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ The base directory stores the basic deployment configuration, and the prod envir
111111

112112
We can display the real deployment configuration of the prod environment through the following command.
113113

114-
```bash
115-
$ kubectl kustomize ./prod
114+
```shell
115+
kubectl kustomize ./prod
116+
```
117+
118+
The output is
119+
120+
```yaml
116121
apiVersion: apps/v1
117122
kind: Deployment
118123
metadata:
@@ -149,9 +154,13 @@ spec:
149154
150155
We can also directly apply the configuration to the cluster through the following command.
151156
152-
```bash
153-
$ kubectl apply -k ./prod
157+
```shell
158+
kubectl apply -k ./prod
159+
```
160+
161+
The output is
154162

163+
```shell
155164
deployment.apps/ldap created
156165
```
157166

@@ -244,17 +253,25 @@ diff prod-deployment.yaml deployment.yaml
244253

245254
Of course, we can also use KCL tools together with kubectl and other tools to apply the configuration of the production environment to the cluster
246255

247-
```bash
248-
$ kcl main.k -D env=prod | kubectl apply -f -
256+
```shell
257+
kcl main.k -D env=prod | kubectl apply -f -
258+
```
259+
260+
The output is
249261

262+
```shell
250263
deployment.apps/ldap created
251264
```
252265

253266
Finally, check the deployment status through kubectl
254267

255-
```bash
256-
$ kubectl get deploy
268+
```shell
269+
kubectl get deploy
270+
```
271+
272+
The output is
257273

274+
```shell
258275
NAME READY UP-TO-DATE AVAILABLE AGE
259276
ldap 0/6 6 0 15s
260277
```

blog/2023-05-30-vs-helm/index.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,13 @@ We can get the `Deployment` and `Service` resources throw the following command:
364364

365365
+ `Deployment`
366366

367-
```bash
368-
$ kcl workload-kcl/deployment.k -Y workload-kcl/kcl.yaml
367+
```shell
368+
kcl workload-kcl/deployment.k -Y workload-kcl/kcl.yaml
369+
```
370+
371+
The output is
372+
373+
```yaml
369374
apiVersion: apps/v1
370375
kind: Deployment
371376
metadata:
@@ -401,8 +406,13 @@ spec:
401406

402407
+ `Service`
403408

404-
```bash
405-
$ kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml
409+
```shell
410+
kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml
411+
```
412+
413+
The output is
414+
415+
```yaml
406416
apiVersion: v1
407417
kind: Service
408418
metadata:
@@ -425,8 +435,13 @@ spec:
425435

426436
In addition, we can overwrite the value in the `kcl.yaml` file with the `-D` parameter, such as executing the following command.
427437

428-
```bash
429-
$ kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml -D service=None
438+
```shell
439+
kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml -D service=None
440+
```
441+
442+
The output is
443+
444+
```yaml
430445
apiVersion: v1
431446
kind: Service
432447
metadata:

blog/2023-06-05-k8s-sidecar-1/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636

3737
The `Pod` is then created via the kubectl, and then the `Pod` execution status is viewed via `kubectl get po`.
3838

39-
```bash
39+
```shell
4040
$ kubectl create -f pod.yaml
4141
$ kubectl get po
4242
NAME READY STATUS RESTARTS AGE
@@ -45,7 +45,7 @@ web-app 1/1 Running 0 45m
4545

4646
You can see that a `Pod` named `web-app` is up and running properly, containing the `Nginx` service. To configure port forwarding for external access, the port 3999 of the host corresponds to port 80 of the master container:
4747

48-
```bash
48+
```shell
4949
$ kubectl port-forward web-app 3999:80
5050
Forwarding from 127.0.0.1:3999 ->80
5151
Forwarding from [::1]:3999 -> 80
@@ -59,7 +59,7 @@ Port forwarding is a blocking procedure, keep the command line open. Then open t
5959

6060
In this section, we try to add the ability to customize web pages to the `Nginx` service via Sidecar without modifying the original `Nginx` container image. Before we start, remove the previously started `Pod`:
6161

62-
```bash
62+
```shell
6363
$ kubectl delete po web-app
6464
pod "web-app" deleted
6565
```
@@ -113,7 +113,7 @@ The `Busybox` has only one function: it overwrites the `/var/log/index.html` fil
113113

114114
Then restart the Pod and remap the local host port to the container port.
115115

116-
```bash
116+
```shell
117117
$ kubectl create -f pod.yaml
118118
pod/web-app created
119119
$ kubectl port-forward web-app 3999:80

blog/2023-07-14-kcl-0.5.0-release/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ kcl-openapi generate model -f processed-${spec_path}
229229

230230
The expected execution output of the script is the corresponding version of the KCL Kubernetes model, and the generated path is `<workspace path>/models/k8s`.
231231

232-
```bash
232+
```shell
233233
$ tree models/k8s
234234
models/k8s
235235
├── api
@@ -290,7 +290,7 @@ apps.Deployment {
290290

291291
By combining the `kpm run` and `kubectl` command lines, we can directly distribute resource configurations to the cluster.
292292

293-
```bash
293+
```shell
294294
$ kpm run | kubectl apply -f -
295295

296296
deployment.apps/nginx-deployment configured
@@ -420,7 +420,7 @@ spec:
420420

421421
In the above configuration, we used a Kubernetes web service application abstract model that has been predetermined on OCI `oci://ghcr.io/kcl-lang/web-service` and configured the required configuration fields for the model through the `params` field. The original Kubernetes YAML output can be obtained and applied by executing the following command:
422422

423-
```bash
423+
```shell
424424
$ kubectl kcl apply -f krm-kcl-abstration.yaml
425425

426426
deployment.apps/app created

docs/reference/package-management/command-reference/6.login.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,37 @@ Show help for `kpm login` command.
3131
### login to a registry with account and password
3232

3333
```shell
34-
$ kpm login -u <account_name> -p <password> <oci_registry>
34+
kpm login -u <account_name> -p <password> <oci_registry>
35+
```
36+
37+
The output is
38+
39+
```shell
3540
Login succeeded
3641
```
3742

3843
### login to a registry with account, and enter the password interactively
3944

4045
```shell
41-
$ kpm login -u <account_name> <oci_registry>
46+
kpm login -u <account_name> <oci_registry>
47+
```
48+
49+
The output is
50+
51+
```shell
4252
Password:
4353
Login succeeded
4454
```
4555

4656
### login to a registry, and enter the account and password interactively
4757

4858
```shell
49-
$ kpm login <oci_registry>
59+
kpm login <oci_registry>
60+
```
61+
62+
The output is
63+
64+
```shell
5065
Username: <account_name>
5166
Password:
5267
Login succeeded

docs/reference/xlang-api/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ x1 = Person {
135135

136136
Execute the following command and get the output:
137137

138-
```bash
138+
```shell
139139
$ python3 -m kclvm hello.k
140140
name: kcl
141141
age: 1
@@ -162,7 +162,7 @@ print(planner.plan(kclvm_exec.Run(["hello.k"]).filter_by_path_selector()))
162162

163163
Execute the following command and get the output:
164164

165-
```bash
165+
```shell
166166
$ python3 main.py
167167
name: kcl
168168
age: 1

docs/tools/cli/kcl/vet.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ schema Data:
4949

5050
Execute the following command:
5151

52-
```bash
53-
$ kcl-vet data.json schema.k
52+
```shell
53+
kcl-vet data.json schema.k
5454
```
5555

5656
## Specify the schema for validation
5757

5858
When multiple schema definitions exist in the KCL file, by default, the KCL Validation tool will use the first schema to check. If you need to specify a schema for verification, you can use the `-d|--schema` parameter
5959

60-
```bash
61-
$ kcl-vet data.json schema.k -d User
60+
```shell
61+
kcl-vet data.json schema.k -d User
6262
```
6363

6464
## Args
6565

66-
```bash
66+
```shell
6767
$ kcl-vet -h
6868
USAGE:
6969
kcl-vet [OPTIONS] [ARGS]

docs/user_docs/getting-started/kcl-quick-start.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ Set the `hello` attribute to the `"KCL"` string. Then save the code to the `hell
2121
How to execute this program depends on the specific development environment, we first assume that the local macOS or Linux system has installed the `kcl` command (or enter the **Docker** environment test by `docker run --rm -it kcllang/kcl`) and then run the following command:
2222

2323
```shell
24-
$ kcl hello.k
24+
kcl hello.k
25+
```
26+
27+
The output is
28+
29+
30+
```yaml
2531
hello: KCL
2632
```
2733
@@ -123,7 +129,12 @@ database = DatabaseConfig {
123129
When executed, an error similar to the following will be generated (the displayed file path depends on the local environment):
124130

125131
```shell
126-
$ kcl server.k
132+
kcl server.k
133+
```
134+
135+
The output is
136+
137+
```shell
127138
error[E2G22]: TypeError
128139
--> /path/to/server.k:8:5
129140
|

0 commit comments

Comments
 (0)