@@ -384,10 +384,12 @@ Example
384384~~~~~~~
385385
386386.. code-block :: python
387- :caption: conftest .py
387+ :caption: teststrategy .py
388388
389389 from labgrid.strategy import GraphStrategy
390+ from labgrid.factory import target_factory
390391
392+ @target_factory.reg_driver
391393 class TestStrategy (GraphStrategy ):
392394 def state_unknown (self ):
393395 pass
@@ -416,25 +418,26 @@ The class can also render a graph as PNG (using GraphViz):
416418 targets :
417419 main :
418420 resources : {}
419- drivers : {}
421+ drivers :
422+ TestStrategy : {}
420423
421- .. code-block :: python
422- :caption: render_teststrategy .py
423-
424- from labgrid.environment import Environment
425- from conftest import TestStrategy
426- env = Environment( ' test.yaml ' )
427- strategy = TestStrategy(env.get_target(), " strategy name " )
428-
429- strategy.transition( ' barebox ' , via = [ ' boot_via_nfs ' ] )
430- # returned: ['unknown ', 'boot_via_nfs', 'barebox']
431- strategy.graph.render( " teststrategy-via-nfs " )
432- # returned: ' teststrategy-via-nfs.png'
433-
434- strategy.transition(' barebox' , via = [' boot_via_nand' ])
435- # returned: ['unknown', 'boot_via_nand', 'barebox']
436- strategy.graph.render(" teststrategy-via-nand" )
437- # returned: 'teststrategy-via-nand.png'
424+ imports :
425+ - teststrategy .py
426+
427+
428+ ::
429+
430+ >>> from labgrid.environment import Environment
431+ >>> env = Environment('test.yaml')
432+ >>> strategy = env.get_target().get_driver('Strategy' )
433+ >>> strategy.transition('barebox ', via=[ 'boot_via_nfs'])
434+ ['unknown', 'boot_via_nfs', 'barebox']
435+ >>> strategy.graph.render(" teststrategy-via-nfs")
436+ 'teststrategy-via-nfs.png'
437+ >>> strategy.transition('barebox', via=['boot_via_nand'])
438+ ['unknown', 'boot_via_nand', 'barebox']
439+ >>> strategy.graph.render("teststrategy-via-nand")
440+ 'teststrategy-via-nand.png'
438441
439442.. figure :: res/graphstrategy-via-nfs.png
440443
0 commit comments