Skip to content

Commit cb0fdbe

Browse files
authored
Document class-scope constants (#306)
See #299
1 parent 0eb6fc7 commit cb0fdbe

File tree

4 files changed

+106
-95
lines changed

4 files changed

+106
-95
lines changed

ev3dev/core.py

Lines changed: 101 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -709,77 +709,77 @@ def time_sp(self, value):
709709
# ~autogen
710710
# ~autogen generic-property-value classes.motor>currentClass
711711

712-
# Run the motor until another command is sent.
712+
#: Run the motor until another command is sent.
713713
COMMAND_RUN_FOREVER = 'run-forever'
714714

715-
# Run to an absolute position specified by `position_sp` and then
716-
# stop using the action specified in `stop_action`.
715+
#: Run to an absolute position specified by `position_sp` and then
716+
#: stop using the action specified in `stop_action`.
717717
COMMAND_RUN_TO_ABS_POS = 'run-to-abs-pos'
718718

719-
# Run to a position relative to the current `position` value.
720-
# The new position will be current `position` + `position_sp`.
721-
# When the new position is reached, the motor will stop using
722-
# the action specified by `stop_action`.
719+
#: Run to a position relative to the current `position` value.
720+
#: The new position will be current `position` + `position_sp`.
721+
#: When the new position is reached, the motor will stop using
722+
#: the action specified by `stop_action`.
723723
COMMAND_RUN_TO_REL_POS = 'run-to-rel-pos'
724724

725-
# Run the motor for the amount of time specified in `time_sp`
726-
# and then stop the motor using the action specified by `stop_action`.
725+
#: Run the motor for the amount of time specified in `time_sp`
726+
#: and then stop the motor using the action specified by `stop_action`.
727727
COMMAND_RUN_TIMED = 'run-timed'
728728

729-
# Run the motor at the duty cycle specified by `duty_cycle_sp`.
730-
# Unlike other run commands, changing `duty_cycle_sp` while running *will*
731-
# take effect immediately.
729+
#: Run the motor at the duty cycle specified by `duty_cycle_sp`.
730+
#: Unlike other run commands, changing `duty_cycle_sp` while running *will*
731+
#: take effect immediately.
732732
COMMAND_RUN_DIRECT = 'run-direct'
733733

734-
# Stop any of the run commands before they are complete using the
735-
# action specified by `stop_action`.
734+
#: Stop any of the run commands before they are complete using the
735+
#: action specified by `stop_action`.
736736
COMMAND_STOP = 'stop'
737737

738-
# Reset all of the motor parameter attributes to their default value.
739-
# This will also have the effect of stopping the motor.
738+
#: Reset all of the motor parameter attributes to their default value.
739+
#: This will also have the effect of stopping the motor.
740740
COMMAND_RESET = 'reset'
741741

742-
# Sets the normal polarity of the rotary encoder.
742+
#: Sets the normal polarity of the rotary encoder.
743743
ENCODER_POLARITY_NORMAL = 'normal'
744744

745-
# Sets the inversed polarity of the rotary encoder.
745+
#: Sets the inversed polarity of the rotary encoder.
746746
ENCODER_POLARITY_INVERSED = 'inversed'
747747

748-
# With `normal` polarity, a positive duty cycle will
749-
# cause the motor to rotate clockwise.
748+
#: With `normal` polarity, a positive duty cycle will
749+
#: cause the motor to rotate clockwise.
750750
POLARITY_NORMAL = 'normal'
751751

752-
# With `inversed` polarity, a positive duty cycle will
753-
# cause the motor to rotate counter-clockwise.
752+
#: With `inversed` polarity, a positive duty cycle will
753+
#: cause the motor to rotate counter-clockwise.
754754
POLARITY_INVERSED = 'inversed'
755755

756-
# Power is being sent to the motor.
756+
#: Power is being sent to the motor.
757757
STATE_RUNNING = 'running'
758758

759-
# The motor is ramping up or down and has not yet reached a constant output level.
759+
#: The motor is ramping up or down and has not yet reached a constant output level.
760760
STATE_RAMPING = 'ramping'
761761

762-
# The motor is not turning, but rather attempting to hold a fixed position.
762+
#: The motor is not turning, but rather attempting to hold a fixed position.
763763
STATE_HOLDING = 'holding'
764764

765-
# The motor is turning, but cannot reach its `speed_sp`.
765+
#: The motor is turning, but cannot reach its `speed_sp`.
766766
STATE_OVERLOADED = 'overloaded'
767767

768-
# The motor is not turning when it should be.
768+
#: The motor is not turning when it should be.
769769
STATE_STALLED = 'stalled'
770770

771-
# Power will be removed from the motor and it will freely coast to a stop.
771+
#: Power will be removed from the motor and it will freely coast to a stop.
772772
STOP_ACTION_COAST = 'coast'
773773

774-
# Power will be removed from the motor and a passive electrical load will
775-
# be placed on the motor. This is usually done by shorting the motor terminals
776-
# together. This load will absorb the energy from the rotation of the motors and
777-
# cause the motor to stop more quickly than coasting.
774+
#: Power will be removed from the motor and a passive electrical load will
775+
#: be placed on the motor. This is usually done by shorting the motor terminals
776+
#: together. This load will absorb the energy from the rotation of the motors and
777+
#: cause the motor to stop more quickly than coasting.
778778
STOP_ACTION_BRAKE = 'brake'
779779

780-
# Does not remove power from the motor. Instead it actively try to hold the motor
781-
# at the current position. If an external force tries to turn the motor, the motor
782-
# will `push back` to maintain its position.
780+
#: Does not remove power from the motor. Instead it actively try to hold the motor
781+
#: at the current position. If an external force tries to turn the motor, the motor
782+
#: will `push back` to maintain its position.
783783
STOP_ACTION_HOLD = 'hold'
784784

785785

@@ -1223,37 +1223,37 @@ def time_sp(self, value):
12231223
# ~autogen
12241224
# ~autogen generic-property-value classes.dcMotor>currentClass
12251225

1226-
# Run the motor until another command is sent.
1226+
#: Run the motor until another command is sent.
12271227
COMMAND_RUN_FOREVER = 'run-forever'
12281228

1229-
# Run the motor for the amount of time specified in `time_sp`
1230-
# and then stop the motor using the action specified by `stop_action`.
1229+
#: Run the motor for the amount of time specified in `time_sp`
1230+
#: and then stop the motor using the action specified by `stop_action`.
12311231
COMMAND_RUN_TIMED = 'run-timed'
12321232

1233-
# Run the motor at the duty cycle specified by `duty_cycle_sp`.
1234-
# Unlike other run commands, changing `duty_cycle_sp` while running *will*
1235-
# take effect immediately.
1233+
#: Run the motor at the duty cycle specified by `duty_cycle_sp`.
1234+
#: Unlike other run commands, changing `duty_cycle_sp` while running *will*
1235+
#: take effect immediately.
12361236
COMMAND_RUN_DIRECT = 'run-direct'
12371237

1238-
# Stop any of the run commands before they are complete using the
1239-
# action specified by `stop_action`.
1238+
#: Stop any of the run commands before they are complete using the
1239+
#: action specified by `stop_action`.
12401240
COMMAND_STOP = 'stop'
12411241

1242-
# With `normal` polarity, a positive duty cycle will
1243-
# cause the motor to rotate clockwise.
1242+
#: With `normal` polarity, a positive duty cycle will
1243+
#: cause the motor to rotate clockwise.
12441244
POLARITY_NORMAL = 'normal'
12451245

1246-
# With `inversed` polarity, a positive duty cycle will
1247-
# cause the motor to rotate counter-clockwise.
1246+
#: With `inversed` polarity, a positive duty cycle will
1247+
#: cause the motor to rotate counter-clockwise.
12481248
POLARITY_INVERSED = 'inversed'
12491249

1250-
# Power will be removed from the motor and it will freely coast to a stop.
1250+
#: Power will be removed from the motor and it will freely coast to a stop.
12511251
STOP_ACTION_COAST = 'coast'
12521252

1253-
# Power will be removed from the motor and a passive electrical load will
1254-
# be placed on the motor. This is usually done by shorting the motor terminals
1255-
# together. This load will absorb the energy from the rotation of the motors and
1256-
# cause the motor to stop more quickly than coasting.
1253+
#: Power will be removed from the motor and a passive electrical load will
1254+
#: be placed on the motor. This is usually done by shorting the motor terminals
1255+
#: together. This load will absorb the energy from the rotation of the motors and
1256+
#: cause the motor to stop more quickly than coasting.
12571257
STOP_ACTION_BRAKE = 'brake'
12581258

12591259

@@ -1482,18 +1482,18 @@ def state(self):
14821482
# ~autogen
14831483
# ~autogen generic-property-value classes.servoMotor>currentClass
14841484

1485-
# Drive servo to the position set in the `position_sp` attribute.
1485+
#: Drive servo to the position set in the `position_sp` attribute.
14861486
COMMAND_RUN = 'run'
14871487

1488-
# Remove power from the motor.
1488+
#: Remove power from the motor.
14891489
COMMAND_FLOAT = 'float'
14901490

1491-
# With `normal` polarity, a positive duty cycle will
1492-
# cause the motor to rotate clockwise.
1491+
#: With `normal` polarity, a positive duty cycle will
1492+
#: cause the motor to rotate clockwise.
14931493
POLARITY_NORMAL = 'normal'
14941494

1495-
# With `inversed` polarity, a positive duty cycle will
1496-
# cause the motor to rotate counter-clockwise.
1495+
#: With `inversed` polarity, a positive duty cycle will
1496+
#: cause the motor to rotate counter-clockwise.
14971497
POLARITY_INVERSED = 'inversed'
14981498

14991499

@@ -1833,7 +1833,7 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
18331833
self.auto_mode = True
18341834

18351835

1836-
# Button state
1836+
#: Button state
18371837
MODE_TOUCH = 'TOUCH'
18381838

18391839

@@ -1865,43 +1865,43 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
18651865
self.auto_mode = True
18661866

18671867

1868-
# Reflected light. Red LED on.
1868+
#: Reflected light. Red LED on.
18691869
MODE_COL_REFLECT = 'COL-REFLECT'
18701870

1871-
# Ambient light. Red LEDs off.
1871+
#: Ambient light. Red LEDs off.
18721872
MODE_COL_AMBIENT = 'COL-AMBIENT'
18731873

1874-
# Color. All LEDs rapidly cycling, appears white.
1874+
#: Color. All LEDs rapidly cycling, appears white.
18751875
MODE_COL_COLOR = 'COL-COLOR'
18761876

1877-
# Raw reflected. Red LED on
1877+
#: Raw reflected. Red LED on
18781878
MODE_REF_RAW = 'REF-RAW'
18791879

1880-
# Raw Color Components. All LEDs rapidly cycling, appears white.
1880+
#: Raw Color Components. All LEDs rapidly cycling, appears white.
18811881
MODE_RGB_RAW = 'RGB-RAW'
18821882

1883-
# No color.
1883+
#: No color.
18841884
COLOR_NOCOLOR = 0
18851885

1886-
# Black color.
1886+
#: Black color.
18871887
COLOR_BLACK = 1
18881888

1889-
# Blue color.
1889+
#: Blue color.
18901890
COLOR_BLUE = 2
18911891

1892-
# Green color.
1892+
#: Green color.
18931893
COLOR_GREEN = 3
18941894

1895-
# Yellow color.
1895+
#: Yellow color.
18961896
COLOR_YELLOW = 4
18971897

1898-
# Red color.
1898+
#: Red color.
18991899
COLOR_RED = 5
19001900

1901-
# White color.
1901+
#: White color.
19021902
COLOR_WHITE = 6
19031903

1904-
# Brown color.
1904+
#: Brown color.
19051905
COLOR_BROWN = 7
19061906

19071907

@@ -2006,19 +2006,19 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
20062006
self.auto_mode = True
20072007

20082008

2009-
# Continuous measurement in centimeters.
2009+
#: Continuous measurement in centimeters.
20102010
MODE_US_DIST_CM = 'US-DIST-CM'
20112011

2012-
# Continuous measurement in inches.
2012+
#: Continuous measurement in inches.
20132013
MODE_US_DIST_IN = 'US-DIST-IN'
20142014

2015-
# Listen.
2015+
#: Listen.
20162016
MODE_US_LISTEN = 'US-LISTEN'
20172017

2018-
# Single measurement in centimeters.
2018+
#: Single measurement in centimeters.
20192019
MODE_US_SI_CM = 'US-SI-CM'
20202020

2021-
# Single measurement in inches.
2021+
#: Single measurement in inches.
20222022
MODE_US_SI_IN = 'US-SI-IN'
20232023

20242024

@@ -2074,19 +2074,19 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
20742074
self.auto_mode = True
20752075

20762076

2077-
# Angle
2077+
#: Angle
20782078
MODE_GYRO_ANG = 'GYRO-ANG'
20792079

2080-
# Rotational speed
2080+
#: Rotational speed
20812081
MODE_GYRO_RATE = 'GYRO-RATE'
20822082

2083-
# Raw sensor value
2083+
#: Raw sensor value
20842084
MODE_GYRO_FAS = 'GYRO-FAS'
20852085

2086-
# Angle and rotational speed
2086+
#: Angle and rotational speed
20872087
MODE_GYRO_G_A = 'GYRO-G&A'
20882088

2089-
# Calibration ???
2089+
#: Calibration ???
20902090
MODE_GYRO_CAL = 'GYRO-CAL'
20912091

20922092

@@ -2140,19 +2140,19 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
21402140
self.auto_mode = True
21412141

21422142

2143-
# Proximity
2143+
#: Proximity
21442144
MODE_IR_PROX = 'IR-PROX'
21452145

2146-
# IR Seeker
2146+
#: IR Seeker
21472147
MODE_IR_SEEK = 'IR-SEEK'
21482148

2149-
# IR Remote Control
2149+
#: IR Remote Control
21502150
MODE_IR_REMOTE = 'IR-REMOTE'
21512151

2152-
# IR Remote Control. State of the buttons is coded in binary
2152+
#: IR Remote Control. State of the buttons is coded in binary
21532153
MODE_IR_REM_A = 'IR-REM-A'
21542154

2155-
# Calibration ???
2155+
#: Calibration ???
21562156
MODE_IR_CAL = 'IR-CAL'
21572157

21582158

@@ -2184,10 +2184,10 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
21842184
self.auto_mode = True
21852185

21862186

2187-
# Sound pressure level. Flat weighting
2187+
#: Sound pressure level. Flat weighting
21882188
MODE_DB = 'DB'
21892189

2190-
# Sound pressure level. A weighting
2190+
#: Sound pressure level. A weighting
21912191
MODE_DBA = 'DBA'
21922192

21932193

@@ -2231,10 +2231,10 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
22312231
self.auto_mode = True
22322232

22332233

2234-
# Reflected light. LED on
2234+
#: Reflected light. LED on
22352235
MODE_REFLECT = 'REFLECT'
22362236

2237-
# Ambient light. LED off
2237+
#: Ambient light. LED off
22382238
MODE_AMBIENT = 'AMBIENT'
22392239

22402240

@@ -2604,12 +2604,22 @@ class RemoteControl(ButtonBase):
26042604
11: ['blue_up', 'blue_down']
26052605
}
26062606

2607+
#: Handles ``Red Up`` events.
26072608
on_red_up = None
2609+
2610+
#: Handles ``Red Down`` events.
26082611
on_red_down = None
2612+
2613+
#: Handles ``Blue Up`` events.
26092614
on_blue_up = None
2615+
2616+
#: Handles ``Blue Down`` events.
26102617
on_blue_down = None
2618+
2619+
#: Handles ``Beacon`` events.
26112620
on_beacon = None
26122621

2622+
26132623
@property
26142624
def red_up(self):
26152625
"""

templates/generic-property-value.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
assign propName = prop.propertyName | upcase | underscore_spaces %}{%
44
for value in prop.values %}{%
55
for line in value.description %}
6-
# {{ line }}{%
6+
#: {{ line }}{%
77
endfor %}
88
{{ propName }}_{{ value.name | upcase | underscore_non_wc }} = '{{ value.name }}'
99
{% endfor %}{%

0 commit comments

Comments
 (0)