diff --git a/pybricks/_display.py b/pybricks/_display.py index 5475dfc..2f5407f 100644 --- a/pybricks/_display.py +++ b/pybricks/_display.py @@ -22,7 +22,7 @@ class Display(): text (str): The text to display. coordinate (tuple): ``(x, y)`` coordinate tuple. It is the top-left corner of the first character. If no location is specified, it is printed on the next line. - :: + Example:: # Clear the display brick.display.clear() @@ -52,7 +52,7 @@ class Display(): coordinate (tuple): ``(x, y)`` coordinate tuple. It is the top-left corner of the image (*Default*: None). clear (bool): Whether to clear the screen before showing the image. (*Default*: ``True``) - :: + Example:: # Show a built-in image showing two eyes looking upward brick.display.image(Image.up) diff --git a/pybricks/_speaker.py b/pybricks/_speaker.py index 241fcdd..9827401 100644 --- a/pybricks/_speaker.py +++ b/pybricks/_speaker.py @@ -15,7 +15,8 @@ class Speaker(): frequency (:ref:`frequency`): Frequency of the beep (*Default*: 500). duration (:ref:`time`): Duration of the beep (*Default*: 100). volume (:ref:`percentage`): Volume of the beep (*Default*: 30). - :: + + Example:: # A simple beep brick.sound.beep() @@ -31,7 +32,7 @@ class Speaker(): Arguments: number (int): Number of beeps - :: + Example:: # Make 5 simple beeps brick.sound.beeps(5) @@ -45,7 +46,7 @@ class Speaker(): file_name (str): Path to the sound file, including extension. volume (:ref:`percentage`): Volume of the sound (*Default*: 100). - :: + Example:: # Play one of the built-in sounds brick.sound.file(Sound.hello) diff --git a/pybricks/ev3brick.py b/pybricks/ev3brick.py index d188be9..545fbc1 100644 --- a/pybricks/ev3brick.py +++ b/pybricks/ev3brick.py @@ -10,7 +10,7 @@ def buttons(): :returns: List of pressed buttons. :rtype: List of :class:`Button ` - :: + Example:: if Button.left in brick.buttons(): print("The left button is pressed.") @@ -25,7 +25,7 @@ def light(color): Arguments: color (Color): Color of the light. Choose ``Color.black`` or ``None`` to turn the light off. - :: + Example:: # Make the light red brick.light(Color.red) diff --git a/pybricks/ev3devices.py b/pybricks/ev3devices.py index c723789..d2911b2 100644 --- a/pybricks/ev3devices.py +++ b/pybricks/ev3devices.py @@ -33,7 +33,7 @@ class Motor(): The ``gears`` setting is only available for motors with rotation sensors. - :: + Example:: # Initialize a motor (by default this means clockwise, without any gears). example_motor = Motor(Port.A) @@ -53,7 +53,7 @@ class Motor(): duty (:ref:`percentage`): The duty cycle (-100.0 to 100). limit (:ref:`percentage`): Limit on the maximum ``duty`` value. (*Default*: 100). This overrides the first argument when it exceeds the limit. This ensures that ``abs(duty)`` <``limit``. This is useful when you use your own formula to set the duty cycle, because provides a limit when your formula gives a very big number. For example, you could use this to prevent your LEGO train from unintentionally going at full speed. - :: + Example:: # Set the motor duty cycle to 75%. example_motor.duty(75) @@ -199,7 +199,7 @@ class Motor(): Arguments: target_angle (:ref:`angle`): Target angle that the motor should go to. - :: + Example:: # Initialize motor and timer from math import sin @@ -231,7 +231,7 @@ class Motor(): max_speed (:ref:`speed`): Maximum speed of the motor during a motor command. acceleration (:ref:`acceleration`): Acceleration towards the target speed and deceleration towards standstill. This should be a positive value. The motor will automatically change the sign to decelerate as needed. - :: + Example:: # Set the maximum speed to 200 deg/s and set the acceleration to 400 deg/s/s. example_motor.set_run_settings(200, 400) diff --git a/pybricks/tools.py b/pybricks/tools.py index 1e90979..bab223a 100644 --- a/pybricks/tools.py +++ b/pybricks/tools.py @@ -6,7 +6,7 @@ def print(): Prints the values to the terminal or a stream. - :: + Example:: # Print some text print("Hello, world")