Skip to content

Commit

Permalink
examples: Generate hub examples while building.
Browse files Browse the repository at this point in the history
This way we don't have to commit the generated scripts.

While we do this, rename ExampleHub to ThisHub so that the common scripts can actually run.
  • Loading branch information
laurensvalk committed Jul 4, 2022
1 parent 9d706d7 commit 1b51d71
Show file tree
Hide file tree
Showing 62 changed files with 121 additions and 903 deletions.
5 changes: 5 additions & 0 deletions doc/main/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Pybricks documentation build configuration file
#
import os
import sys

# General information about the project.
project = "pybricks"
Expand Down Expand Up @@ -50,3 +51,7 @@
extensions.remove("sphinx.ext.mathjax") # noqa F821
extensions.append("sphinx.ext.imgmath") # noqa F821
html_theme_options["prev_next_buttons_location"] = None # noqa F821

# Build hub specific example scripts.
sys.path.append(os.path.abspath("../../examples/pup/hub_common"))
import make_examples # noqa F401, E402
12 changes: 6 additions & 6 deletions doc/main/hubs/cityhub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ Turning the light on and off
****************************

.. literalinclude::
../../../examples/pup/hub_cityhub/light_off.py
../../../examples/pup/hub_common/build/light_off_cityhub.py

Changing brightness and using custom colors
*******************************************

.. literalinclude::
../../../examples/pup/hub_cityhub/light_hsv.py
../../../examples/pup/hub_common/build/light_hsv_cityhub.py

Making the light blink
**********************

.. literalinclude::
../../../examples/pup/hub_cityhub/light_blink.py
../../../examples/pup/hub_common/build/light_blink_cityhub.py

Creating light animations
*************************

.. literalinclude::
../../../examples/pup/hub_cityhub/light_animate.py
../../../examples/pup/hub_common/build/light_animate_cityhub.py

Button and system examples
----------------------------------
Expand All @@ -71,10 +71,10 @@ Using the stop button during your program
*****************************************

.. literalinclude::
../../../examples/pup/hub_cityhub/button_single.py
../../../examples/pup/hub_common/build/button_single_cityhub.py

Turning the hub off
*****************************************

.. literalinclude::
../../../examples/pup/hub_cityhub/system_shutdown.py
../../../examples/pup/hub_common/build/system_shutdown_cityhub.py
24 changes: 12 additions & 12 deletions doc/main/hubs/essentialhub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@ Turning the light on and off
****************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/light_off.py
../../../examples/pup/hub_common/build/light_off_essentialhub.py

Changing brightness and using custom colors
*******************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/light_hsv.py
../../../examples/pup/hub_common/build/light_hsv_essentialhub.py

Making the light blink
**********************

.. literalinclude::
../../../examples/pup/hub_essentialhub/light_blink.py
../../../examples/pup/hub_common/build/light_blink_essentialhub.py

Creating light animations
*************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/light_animate.py
../../../examples/pup/hub_common/build/light_animate_essentialhub.py

Button examples
---------------
Expand All @@ -106,7 +106,7 @@ Detecting button presses
************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/button_single.py
../../../examples/pup/hub_common/build/button_single_essentialhub.py

IMU examples
---------------
Expand All @@ -115,32 +115,32 @@ Testing which way is up
********************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/imu_up.py
../../../examples/pup/hub_common/build/imu_up_essentialhub.py


Reading the tilt value
********************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/imu_tilt.py
../../../examples/pup/hub_common/build/imu_tilt_essentialhub.py

Using a custom hub orientation
**************************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/imu_tilt_blast.py
../../../examples/pup/hub_common/build/imu_tilt_blast_essentialhub.py

Reading acceleration and angular velocity vectors
**************************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/imu_read_vector.py
../../../examples/pup/hub_common/build/imu_read_vector_essentialhub.py

Reading acceleration and angular velocity on one axis
*****************************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/imu_read_scalar.py
../../../examples/pup/hub_common/build/imu_read_scalar_essentialhub.py

System examples
----------------------------------
Expand All @@ -149,10 +149,10 @@ Using the stop button during your program
*****************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/button_single.py
../../../examples/pup/hub_common/build/button_single_essentialhub.py

Turning the hub off
*****************************************

.. literalinclude::
../../../examples/pup/hub_essentialhub/system_shutdown.py
../../../examples/pup/hub_common/build/system_shutdown_essentialhub.py
10 changes: 5 additions & 5 deletions doc/main/hubs/movehub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ Turning the light on and off
******************************

.. literalinclude::
../../../examples/pup/hub_movehub/light_off.py
../../../examples/pup/hub_common/build/light_off_movehub.py

Making the light blink
******************************

.. literalinclude::
../../../examples/pup/hub_movehub/light_blink.py
../../../examples/pup/hub_common/build/light_blink_movehub.py

IMU examples
---------------
Expand All @@ -71,7 +71,7 @@ Testing which way is up
********************************

.. literalinclude::
../../../examples/pup/hub_movehub/imu_up.py
../../../examples/pup/hub_common/build/imu_up_movehub.py

Reading acceleration
**************************************************
Expand All @@ -86,10 +86,10 @@ Using the stop button during your program
*****************************************

.. literalinclude::
../../../examples/pup/hub_movehub/button_single.py
../../../examples/pup/hub_common/build/button_single_movehub.py

Turning the hub off
*****************************************

.. literalinclude::
../../../examples/pup/hub_movehub/system_shutdown.py
../../../examples/pup/hub_common/build/system_shutdown_movehub.py
20 changes: 10 additions & 10 deletions doc/main/hubs/primehub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,25 @@ Turning the light on and off
****************************

.. literalinclude::
../../../examples/pup/hub_primehub/light_off.py
../../../examples/pup/hub_common/build/light_off_primehub.py

Changing brightness and using custom colors
*******************************************

.. literalinclude::
../../../examples/pup/hub_primehub/light_hsv.py
../../../examples/pup/hub_common/build/light_hsv_primehub.py

Making the light blink
**********************

.. literalinclude::
../../../examples/pup/hub_primehub/light_blink.py
../../../examples/pup/hub_common/build/light_blink_primehub.py

Creating light animations
*************************

.. literalinclude::
../../../examples/pup/hub_primehub/light_animate.py
../../../examples/pup/hub_common/build/light_animate_primehub.py

Matrix display examples
-----------------------
Expand Down Expand Up @@ -209,32 +209,32 @@ Testing which way is up
********************************

.. literalinclude::
../../../examples/pup/hub_primehub/imu_up.py
../../../examples/pup/hub_common/build/imu_up_primehub.py


Reading the tilt value
********************************

.. literalinclude::
../../../examples/pup/hub_primehub/imu_tilt.py
../../../examples/pup/hub_common/build/imu_tilt_primehub.py

Using a custom hub orientation
**************************************************

.. literalinclude::
../../../examples/pup/hub_primehub/imu_tilt_blast.py
../../../examples/pup/hub_common/build/imu_tilt_blast_primehub.py

Reading acceleration and angular velocity vectors
**************************************************

.. literalinclude::
../../../examples/pup/hub_primehub/imu_read_vector.py
../../../examples/pup/hub_common/build/imu_read_vector_primehub.py

Reading acceleration and angular velocity on one axis
*****************************************************

.. literalinclude::
../../../examples/pup/hub_primehub/imu_read_scalar.py
../../../examples/pup/hub_common/build/imu_read_scalar_primehub.py

System examples
----------------------------------
Expand All @@ -249,7 +249,7 @@ Turning the hub off
*****************************************

.. literalinclude::
../../../examples/pup/hub_primehub/system_shutdown.py
../../../examples/pup/hub_common/build/system_shutdown_primehub.py

.. _installation instructions: https://pybricks.com/install/

22 changes: 11 additions & 11 deletions doc/main/hubs/technichub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ Turning the light on and off
****************************

.. literalinclude::
../../../examples/pup/hub_technichub/light_off.py
../../../examples/pup/hub_common/build/light_off_technichub.py

Changing brightness and using custom colors
*******************************************

.. literalinclude::
../../../examples/pup/hub_technichub/light_hsv.py
../../../examples/pup/hub_common/build/light_hsv_technichub.py

Making the light blink
**********************

.. literalinclude::
../../../examples/pup/hub_technichub/light_blink.py
../../../examples/pup/hub_common/build/light_blink_technichub.py

Creating light animations
*************************

.. literalinclude::
../../../examples/pup/hub_technichub/light_animate.py
../../../examples/pup/hub_common/build/light_animate_technichub.py

IMU examples
---------------
Expand All @@ -85,32 +85,32 @@ Testing which way is up
********************************

.. literalinclude::
../../../examples/pup/hub_technichub/imu_up.py
../../../examples/pup/hub_common/build/imu_up_technichub.py


Reading the tilt value
********************************

.. literalinclude::
../../../examples/pup/hub_technichub/imu_tilt.py
../../../examples/pup/hub_common/build/imu_tilt_technichub.py

Using a custom hub orientation
**************************************************

.. literalinclude::
../../../examples/pup/hub_technichub/imu_tilt_blast.py
../../../examples/pup/hub_common/build/imu_tilt_blast_technichub.py

Reading acceleration and angular velocity vectors
**************************************************

.. literalinclude::
../../../examples/pup/hub_technichub/imu_read_vector.py
../../../examples/pup/hub_common/build/imu_read_vector_technichub.py

Reading acceleration and angular velocity on one axis
*****************************************************

.. literalinclude::
../../../examples/pup/hub_technichub/imu_read_scalar.py
../../../examples/pup/hub_common/build/imu_read_scalar_technichub.py

Button and system examples
----------------------------------
Expand All @@ -119,10 +119,10 @@ Using the stop button during your program
*****************************************

.. literalinclude::
../../../examples/pup/hub_technichub/button_single.py
../../../examples/pup/hub_common/build/button_single_technichub.py

Turning the hub off
*****************************************

.. literalinclude::
../../../examples/pup/hub_technichub/system_shutdown.py
../../../examples/pup/hub_common/build/system_shutdown_technichub.py
22 changes: 0 additions & 22 deletions examples/pup/hub_cityhub/light_animate.py

This file was deleted.

16 changes: 0 additions & 16 deletions examples/pup/hub_cityhub/light_blink.py

This file was deleted.

0 comments on commit 1b51d71

Please sign in to comment.