Skip to content

Commit 485b386

Browse files
authored
Merge pull request #21729 from LasseRosenow/fix-guides-code-blocks
doc/guides: Fix code block indentation and improve board file structure ASCII art
2 parents 30a2b27 + cfb7af9 commit 485b386

File tree

7 files changed

+141
-131
lines changed

7 files changed

+141
-131
lines changed

doc/guides/advanced_tutorials/creating_modules.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,47 +114,47 @@ These modules appear in RIOT under two forms:
114114

115115
1. Conditionally included source files:
116116

117-
```
118-
foo/
119-
|----foo_bar.c
120-
|----foo.c
121-
|----Makefile
122-
```
117+
```
118+
foo
119+
├── foo_bar.c
120+
├── foo.c
121+
└── Makefile
122+
```
123123

124124
In `foo/Makefile` you add the source file to the `SRC` variable, conditioned on
125125
the Pseudomodule inclusion
126126

127-
```makefile
128-
ifneq (,$(filter foo_bar,$(USEMODULE)))
129-
SRC += foo_bar.c
130-
endif
131-
```
127+
```makefile
128+
ifneq (,$(filter foo_bar,$(USEMODULE)))
129+
SRC += foo_bar.c
130+
endif
131+
```
132132

133133
See `sys/net/ble/skald` for an example in code.
134134

135135
2. Using the `SUBMODULES` mechanism:
136136

137-
```
138-
foo/
139-
|----spam.c
140-
|----ham.c
141-
|----eggs.c
142-
|----Makefile
143-
```
137+
```
138+
foo
139+
├── spam.c
140+
├── ham.c
141+
├── eggs.c
142+
└── Makefile
143+
```
144144

145-
```makefile
146-
# make all code end up in "foo_bar.a", this can be any name
147-
MODULE := foo_bar
145+
```makefile
146+
# make all code end up in "foo_bar.a", this can be any name
147+
MODULE := foo_bar
148148

149-
# ensure that "foo_ham" or "bar_foo_ham" builds "foo_ham.c".
150-
BASE_MODULE := foo
149+
# ensure that "foo_ham" or "bar_foo_ham" builds "foo_ham.c".
150+
BASE_MODULE := foo
151151

152-
# list of source files that are not SUBMODULES
153-
SRC := spam.c
152+
# list of source files that are not SUBMODULES
153+
SRC := spam.c
154154

155-
# enable submodules by setting SUBMODULES = 1
156-
SUBMODULES = 1
157-
```
155+
# enable submodules by setting SUBMODULES = 1
156+
SUBMODULES = 1
157+
```
158158

159159
When using `SUBMODULES` in a `MODULE` all `SRC` file excluded from `foo/Makefile`
160160
will be considered `SUBMODULES`. In the example above `ham.c` and `eggs.c`.

doc/guides/advanced_tutorials/porting_boards.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ although not all of the subdirectories or Makefiles have to be present for
3232
a board implementation to work.
3333

3434
```
35-
board-foo/
36-
|----dist/
37-
|----scripts
38-
|----board.c
39-
|----doc.md
40-
|----include/
41-
|----periph_conf.h
42-
|----board.h
43-
|----gpio_params.h
44-
|----Makefile
45-
|----Makefile.dep
46-
|----Makefile.features
47-
|----Makefile.include
35+
board-foo
36+
├── dist
37+
└── scripts
38+
├── board.c
39+
├── doc.md
40+
├── include
41+
├── periph_conf.h
42+
├── board.h
43+
└── gpio_params.h
44+
├── Makefile
45+
├── Makefile.dep
46+
├── Makefile.features
47+
└── Makefile.include
4848
```
4949

5050
## Source Files
@@ -170,7 +170,7 @@ The default serial port configuration is provided by
170170
`makefiles/tools/serial.inc.mk` and defines the following values for the serial
171171
port (depending on the host OS):
172172

173-
```
173+
```makefile
174174
PORT_LINUX ?= /dev/ttyACM0
175175
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
176176
```
@@ -201,6 +201,10 @@ It can be measured by running `tests/sys/ztimer_overhead` on your board, i.e:
201201

202202
```bash
203203
$ BOARD=my-new-board make -C tests/sys/ztimer_overhead flash term
204+
```
205+
206+
This should give the following output:
207+
```
204208
main(): This is RIOT!
205209
ZTIMER_USEC auto_adjust params:
206210
ZTIMER_USEC->adjust_set = xx
@@ -346,23 +350,23 @@ commonly be done in your application `Makefile` or your environment). You can
346350
specify multiple directories separated by spaces.
347351

348352
```
349-
/home/
350-
|----RIOT/
351-
|---- ...
352-
|----external-boards/
353-
|----board-foo/
354-
|----dist/
355-
|----scripts
356-
|----board.c
357-
|----doc.md
358-
|----include/
359-
|----periph_conf.h
360-
|----board.h
361-
|----gpio_params.h
362-
|----Makefile
363-
|----Makefile.dep
364-
|----Makefile.features
365-
|----Makefile.include
353+
/home
354+
├── RIOT
355+
└── ...
356+
└── external-boards
357+
└── board-foo
358+
├── dist
359+
└── scripts
360+
├── board.c
361+
├── doc.md
362+
├── include
363+
├── periph_conf.h
364+
├── board.h
365+
└── gpio_params.h
366+
├── Makefile
367+
├── Makefile.dep
368+
├── Makefile.features
369+
└── Makefile.include
366370
```
367371

368372
If the external `BOARD` is very similar to a `BOARD` already present in
@@ -378,7 +382,7 @@ In this case some special considerations must be taken with the makefiles:
378382
one):
379383

380384
```makefile
381-
DIRS += $(RIOTBOARD)/foo-parent
385+
DIRS += $(RIOTBOARD)/foo-parent
382386
```
383387

384388
- `Makefile.include`

doc/guides/build-system/build-in-docker.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ but will need to be prefixed with `-e` (see [option-summary]).
6363

6464
e.g.:
6565

66-
```
66+
```shell
6767
DOCKER_ENVIRONMENT_CMDLINE='-e BEER_TYPE="imperial stout"' BUILD_IN_DOCKER=1 make -C examples/basic/hello-world/
6868
docker run --rm -t -u "$(id -u)" \
6969
...
@@ -105,20 +105,24 @@ A subset of these variables, namely variables relating to dependency resolution
105105
are therefore unconditionally passed to docker. The complete list can be found
106106
under `DOCKER_ENV_VARS_ALWAYS`.
107107

108-
#### CFLAGS
108+
### CFLAGS
109109

110110
CFLAGS are not automatically passed to docker because they might contain spaces,
111111
'"' or other characters that will require escaping. The solution is to pass it with
112112
`DOCKER_ENVIRONMENT_CMDLINE` and escape every character as required.
113113

114114
e.g: if wanting to override STRING_WITH_SPACES
115115

116+
#### Normal Build
117+
118+
```shell
119+
CFLAGS='-DSTRING_WITH_SPACES="\"with space\""' make
116120
```
117-
# normal build
118-
CFLAGS=-DSTRING_WITH_SPACES='\"with space\" make
119-
# in docker
120-
DOCKER_ENVIRONMENT_CMDLINE='-e CFLAGS=-DSTRING_WITH_SPACES=\'\\\"with\ space\\\"\'' \
121-
BUILD_IN_DOCKER=1 make
121+
122+
#### In Docker
123+
124+
```shell
125+
DOCKER_ENVIRONMENT_CMDLINE="-e CFLAGS='-DSTRING_WITH_SPACES=\\\"with\ space\\\"'" BUILD_IN_DOCKER=1 make
122126
```
123127

124128
Alternatively, it is often easier to define the CFLAGS in the Makefile which gets

doc/guides/build-system/build_system_basics.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ The fact that many `FEATURES` translate directly into a `MODULE` is only by
2222
convenience.
2323

2424
e.g.
25-
26-
# all periph features correspond to a periph submodule
27-
USEMODULE += $(filter periph_%,$(FEATURES_USED))
25+
```makefile
26+
# all periph features correspond to a periph submodule
27+
USEMODULE += $(filter periph_%,$(FEATURES_USED))
28+
```
2829

2930
### Providing a FEATURE
3031

@@ -136,7 +137,7 @@ regarding these subjects.
136137

137138
## Avoid Unnecessary Export
138139

139-
```
140+
```makefile
140141
export OUTPUT = $(shell some-command)
141142
```
142143

@@ -158,7 +159,7 @@ This is why global variables need clear documentation.
158159

159160
### Recursively Expanded Variable
160161

161-
```
162+
```makefile
162163
OUTPUT = $(shell some-command $(ANOTHER_VARIABLE))
163164
```
164165

@@ -177,7 +178,7 @@ OUTPUT = $(shell some-command $(ANOTHER_VARIABLE))
177178

178179
### Simply Expanded Variable
179180

180-
```
181+
```makefile
181182
OUTPUT := $(shell some-command $(ANOTHER_VARIABLE))
182183
```
183184

@@ -195,7 +196,7 @@ OUTPUT := $(shell some-command $(ANOTHER_VARIABLE))
195196

196197
### Memoized
197198

198-
```
199+
```makefile
199200
OUTPUT = $(call memoized,OUTPUT,$(shell some-command))
200201
```
201202

doc/guides/build-system/debugging_aids.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ undefined behavior (UB).
1616
E.g., the following code might trigger UB for some parameters:
1717

1818
```c
19-
void test(int foo) {
19+
void test(int foo)
20+
{
2021
return (foo << 24);
2122
}
2223
```

0 commit comments

Comments
 (0)