Skip to content

Commit 7a81870

Browse files
dfanglalexrashed
andauthored
Command shortcode and refactoring (#55)
* add command shortcode and refactor first documents to use it * change more commands to new shortcode * format more commands to the shortcode * fix the last of the commands * add python code type * reafactor code fences to use proper language or command shortcode * fix typo in cloudformation * add command shortcode to best practices * add more comments to the shortcode Co-authored-by: Alexander Rashed <[email protected]>
1 parent 15e1b6b commit 7a81870

File tree

40 files changed

+328
-422
lines changed

40 files changed

+328
-422
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ alternatively:
4242
## Best Practices
4343

4444
Please follow these best practices when writing documentation here:
45+
- Use the custom `command` shortcode for all one-liner commands (also when their output is presented). Do not use it for bash scripts with comments. You can find a more detailed description here: https://github.com/localstack/docs/pull/55
4546
- Use the [`ref` or `relref` shortcode](https://gohugo.io/content-management/cross-references/#use-ref-and-relref) when creating non-external links (but still use the markdown native image linking, ref doesn't work there).
4647
You can either use `ref` or `relref`, the point is to have compile time internal-link checks (which works for both).
4748
- Stick to markdown if possible.
@@ -50,6 +51,8 @@ Please follow these best practices when writing documentation here:
5051
- For snippets, define the correct syntax highlighting.
5152
Here's a list of the supported languages:
5253
https://gohugo.io/content-management/syntax-highlighting/
54+
- If you want to hightlight a specific line, there's a feature for that: https://gohugo.io/content-management/syntax-highlighting/#highlighting-in-code-fences
55+
- This is also supported by the `command` shortcode!
5356
- Handling images can be a bit tedious with Hugo.
5457
If you want to use images in your post, create a new [leaf bundle directory](https://github.com/gohugoio/hugo/issues/1240) and put the image and the post (named `index.md`) in there (you can find examples in the docs already, f.e. the cognito service docs).
5558

@@ -59,4 +62,4 @@ Please follow these best practices when writing documentation here:
5962
If you want to resize the image, use the `figure` shortcode.
6063
- Use relative paths to cross-reference between pages
6164

62-
PS.: Feel free to add more best practices here (also give us a heads-up in [#sig-docs](https://localstack-cloud.slack.com/archives/C02FZH6UB2A)).
65+
PS.: Feel free to add more best practices here (also give us a heads-up in [#sig-docs](https://localstack-cloud.slack.com/archives/C02FZH6UB2A)).

assets/scss/_variables_project.scss

+7
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,12 @@ $primary: #30638E !default;
1818
margin-top: 1em;
1919
}
2020

21+
.command-prefix {
22+
-moz-user-select: none;
23+
-webkit-user-select: none;
24+
-ms-user-select: none;
25+
user-select: none;
26+
}
27+
2128
// workaround for https://github.com/google/docsy/issues/694
2229
@import "/css/shortcodes.css";

content/en/docs/Getting started/_index.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,26 @@ Please make sure to install the following tools on your machine before moving on
4848
#### Installation
4949
The easiest way to install the LocalStack CLI is via `pip`:
5050

51-
```sh
52-
python3 -m pip install localstack
53-
```
51+
{{< command >}}
52+
$ python3 -m pip install localstack
53+
{{< / command >}}
5454

5555
{{< alert >}}
5656
**Note**: Please do **not** use `sudo` or the `root` user - LocalStack should be installed and started entirely under a local non-root user.
5757
If you have problems with permissions in MacOS X Sierra, install with `python3 -m pip install --user localstack`.
5858
{{< /alert >}}
5959

6060
Afterwards you should be able to use the LocalStack CLI in your terminal:
61-
```
61+
62+
{{< command >}}
6263
$ localstack --help
6364
Usage: localstack [OPTIONS] COMMAND [ARGS]...
6465

6566
The LocalStack Command Line Interface (CLI)
6667

6768
Options:
6869
...
69-
```
70+
{{< / command >}}
7071

7172
#### Troubleshooting
7273
##### The installation is successful, but I cannot execute `localstack` on my terminal.
@@ -75,16 +76,16 @@ If you can successfully install LocalStack using `pip` but you cannot use it in
7576
- If you are using a MacOS or Linux operating system, please make sure that the `PATH` is correctly set up - either system wide, or in your terminal.
7677

7778
As a workaround you can call the LocalStack CLI python module directly:
78-
```sh
79-
python3 -m localstack.cli.main
80-
```
79+
{{< command >}}
80+
$ python3 -m localstack.cli.main
81+
{{< / command >}}
8182

8283
#### Starting LocalStack with the LocalStack CLI
8384
By default, LocalStack is started inside a Docker container by running:
8485

85-
```sh
86-
localstack start
87-
```
86+
{{< command >}}
87+
$ localstack start
88+
{{< / command >}}
8889

8990
{{< alert title="Notes" >}}
9091
- This command starts all services provided by LocalStack.
@@ -108,9 +109,9 @@ You can check if `docker` is correctly configured on your machine by executing `
108109

109110
#### Starting LocalStack with Docker
110111
You can start the Docker container simply by executing the following `docker run` command:
111-
```
112-
docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack
113-
```
112+
{{< command >}}
113+
$ docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack
114+
{{< / command >}}
114115

115116
{{< alert title="Notes" >}}
116117
- This command pulls the current nighty build from the `master` branch (if you don't have the image locally) and **not** the latest supported version.
@@ -139,9 +140,9 @@ If you want to manually manage your Docker container, it's usually a good idea t
139140
#### Starting LocalStack with Docker-Compose
140141
You can use the [`docker-compose.yml` file from the official LocalStack repository](https://github.com/localstack/localstack/blob/master/docker-compose.yml) and use this command (currently requires `docker-compose` version 1.9.0+):
141142

142-
```
143-
docker-compose up
144-
```
143+
{{< command >}}
144+
$ docker-compose up
145+
{{< / command >}}
145146

146147
{{< alert title="Notes" >}}
147148
- This command pulls the current nighty build from the `master` branch (if you don't have the image locally) and **not** the latest supported version.
@@ -163,10 +164,10 @@ If you want to deply LocalStack in your [Kubernetes](https://kubernetes.io) clus
163164

164165
#### Deploy LocalStack using Helm
165166
You can deploy LocalStack in a Kubernetes cluster by running these commands:
166-
```sh
167-
helm repo add localstack-repo https://helm.localstack.cloud
168-
helm upgrade --install localstack localstack-repo/localstack
169-
```
167+
{{< command >}}
168+
$ helm repo add localstack-repo https://helm.localstack.cloud
169+
$ helm upgrade --install localstack localstack-repo/localstack
170+
{{< / command >}}
170171

171172
The Helm charts are not maintained in the main repository, but in a [separate one](https://github.com/localstack/helm-charts).
172173

content/en/docs/Getting started/getting-started-pro/index.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ You can find your API key in the [LocalStack Web Interface](https://app.localsta
3131
LocalStack Pro expects your API key to be present in the environment variable `LOCALSTACK_API_KEY`.
3232
Before starting LocalStack, please define the environment variable in your terminal like this:
3333

34-
```sh
34+
{{< command >}}
3535
$ export LOCALSTACK_API_KEY=<your-api-key>
36-
```
36+
{{< / command >}}
3737

3838
### Starting LocalStack Pro using the CLI
3939

4040
When starting LocalStack using the LocalStack CLI, you dot not have to perform any further steps (after exporting the environment variable).
41-
```sh
41+
{{< command >}}
4242
$ localstack start
43-
```
43+
{{< / command >}}
4444

4545
LocalStack will detect the API key and properly pass it to the LocalStack container.
4646

4747
### Starting LocalStack Pro using Docker
4848

4949
When starting LocalStack using a `docker run` command, you have to specify the API key using the `-e` flag for environment variables like this:
5050

51-
{{< highlight bash "hl_lines=5" >}}
52-
docker run \
51+
{{< command "hl_lines=5" >}}
52+
$ docker run \
5353
--rm -it \
5454
-p 4566:4566 \
5555
-p 4571:4571 \
5656
-e LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:- } \
5757
localstack/localstack
58-
{{< / highlight >}}
58+
{{< / command >}}
5959

6060
For more information about starting LocalStack, take a look at our general [Getting Started]({{< ref "Getting started" >}}) guide.
6161

@@ -79,9 +79,9 @@ If you want to make sure that LocalStack is only started if LocalStack Pro can b
7979

8080
The easiest way to check if LocalStack Pro is activated is to check the health endpoing of LocalStack for a list of the running services:
8181

82-
```
83-
curl localhost:4566/health | jq
84-
```
82+
{{< command >}}
83+
$ curl localhost:4566/health | jq
84+
{{< / command >}}
8585

8686
If a Pro-only [service]({{< ref "Local AWS Services" >}}) -- like [XRay]({{< ref "XRay-Tracing" >}}) -- is running, LocalStack Pro has started successfully.
8787

@@ -129,9 +129,9 @@ socket.gaierror: [Errno -3] Temporary failure in name resolution
129129
130130
Please confirm this by using a tool like `dig`:
131131
132-
```sh
133-
dig api.localstack.cloud
134-
```
132+
{{< command >}}
133+
$ dig api.localstack.cloud
134+
{{< / command >}}
135135
136136
If the result has some other status than `status: NOERROR`, your machine cannot resolve this domain.
137137

content/en/docs/Integrations/architect/index.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ If you are adapting an existing configuration, you might be able to skip certain
1717
## Example
1818

1919
### Setup
20-
To use Architect in conjunction with Localstack, simply install the ```arclocal``` command (sources can be found [here](https://github.com/localstack/architect-local)).
21-
```
22-
npm install -g architect-local @architect/architect aws-sdk
23-
```
24-
The ``` arclocal``` command has the same usage as the ```arc``` command, so you can start right away.
20+
To use Architect in conjunction with Localstack, simply install the `arclocal` command (sources can be found [here](https://github.com/localstack/architect-local)).
21+
{{< command >}}
22+
$ npm install -g architect-local @architect/architect aws-sdk
23+
{{< /command >}}
24+
25+
The `arclocal` command has the same usage as the `arc` command, so you can start right away.
2526

2627
Create a test directory
2728

28-
```bash
29-
mkdir architect_quickstart && cd architect_quickstart
30-
```
29+
{{< command >}}
30+
$ mkdir architect_quickstart && cd architect_quickstart
31+
{{< / command >}}
3132

3233
then create an architect project
3334

34-
```
35-
arclocal init
36-
```
35+
{{< command >}}
36+
$ arclocal init
37+
{{< / command >}}
3738

3839
### Deployment
3940

@@ -43,9 +44,9 @@ Now you need to start LocalStack. The services you need to start are
4344
- cloudformation
4445

4546
After LocalStack has started you can deploy your Architect setup via
46-
```
47-
arclocal deploy
48-
```
47+
{{< command >}}
48+
$ arclocal deploy
49+
{{< / command >}}
4950

5051
## Further reading
5152

content/en/docs/Integrations/aws-cli/index.md

+36-36
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,37 @@ All CLI commands that access [services that are implemented in LocalStack]({{< r
1313
There are two ways to use the CLI:
1414

1515
* Use our `awslocal` drop-in replacement:
16-
```
17-
awslocal kinesis list-streams
18-
```
16+
{{< command >}}
17+
$ awslocal kinesis list-streams
18+
{{< / command >}}
1919
* Configure AWS test environment variables and add the `--endpoint-url=<localstack-url>` flag to your `aws` CLI invocations.
2020
For example:
21-
```
22-
export AWS_ACCESS_KEY_ID="test"
23-
export AWS_SECRET_ACCESS_KEY="test"
24-
export AWS_DEFAULT_REGION="us-east-1"
21+
{{< command >}}
22+
$ export AWS_ACCESS_KEY_ID="test"
23+
$ export AWS_SECRET_ACCESS_KEY="test"
24+
$ export AWS_DEFAULT_REGION="us-east-1"
2525

26-
aws --endpoint-url=http://localhost:4566 kinesis list-streams
27-
```
26+
$ aws --endpoint-url=http://localhost:4566 kinesis list-streams
27+
{{< / command >}}
2828

2929
## AWS CLI
3030

3131
Use the below command to install `aws`, if not installed already.
3232

33-
```
34-
pip install awscli
35-
```
33+
{{< command >}}
34+
$ pip install awscli
35+
{{< / command >}}
3636

3737
### Setting up local region and credentials to run LocalStack
3838

3939
aws requires the region and the credentials to be set in order to run the aws commands.
4040
Create the default configuration and the credentials.
4141
Below key will ask for the Access key id, secret Access Key, region & output format.
42+
Config & credential file will be created under ~/.aws folder
4243

43-
```
44-
aws configure --profile default
45-
46-
# Config & credential file will be created under ~/.aws folder
47-
```
44+
{{< command >}}
45+
$ aws configure --profile default
46+
{{< / command >}}
4847

4948
{{< alert >}}
5049
**Note** Please use `test` as value for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to make pre-signed URLs for S3 buckets work.
@@ -68,14 +67,14 @@ The source code can be found on GitHub: https://github.com/localstack/awscli-loc
6867

6968
You can install the `awslocal` command via `pip`:
7069

71-
```
72-
pip install awscli-local[ver1]
73-
```
70+
{{< command >}}
71+
$ pip install awscli-local[ver1]
72+
{{< / command >}}
7473

7574
Note that the command above also installs the latest version of the underlying AWS CLI version 1 (`awscli`) package. Use this command if you prefer to manage your own version of `awscli` (e.g., `v1`/`v2`) and install the wrapper script only:
76-
```
77-
pip install awscli-local
78-
```
75+
{{< command >}}
76+
$ pip install awscli-local
77+
{{< / command >}}
7978

8079
{{< alert >}}
8180
**Note:** Automatic installation of AWS CLI version 2 is currently not supported yet (at the time of writing there is no official pypi package for `v2` available), but the `awslocal` technically also works with AWS CLI v2 (see [this section]({{< ref "#limitations" >}}) for more details).
@@ -107,11 +106,11 @@ To work around this issue, you have 2 options:
107106
We do not recommend this, but it is technically possible.
108107
Also, you should install these libraries in a Python virtualenv, to avoid version clashes with other libraries on your system:
109108

110-
```bash
111-
virtualenv .venv
112-
. .venv/bin/activate
113-
pip install https://github.com/boto/botocore/archive/v2.zip https://github.com/aws/aws-cli/archive/v2.zip
114-
```
109+
{{< command >}}
110+
$ virtualenv .venv
111+
$ . .venv/bin/activate
112+
$ pip install https://github.com/boto/botocore/archive/v2.zip https://github.com/aws/aws-cli/archive/v2.zip
113+
{{< / command >}}
115114

116115
## AWS CLI v2
117116

@@ -123,10 +122,11 @@ By default, the container running [amazon/aws-cli](https://docs.aws.amazon.com/c
123122

124123
To ensure that the two docker containers can communicate create a network on the docker engine:
125124

126-
```bash
125+
{{< command >}}
127126
$ docker network create localstack
128127
0c9cb3d37b0ea1bfeb6b77ade0ce5525e33c7929d69f49c3e5ed0af457bdf123
129-
```
128+
{{< / command >}}
129+
130130
Then modify the `docker-compose.yml` specifying the network to use:
131131

132132
```yaml
@@ -138,24 +138,24 @@ networks:
138138
139139
Run AWS Cli v2 docker container using this network (example):
140140
141-
```bash
141+
{{< command >}}
142142
$ docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566 lambda list-functions
143143
{
144144
"Functions": []
145145
}
146-
```
146+
{{< / command >}}
147147
148148
If you use AWS CLI v2 from a docker container often, create an alias:
149149
150-
```bash
150+
{{< command >}}
151151
$ alias laws='docker run --network localstack --rm -it amazon/aws-cli --endpoint-url=http://localstack:4566'
152-
```
152+
{{< / command >}}
153153
154154
So you can type:
155155
156-
```bash
156+
{{< command >}}
157157
$ laws lambda list-functions
158158
{
159159
"Functions": []
160160
}
161-
```
161+
{{< / command >}}

0 commit comments

Comments
 (0)