Skip to content

Commit ab8b3af

Browse files
authored
feat: move the $ shell line indicator to scss (#1354)
1 parent e2bace8 commit ab8b3af

36 files changed

+343
-317
lines changed

assets/scss/_grpc.scss

+26
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ body:not(.td-blog) .td-content:not(.list-page) {
154154
}
155155
}
156156

157+
// Render the bash $ prefix indicator to enable easier copy of cli commands
158+
.td-contentdiv.highlightpre {
159+
padding-left: 0.5rem;
160+
code.language-sh:before {
161+
content: "$";
162+
margin-left: 0.5rem;
163+
}
164+
code.language-shspan {
165+
display: inline!important;
166+
margin-left: 0.25rem;
167+
}
168+
}
169+
170+
// Render the powershell > prefix indicator to enable easier copy of cli commands
171+
.td-contentdiv.highlightpre {
172+
padding-left: 0.5rem;
173+
code.language-powershell:before {
174+
content: ">";
175+
margin-left: 0.5rem;
176+
}
177+
code.language-powershellspan {
178+
display: inline!important;
179+
margin-left: 0.25rem;
180+
}
181+
}
182+
157183
/*
158184
The following contains some styles in use on the top-level pages
159185
(About, Community...). Bootstrap provides many responsive utilities

content/en/blog/bazel-rules-protobuf.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ To best follow along,
4141
and clone the rules_protobuf repository:
4242

4343
```sh
44-
~$ git clone https://github.com/pubref/rules_protobuf
45-
~$ cd rules_protobuf
44+
git clone https://github.com/pubref/rules_protobuf
45+
cd rules_protobuf
4646
~/rules_protobuf$
4747
```
4848

@@ -89,7 +89,7 @@ Let's look at the file tree, showing only those folder having a
8989
`BUILD` file:
9090

9191
```diff
92-
$ tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/
92+
tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/
9393
.
9494
├── BUILD
9595
├── WORKSPACE
@@ -130,7 +130,7 @@ within the examples folder, and say what kind of thing it is in
130130
addition to its path label"*:
131131

132132

133-
```sh
133+
```bash
134134
~/rules_protobuf$ bazel query //examples/... --output label_kind | sort | column -t
135135

136136
cc_binary rule //examples/helloworld/cpp:client
@@ -174,7 +174,7 @@ named as an external repository (more on this later) and we can also
174174
address targets in that workspace in the same way. Here's a partial
175175
list:
176176

177-
```sh
177+
```bash
178178
~/rules_protobuf$ bazel query @com_github_google_protobuf//... --output label_kind | sort | column -t
179179

180180
cc_binary rule @com_github_google_protobuf//:protoc
@@ -201,7 +201,7 @@ build all the dependent libraries, build a pristine executable binary
201201
from source, and call it (pass command line arguments to binary rules
202202
after the double-dash):
203203

204-
```sh
204+
```bash
205205
~/rules_protobuf$ bazel run @com_github_google_protobuf//:protoc -- --help
206206
Usage: /private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf/bazel-out/local-fastbuild/bin/external/com_github_google_protobuf/protoc [OPTION] PROTO_FILES
207207
Parse PROTO_FILES and generate output based on the options given:
@@ -322,7 +322,7 @@ via a compromised network.
322322
For example, we can peek at the generated BUILD file for the
323323
`maven_jar` guava dependency via:
324324

325-
```sh
325+
```bash
326326
~/rules_protobuf$ cat $(bazel info execution_root)/external/com_google_guava_guava/jar/BUILD
327327
```
328328

@@ -361,7 +361,7 @@ root package of the external workspace com_github_madler_zlib.*" Bazel
361361
reports this reverse dependency set. We request the output in
362362
graphviz format and pipe this to dot to generate the figure:
363363

364-
```sh
364+
```bash
365365
~/rules_protobuf$ bazel query "rdeps(deps(//examples/...), @com_github_madler_zlib//:zlib)" \
366366
--output graph | dot -Tpng -O
367367
```
@@ -461,7 +461,7 @@ simultaneously:
461461
```
462462

463463
```sh
464-
$ bazel build :pluriproto
464+
bazel build :pluriproto
465465
# ************************************************************
466466
cd$(bazel info execution_root)&& bazel-out/host/bin/external/com_github_google_protobuf/protoc \
467467
--plugin=protoc-gen-grpc-java=bazel-out/host/genfiles/third_party/protoc_gen_grpc_java/protoc_gen_grpc_java \
@@ -637,7 +637,7 @@ This demo application can be cloned at
637637
Here's the directory layout and relevant BUILD files we'll be using:
638638

639639
```sh
640-
~$ mkdir grpc_greetertimer &&cd grpc_greetertimer
640+
mkdir grpc_greetertimer &&cd grpc_greetertimer
641641
~/grpc_greetertimer$ mkdir -p proto/ go/ java/org/pubref/grpc/greetertimer/
642642
~/grpc_greetertimer$ touch WORKSPACE
643643
~/grpc_greetertimer$ touch proto/BUILD
@@ -795,7 +795,7 @@ go_binary(
795795
)
796796
```
797797

798-
```sh
798+
```bash
799799
~/grpc_greetertimer$ bazel build //go:client
800800
```
801801

@@ -864,7 +864,7 @@ executable jar. If these jar files have not yet been downloaded from
864864
maven central, they will be fetch as soon as we need them:
865865

866866

867-
```sh
867+
```bash
868868
~/grpc_greetertimer$ bazel build java/org/pubref/grpc/greetertimer:server
869869
~/grpc_greetertimer$ bazel build java/org/pubref/grpc/greetertimer:server_deploy.jar
870870
```
@@ -878,7 +878,7 @@ that can be run independently in a jvm.
878878

879879
First, we'll start a greeter server (one at a time):
880880

881-
```sh
881+
```bash
882882
~/grpc_greetertimer$ cd~/rules_protobuf
883883
~/rules_protobuf$ bazel run examples/helloworld/go/server
884884
~/rules_protobuf$ bazel run examples/helloworld/cpp/server
@@ -889,7 +889,7 @@ INFO: Server started, listening on 50051
889889

890890
In a separate terminal, start the greetertimer server:
891891

892-
```sh
892+
```bash
893893
~/grpc_greetertimer$ bazel build //java/org/pubref/grpc/greetertimer:server_deploy.jar
894894
~/grpc_greetertimer$ java -jar bazel-bin/java/org/pubref/grpc/greetertimer/server_deploy.jar
895895
```

content/en/blog/coreos.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ service EchoService {
5757
This means the gateway, once generated by `protoc`, can now accept a HTTP request from `curl` like this:
5858

5959
```sh
60-
$ curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
60+
curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
6161
```
6262

6363
The whole system so far looks like this, with a single `service.proto` file generating both a gRPC server and a REST proxy:
@@ -77,15 +77,15 @@ if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "applicat
7777
To try it out, all you need is a working Go 1.6 development environment and the following simple commands:
7878

7979
```sh
80-
$ go get -u github.com/philips/grpc-gateway-example
81-
$ grpc-gateway-example serve
80+
go get -u github.com/philips/grpc-gateway-example
81+
grpc-gateway-example serve
8282
```
8383

8484
With the server running you can try requests on both HTTP 1.1 and gRPC interfaces:
8585

8686
```sh
87-
$ grpc-gateway-example echo Take a REST from REST with gRPC
88-
$ curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
87+
grpc-gateway-example echo Take a REST from REST with gRPC
88+
curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
8989
```
9090

9191
One last bonus: because we have an Open API specification, you can browse the Open API UI running at `https://localhost:10000/swagger-ui/#!/EchoService/Echo` if you have the server above running on your laptop.

content/en/blog/grpc-dotnet-build.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ directory
3737

3838
Let's start by creating a new library project.
3939

40-
```sh
40+
```bash
4141
~/work$ dotnet new classlib -o MyGreeter
4242
The template "Class library" was created successfully.
4343

@@ -55,7 +55,7 @@ this exercise, we'll copy an example file [`examples/protos/helloworld.proto`
5555
](https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto)
5656
from the gRPC distribution.
5757

58-
```sh
58+
```bash
5959
~/work/MyGreeter$ rm Class1.cs
6060
~/work/MyGreeter$ wget -q https://raw.githubusercontent.com/grpc/grpc/master/examples/protos/helloworld.proto
6161
```
@@ -67,7 +67,7 @@ and use a *Save As...* command from your Web browser).
6767

6868
Next, add required NuGet packages to the project:
6969

70-
```sh
70+
```bash
7171
~/work/MyGreeter$ dotnet add package Grpc
7272
info : PackageReference for package 'Grpc' version '1.17.0' added to file '/home/kkm/work/MyGreeter/MyGreeter.csproj'.
7373
~/work/MyGreeter$ dotnet add package Grpc.Tools
@@ -131,7 +131,7 @@ idea to always do that the very first time you compile a project!
131131
Note that many output lines are omitted below, as the build output is quite
132132
verbose.
133133

134-
```sh
134+
```bash
135135
~/work/MyGreeter$ dotnet build -v:n
136136

137137
Build started 11/9/18 5:33:44 PM.
@@ -173,7 +173,7 @@ accidentally placed under source control. Otherwise, they are accessible to the
173173
tools like the debugger. You can see other autogenerated sources in that
174174
directory, too:
175175

176-
```sh
176+
```bash
177177
~/work/MyGreeter$ find obj -name '*.cs'
178178
obj/Debug/netstandard2.0/MyGreeter.AssemblyInfo.cs
179179
obj/Debug/netstandard2.0/Helloworld.cs

content/en/blog/grpc-web-ga.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ service TodoService {
7878
CommonJS client-side code can be generated from this `.proto` definition with the following command:
7979

8080
```sh
81-
$ protoc echo.proto \
81+
protoc echo.proto \
8282
--js_out=import_style=commonjs:./output \
8383
--grpc-web_out=import_style=commonjs:./output
8484
```

content/en/blog/grpc-with-json.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ final class KvService extends KvGson.KeyValueServiceImplBase {
172172
After implementing all the methods on the server, we now have a fully functioning gRPC Java, JSON encoding RPC system. And to show you there is nothing up my sleeve:
173173

174174
```sh
175-
$ ./gradlew :dependencies | grep -i proto
176-
$ # no proto deps!
175+
./gradlew :dependencies | grep -i proto
176+
# no proto deps!
177177
```
178178

179179
## Optimizing the Code
180180

181181
WhileGson is not as fast as Protobuf, there's no sense in not picking the low hanging fruit. Running the code we see the performance is pretty slow:
182182
183183
```sh
184-
$ ./gradlew installDist
185-
$ time ./build/install/kvstore/bin/kvstore
184+
./gradlew installDist
185+
time ./build/install/kvstore/bin/kvstore
186186
187187
INFO: Did 215.883 RPCs/s
188188
```
@@ -213,8 +213,8 @@ That's not right! Looking at a `RetrieveRequest`, we see that the key bytes are
213213
Using this in our marshallers, we can see a dramatic performance difference:
214214
215215
```sh
216-
$ ./gradlew installDist
217-
$ time ./build/install/kvstore/bin/kvstore
216+
./gradlew installDist
217+
time ./build/install/kvstore/bin/kvstore
218218
219219
INFO: Did 2,202.2 RPCs/s
220220
```

content/en/blog/optimizing-grpc-part-1.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ Since the code is safe and correct, let's see how it performs. For my measureme
133133
Ubuntu system with a 12 core processor and 32 GB of memory. Let's build and run the code:
134134

135135
```sh
136-
$ ./gradlew installDist
137-
$ time ./build/install/kvstore/bin/kvstore
136+
./gradlew installDist
137+
time ./build/install/kvstore/bin/kvstore
138138
Feb 26, 2018 1:10:07 PM io.grpc.examples.KvRunner runClient
139139
INFO: Starting
140140
Feb 26, 2018 1:11:07 PM io.grpc.examples.KvRunner runClient
@@ -345,8 +345,8 @@ Now the code runs successfully, and doesn't run out of memory.
345345
Building and running the code again looks a lot better:
346346

347347
```sh
348-
$ ./gradlew installDist
349-
$ time ./build/install/kvstore/bin/kvstore
348+
./gradlew installDist
349+
time ./build/install/kvstore/bin/kvstore
350350
Feb 26, 2018 2:40:47 PM io.grpc.examples.KvRunner runClient
351351
INFO: Starting
352352
Feb 26, 2018 2:41:47 PM io.grpc.examples.KvRunner runClient

content/en/blog/optimizing-grpc-part-2.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ per RPC, but a lot more are happening at the same time. Let's see if our hypoth
170170
Before:
171171

172172
```sh
173-
$ ./gradlew installDist
174-
$ time ./build/install/kvstore/bin/kvstore
173+
./gradlew installDist
174+
time ./build/install/kvstore/bin/kvstore
175175
Apr 16, 2018 10:38:42 AM io.grpc.examples.KvRunner runClient
176176
INFO: Did 24.067 RPCs/s
177177

content/en/docs/languages/cpp/basics.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ Get the example code and build gRPC:
3636
2. From the repo folder, change to the route guide example directory:
3737

3838
```sh
39-
$ cd examples/cpp/route_guide
39+
cd examples/cpp/route_guide
4040
```
4141
3. Run `cmake`
4242

4343
```sh
44-
$ mkdir -p cmake/build
45-
$ cd cmake/build
46-
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
44+
mkdir -p cmake/build
45+
cd cmake/build
46+
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
4747
```
4848

4949
### Defining the service
@@ -142,14 +142,14 @@ you want to run this yourself, make sure you've installed protoc and followed
142142
the gRPC code [installation instructions](https://github.com/grpc/grpc/blob/{{< param grpc_vers.core >}}/src/cpp/README.md#cmake) first):
143143

144144
```sh
145-
$ make route_guide.grpc.pb.o
145+
make route_guide.grpc.pb.o
146146
```
147147

148148
which actually runs:
149149

150150
```sh
151-
$ protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/route_guide.proto
152-
$ protoc -I ../../protos --cpp_out=. ../../protos/route_guide.proto
151+
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/route_guide.proto
152+
protoc -I ../../protos --cpp_out=. ../../protos/route_guide.proto
153153
```
154154

155155
Running this command generates the following files in your current directory:
@@ -502,19 +502,19 @@ independently.
502502
Build the client and server:
503503
504504
```sh
505-
$ make
505+
make
506506
```
507507
508508
Run the server:
509509
510510
```sh
511-
$ ./route_guide_server --db_path=path/to/route_guide_db.json
511+
./route_guide_server --db_path=path/to/route_guide_db.json
512512
```
513513
514514
From a different terminal, run the client:
515515
516516
```sh
517-
$ ./route_guide_client --db_path=path/to/route_guide_db.json
517+
./route_guide_client --db_path=path/to/route_guide_db.json
518518
```
519519
520520
[build and locally install gRPC from source]: {{< relref "quickstart#install-grpc" >}}

0 commit comments

Comments
 (0)
close