mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 09:37:25 +00:00
config: add classlink directive
We have index pages for most modules now, which link to individual classes. It is helpful if these empty class headers are hyperlinks. This commit does just that. For most sensors/devices so far this is not really necessary as the images are already hyperlinks. But this will become more useful as we start adding index pages like these for classes without images, such as parameters.
This commit is contained in:
+6
-12
@@ -13,43 +13,37 @@
|
||||
primehub
|
||||
ev3brick
|
||||
|
||||
.. class:: MoveHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: MoveHub
|
||||
|
||||
.. figure:: ../../api/images/movehub.png
|
||||
:height: 10 em
|
||||
:target: movehub.html
|
||||
|
||||
.. class:: CityHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: CityHub
|
||||
|
||||
.. figure:: ../../api/images/cityhub.png
|
||||
:height: 10 em
|
||||
:target: cityhub.html
|
||||
|
||||
.. class:: TechnicHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: TechnicHub
|
||||
|
||||
.. figure:: ../../api/images/technichub.png
|
||||
:height: 10 em
|
||||
:target: technichub.html
|
||||
|
||||
.. class:: PrimeHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: PrimeHub
|
||||
|
||||
.. figure:: ../../api/images/primehub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. class:: InventorHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: InventorHub
|
||||
|
||||
.. figure:: ../../api/images/inventorhub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. class:: EV3Brick
|
||||
:noindex:
|
||||
.. pybricks-classlink:: EV3Brick
|
||||
|
||||
.. figure:: ../../api/images/ev3brick.png
|
||||
:height: 10 em
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
dcmotor
|
||||
ev3devsensor
|
||||
|
||||
.. class:: PUPDevice
|
||||
:noindex:
|
||||
.. pybricks-classlink:: PUPDevice
|
||||
|
||||
.. figure:: ../../api/images/sensor_pup.png
|
||||
:width: 70 %
|
||||
@@ -25,43 +24,37 @@
|
||||
|
||||
This class is only available on Powered Up hubs.
|
||||
|
||||
.. class:: I2CDevice
|
||||
:noindex:
|
||||
.. pybricks-classlink:: I2CDevice
|
||||
|
||||
.. figure:: ../../api/images/sensor_rj12_bluegreen.png
|
||||
:width: 25 %
|
||||
:target: i2cdevice.html
|
||||
|
||||
.. class:: UARTDevice
|
||||
:noindex:
|
||||
.. pybricks-classlink:: UARTDevice
|
||||
|
||||
.. figure:: ../../api/images/sensor_rj12_gray.png
|
||||
:width: 25 %
|
||||
:target: uartdevice.html
|
||||
|
||||
.. class:: AnalogSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: AnalogSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_rj12_brown.png
|
||||
:width: 25 %
|
||||
:target: analogsensor.html
|
||||
|
||||
.. class:: LUMPDevice
|
||||
:noindex:
|
||||
.. pybricks-classlink:: LUMPDevice
|
||||
|
||||
.. figure:: ../../api/images/sensor_rj12_green.png
|
||||
:width: 25 %
|
||||
:target: lumpdevice.html
|
||||
|
||||
.. class:: DCMotor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: DCMotor
|
||||
|
||||
.. figure:: ../../api/images/rcxmotor.png
|
||||
:width: 40 %
|
||||
:target: dcmotor.html
|
||||
|
||||
.. class:: Ev3devSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: Ev3devSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_ev3dev.png
|
||||
:width: 70 %
|
||||
|
||||
@@ -20,78 +20,67 @@
|
||||
light
|
||||
remote
|
||||
|
||||
.. class:: DCMotor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: DCMotor
|
||||
|
||||
.. figure:: ../../api/images/pupdcmotors_label.png
|
||||
:width: 70 %
|
||||
:target: dcmotor.html
|
||||
|
||||
.. class:: Motor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: Motor
|
||||
|
||||
.. figure:: ../../api/images/pupmotors_label.png
|
||||
:width: 100 %
|
||||
:target: motor.html
|
||||
|
||||
.. class:: TiltSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: TiltSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_tilt.png
|
||||
:width: 35 %
|
||||
:target: tiltsensor.html
|
||||
|
||||
.. class:: InfraredSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: InfraredSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_proximity.png
|
||||
:width: 35 %
|
||||
:target: infraredsensor.html
|
||||
|
||||
.. class:: ColorDistanceSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: ColorDistanceSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_colordistance.png
|
||||
:width: 32 %
|
||||
:target: colordistancesensor.html
|
||||
|
||||
.. class:: PFMotor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: PFMotor
|
||||
|
||||
.. figure:: ../../api/images/pfmotor.png
|
||||
:width: 95 %
|
||||
:target: pfmotor.html
|
||||
|
||||
.. class:: ColorSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: ColorSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_color.png
|
||||
:width: 32 %
|
||||
:target: colorsensor.html
|
||||
|
||||
.. class:: UltrasonicSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: UltrasonicSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_ultrasonic.png
|
||||
:width: 37 %
|
||||
:target: ultrasonicsensor.html
|
||||
|
||||
.. class:: ForceSensor
|
||||
:noindex:
|
||||
.. pybricks-classlink:: ForceSensor
|
||||
|
||||
.. figure:: ../../api/images/sensor_force.png
|
||||
:width: 35 %
|
||||
:target: forcesensor.html
|
||||
|
||||
.. class:: Light
|
||||
:noindex:
|
||||
.. pybricks-classlink:: Light
|
||||
|
||||
.. figure:: ../../api/images/light.png
|
||||
:width: 90 %
|
||||
:target: light.html
|
||||
|
||||
.. class:: Remote
|
||||
:noindex:
|
||||
.. pybricks-classlink:: Remote
|
||||
|
||||
.. figure:: ../../api/images/pupremote.png
|
||||
:width: 50 %
|
||||
|
||||
@@ -59,6 +59,7 @@ extensions = [
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.mathjax',
|
||||
'color',
|
||||
'classlink',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
|
||||
class PybricksClasslinkDirective(Directive):
|
||||
|
||||
required_arguments = 1
|
||||
|
||||
def run(self):
|
||||
# Get link name from sphinx-directive
|
||||
name = self.arguments[0]
|
||||
|
||||
html = (
|
||||
'<a href="{0}.html">'.format(name.lower()) +
|
||||
'<dl class="py class">' +
|
||||
'<dt>' +
|
||||
'<em class="property">class </em>' +
|
||||
'<code class="sig-name descname">' + name + '</code>' +
|
||||
'</dt>' +
|
||||
'<dd></dd>' +
|
||||
'</dl>' +
|
||||
'</a>'
|
||||
)
|
||||
|
||||
# Return the node
|
||||
node = nodes.raw('', html, format="html")
|
||||
return [node]
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive_to_domain('py', 'pybricks-classlink', PybricksClasslinkDirective)
|
||||
+5
-10
@@ -12,36 +12,31 @@
|
||||
technichub
|
||||
primehub
|
||||
|
||||
.. class:: MoveHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: MoveHub
|
||||
|
||||
.. figure:: ../../api/images/movehub.png
|
||||
:height: 10 em
|
||||
:target: movehub.html
|
||||
|
||||
.. class:: CityHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: CityHub
|
||||
|
||||
.. figure:: ../../api/images/cityhub.png
|
||||
:height: 10 em
|
||||
:target: cityhub.html
|
||||
|
||||
.. class:: TechnicHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: TechnicHub
|
||||
|
||||
.. figure:: ../../api/images/technichub.png
|
||||
:height: 10 em
|
||||
:target: technichub.html
|
||||
|
||||
.. class:: PrimeHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: PrimeHub
|
||||
|
||||
.. figure:: ../../api/images/primehub.png
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. class:: InventorHub
|
||||
:noindex:
|
||||
.. pybricks-classlink:: InventorHub
|
||||
|
||||
.. figure:: ../../api/images/inventorhub.png
|
||||
:height: 10 em
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
pupdevice
|
||||
|
||||
.. class:: PUPDevice
|
||||
:noindex:
|
||||
.. pybricks-classlink:: PUPDevice
|
||||
|
||||
.. figure:: ../../api/images/sensor_pup.png
|
||||
:width: 70 %
|
||||
|
||||
Reference in New Issue
Block a user