diff --git a/docs/examples/tutorial/cdef_classes/wave_function.pyx b/docs/examples/tutorial/cdef_classes/wave_function.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..aa35d954e9ad55fe8e33d17035b72765d39b6abe
--- /dev/null
+++ b/docs/examples/tutorial/cdef_classes/wave_function.pyx
@@ -0,0 +1,21 @@
+from sin_of_square cimport Function
+
+cdef class WaveFunction(Function):
+
+    # Not available in Python-space:
+    cdef double offset
+
+    # Available in Python-space:
+    cdef public double freq
+
+    # Available in Python-space, but only for reading:
+    cdef readonly double scale
+
+    # Available in Python-space:
+    @property
+    def period(self):
+        return 1.0 / self.freq
+
+    @period.setter
+    def period(self, value):
+        self.freq = 1.0 / value
diff --git a/docs/src/tutorial/cdef_classes.rst b/docs/src/tutorial/cdef_classes.rst
index 997c1aeb082c248449231c5b7d90ad4180e3ca86..468f2f6e4e17a3b650ce944c5a1d9a2f74bf4985 100644
--- a/docs/src/tutorial/cdef_classes.rst
+++ b/docs/src/tutorial/cdef_classes.rst
@@ -130,18 +130,4 @@ Attributes in cdef classes behave differently from attributes in regular classes
  - Attributes are by default only accessible from Cython (typed access)
  - Properties can be declared to expose dynamic attributes to Python-space
 
-::
-
-  cdef class WaveFunction(Function):
-      # Not available in Python-space:
-      cdef double offset
-      # Available in Python-space:
-      cdef public double freq
-      # Available in Python-space:
-      @property
-      def period(self):
-          return 1.0 / self.freq
-      @period.setter
-      def period(self, value):
-          self.freq = 1.0 / value
-      <...>
+.. literalinclude:: ../../examples/tutorial/cdef_classes/wave_function.pyx