Skip to content

Commit cf47f7f

Browse files
authored
Merge pull request #587 from bosh/more_code_formatting
More code formatting
2 parents 8895fd6 + 4532634 commit cf47f7f

33 files changed

+197
-181
lines changed

docs/code/BCP_Protocol/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ In all commands referenced below, the `\n` terminator is implicit. Some characte
5151

5252
When a connection is initially established, the pinball controller transmits the following command:
5353

54-
```
54+
``` console
5555
hello?version=1.0
5656
```
5757

5858
…where 1.0 is the version of the Backbox protocol it wants to speak. The media controller may reply with one of two responses:
5959

60-
```
60+
``` console
6161
hello?version=1.0
6262
```
6363

6464
…indicating that it can speak the protocol version named, and reporting the version it speaks, or
6565

66-
```
66+
``` console
6767
error?message=unknown protocol version
6868
```
6969

docs/code/BCP_Protocol/mode_list.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Pin controller
1111
Type: JSON Array
1212

1313
Example (Formatted for legibility; the parameter does not contain line-breaks):
14-
```
14+
``` json
1515
{
1616
"running_modes": [
1717
[
@@ -29,4 +29,4 @@ Example (Formatted for legibility; the parameter does not contain line-breaks):
2929
Each element of the array is another JSON Array with the following elements:
3030

3131
1. The name of the mode (`string`)
32-
2. The priority of the mode (`int`)
32+
2. The priority of the mode (`int`)

docs/code/BCP_Protocol/switch.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# switch (BCP command)
22
Indicates that the other side should process the changed state of a switch. When sent from the media controller to the pin controller, this is typically used to implement a virtual keyboard interface via the media controller (where the player can activate pinball machine switches via keyboard keys for testing). For example, for the media controller to tell the pin controller that the player just pushed the start button, the command would be:
33

4-
```
4+
``` console
55
switch?name=start&state=1
66
```
77

88
followed very quickly by
99

10-
```
10+
``` console
1111
switch?name=start&state=0
1212
```
1313

@@ -17,7 +17,8 @@ When sent from the pin controller to the media controller, this is used to send
1717
Pin controller or media controller
1818

1919
## Parameters
20-
## name
20+
21+
### name
2122
Type: `string`
2223

2324
This is the name of the switch.

docs/code/Writing_Tests/RunUnitTests.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Once MPF is installed, you can run some automated tests to make sure that everything is working. To do this, open a command prompt, and then type the following command and then press <enter>:
55

6-
```
6+
``` console
77
python3 -m unittest discover mpf/tests
88
```
99

@@ -13,7 +13,7 @@ When you do this, you should see a bunch of dots on the screen (one for each tes
1313

1414
The important thing is that when the tests are done, you should have a message like this:
1515

16-
```
16+
``` console
1717
Ran 587 tests in 27.121s
1818

1919
OK
@@ -27,7 +27,7 @@ These tests are the actual tests that the developers of MPF use to test MPF itse
2727

2828
Remember though that MPF is actually two separate parts, the MPF game engine and the MPF media controller. The command you run just tested the game engine, so now let’s test the media controller. To do this, run the following command (basically the same thing as last time but with an “mc” added to the end, like this):
2929

30-
```
30+
``` console
3131
python3 -m unittest discover mpfmc/tests
3232
```
3333

docs/code/Writing_Tests/WritingCustomTestsForYourMachine.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ These test methods will also load the machine config files (just like if the com
5151

5252
Anyway, in our test method, we have the only actual line that does anything:
5353

54-
```
54+
``` python
5555
self.assertModeRunning('attract')
5656
```
5757

@@ -63,7 +63,7 @@ You can run your tests via the command prompt from your machine folder. (In othe
6363

6464
The exact command to run is `python -m unittest`. This should produce output similar to the following:
6565

66-
```
66+
``` console
6767
C:\pinball\your_machine>python -m unittest
6868
C:\Python34\lib\imp.py:32: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
6969
PendingDeprecationWarning)
@@ -82,13 +82,13 @@ That warning about the deprecation can be ignored (if you even have it.. you mig
8282

8383
When you’re writing unit tests, you’ll end up dealing with failed tests a lot! So let’s purposefully change the test so it fails. In this case, change the line which asserts a mode called “attract” is running to look for a mode called “foo” instead, like this:
8484

85-
```
85+
``` python
8686
self.assertModeRunning('foo')
8787
```
8888

8989
Save the file and rerun the tests and you should see results like this:
9090

91-
```
91+
``` console
9292
C:\pinball\your_machine>python -m unittest
9393
C:\Python34\lib\imp.py:32: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
9494
PendingDeprecationWarning)

docs/code/api_reference/misc_components/Players.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ This Player class is responsible for tracking player variables which is a dictio
1717

1818
First, player variables can be accessed as attributes of the player object directly. For example, to set a player variable foo for the current player, you could use:
1919

20-
```
20+
``` python
2121
self.machine.player.foo = 0
2222
```
2323

2424
If that variable didn’t exist, it will be automatically created.
2525

2626
You can get the value of player variables by accessing them directly. For example:
2727

28-
```
28+
``` python
2929
print(self.machine.player.foo) # prints 0
3030
```
3131

@@ -44,7 +44,7 @@ For the change parameter, it will attempt to subtract the old value from the new
4444

4545
For examples, the following three lines:
4646

47-
```
47+
``` python
4848
self.machine.player.score = 0
4949
self.machine.player.score += 500
5050
self.machine.player.score = 1200

docs/code/api_reference/misc_components/RGBAColor.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Parameters:
3434

3535
Returns: An RGBColor object that is a blend between the start and end
3636

37+
`red`
38+
39+
Return the red component of the RGB color representation.
3740

3841
`blue`
3942

@@ -54,7 +57,7 @@ Convert a HEX color representation to an RGB color representation.
5457
Parameters:
5558

5659
* **hex_string** – The 3- or 6-char hexadecimal string representing the color value.
57-
* **default** – The default value to return if _hex is invalid.
60+
* **default** – The default value to return if \_hex is invalid.
5861

5962
Returns: RGB representation of the input HEX value as a 3-item tuple
6063
with each item being an integer 0-255.
@@ -76,9 +79,6 @@ If the name is not found, the default value is returned. :param name: A standard
7679
Generate a uniformly random RGB value.
7780
Returns: A tuple of three integers with values between 0 and 255 inclusive
7881

79-
`red`
80-
81-
Return the red component of the RGB color representation.
8282

8383
`rgb`
8484

@@ -88,7 +88,7 @@ Return an RGB representation of the color.
8888

8989
Convert an RGB color representation to a HEX color representation.
9090

91-
```
91+
``` python
9292
(r, g, b) :: r -> [0, 255]
9393
g -> [0, 255] b -> [0, 255]
9494
```

docs/code/api_reference/misc_components/RGBColor.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ Parameters:
3232
* **end_color** – The end color
3333
* **fraction** – The fraction between 0 and 1 that is used to set the blend point between the two colors.
3434

35-
Returns: An RGBColor object that is a blend between the start and end
35+
Returns: An RGBColor object that is a blend between the start and end.
3636

3737

38+
`red`
39+
40+
Return the red component of the RGB color representation.
41+
3842
`blue`
3943

4044
Return the blue component of the RGB color representation.
@@ -54,7 +58,7 @@ Convert a HEX color representation to an RGB color representation.
5458
Parameters:
5559

5660
* **hex_string** – The 3- or 6-char hexadecimal string representing the color value.
57-
* **default** – The default value to return if _hex is invalid.
61+
* **default** – The default value to return if \_hex is invalid.
5862

5963
Returns: RGB representation of the input HEX value as a 3-item tuple
6064
with each item being an integer 0-255.
@@ -76,19 +80,15 @@ If the name is not found, the default value is returned. :param name: A standard
7680
Generate a uniformly random RGB value.
7781
Returns: A tuple of three integers with values between 0 and 255 inclusive
7882

79-
`red
83+
`rgb`
8084

81-
Return the red component of the RGB color representation.
82-
83-
`rgb
84-
`
8585
Return an RGB representation of the color.
8686

8787
`static rgb_to_hex(rgb: Tuple[int, int, int]) → str`
8888

8989
Convert an RGB color representation to a HEX color representation.
9090

91-
```
91+
``` python
9292
(r, g, b) :: r -> [0, 255]
9393
g -> [0, 255] b -> [0, 255]
9494
```

docs/code/api_reference/misc_components/UtilityFunctions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ For example, in the traditional python dictionary update() methods, if a diction
5555

5656
Consider the following example:
5757

58-
Original dictionary: config[foo][bar] = 1
58+
Original dictionary: `config['foo']['bar'] = 1`
5959

60-
New dictionary we’re merging in: config[foo][other_bar] = 2
60+
New dictionary we’re merging in: `config['foo']['other_bar'] = 2`
6161

6262
Default python dictionary update() method would have the updated dictionary as this:
6363

64-
```
65-
{foo: {other_bar: 2}}
64+
``` python
65+
{'foo': {'other_bar': 2}}
6666
```
6767

6868
This happens because the original dictionary which had the single key bar was overwritten by a new dictionary which has a single key other_bar.)
6969

7070
But really we want this:
7171

72-
```
73-
{foo: {bar: 1, other_bar: 2}}
72+
``` python
73+
{'foo': {'bar': 1, 'other_bar': 2}}
7474
```
7575

7676
This code was based on this: https://www.xormedia.com/recursively-merge-dictionaries-in-python/

0 commit comments

Comments
 (0)