summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-02-21 15:52:13 +0100
committerGubolin <gubolin@fantasymail.de>2015-02-21 15:52:13 +0100
commit1580a2044900e9ebbcba5add76e0b6af85f2960c (patch)
treef69436bafcc92c92f85559ba51ec22ae7ac6a14e
parent37f5d8e57f5ffe7825e9a2f48473fda677b6a13f (diff)
downloadblockext-documentation.tar.gz
blockext-documentation.zip
update docs and add a link to example.pydocumentation
-rw-r--r--doc/tutorial.rst14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/tutorial.rst b/doc/tutorial.rst
index 44393dd..91ea03e 100644
--- a/doc/tutorial.rst
+++ b/doc/tutorial.rst
@@ -4,6 +4,8 @@ Tutorial
WARNING: this documentation is a work-in-progress, as is the library. So
this document is incomplete and things will change. Sorry!
+ See also https://github.com/blockext/blockext/blob/master/example.py
+
This tutorial shows you how to write extensions that are compatible with both
`Scratch 2.0`_ and `Snap!`_.
@@ -27,13 +29,16 @@ Here's a quick example::
def __init__(self):
self.light = False
- def do_toggle_light(self, times):
+ @command('press light switch %n times')
+ def do_toggle_light(self, times=1):
for i in range(times):
self.light = not self.light
+ @predicate('light is on?')
def is_light_on(self):
return self.light
+ @reporter('weather %m.day in %m.city')
def get_weather(self, day, city):
import random
return random.choice(["sunny", "cloudy", "windy"])
@@ -41,12 +46,7 @@ Here's a quick example::
descriptor = Descriptor(
name = "Tutorial Example",
port = 5000,
- blocks = [
- Block('do_toggle_light', 'command', 'press light switch %n times',
- defaults=[1])
- Block('is_light_on', 'predicate', 'light is on?'),
- Block('get_weather', 'reporter', 'weather %m.day in %m.city'),
- ],
+ blocks = get_decorated_blocks_from_class(Tutorial),
menus = dict(
day = ["today", "yesterday"],
city = ["Barcelona", "Boston", "Bournemouth"],