Skip to content

Commit ee2f3e1

Browse files
author
Robert Schindler
committed
[schedy] Work on tutorial in docs
1 parent 0125861 commit ee2f3e1

File tree

5 files changed

+321
-49
lines changed

5 files changed

+321
-49
lines changed

docs/apps/schedy/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ of room for customization with arbitrarily complex rules.
1212

1313
.. note::
1414

15-
Excited? A :doc:`tutorial/index` is provided for getting up and
16-
running quickly.
15+
Excited? A :doc:`tutorial` is provided for getting up and running quickly.
1716

1817
These key features are implemented in Schedy. More are added continuously.
1918

@@ -48,15 +47,15 @@ started with Schedy and advanced users needing a reference book for
4847
implementing complex scenarios.
4948

5049
In order to get started, it is recommended to read the :doc:`chapter about
51-
the concept <concept>` first and then proceed to the :doc:`tutorial/index`.
50+
the concept <concept>` first and then proceed to the :doc:`tutorial`.
5251

5352

5453
.. toctree::
5554
:caption: Contents:
5655
:maxdepth: 1
5756

5857
concept
59-
tutorial/index
58+
tutorial
6059
configuration
6160
actors/index
6261
schedules/index

docs/apps/schedy/schedules/basics.rst

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,19 @@ has a technical reason nor does it reduce the expressiveness of rules.
217217
Rules with Sub-Schedules
218218
------------------------
219219

220-
Imagine you need to turn on heating three times a day for one hour,
221-
but only on working days from January to April. The obvious way of doing
222-
this is to define four rules:
223-
224-
::
220+
Imagine you need to turn on heating three times a day for one hour, but only on working
221+
days from January to April. The obvious way of doing this is to define four rules::
225222

226223
schedule:
227224
- { v: 23, start: "06:00", end: "07:00", months: "1-4", weekdays: "1-5" }
228225
- { v: 20, start: "11:30", end: "12:30", months: "1-4", weekdays: "1-5" }
229226
- { v: 20, start: "18:00", end: "19:00", months: "1-4", weekdays: "1-5" }
230227
- { v: "OFF" }
231228

232-
But what if you want to extend the schedule to heat on Saturdays as
233-
well? You'd end up changing this at three different places.
229+
But what if you want to extend the schedule to heat on Saturdays as well? You'd end
230+
up changing this at three different places.
234231

235-
The more elegant way involves so-called sub-schedule rules. Look at this:
236-
237-
::
232+
The more elegant way involves so-called sub-schedule rules. Look at this::
238233

239234
schedule:
240235
- months: 1-4
@@ -245,15 +240,19 @@ The more elegant way involves so-called sub-schedule rules. Look at this:
245240
- { v: 20, start: "18:00", end: "19:00" }
246241
- v: "OFF"
247242

248-
The first, outer rule containing the ``rules`` parameter isn't considered
249-
for evaluation itself. Instead, it's child rules - those defined under
250-
``rules:`` - are considered, but only when the constraints of the parent
251-
rule (``months`` and ``weekdays`` in this case) are fulfilled.
243+
The first, outer rule containing the ``rules`` parameter isn't considered for
244+
evaluation itself. Instead, it's child rules (those defined under ``rules:``) are
245+
considered, but with all constraints of the outer rule (``months`` and ``weekdays``
246+
in this case) applied to them.
252247

253-
We can go even further and move the ``v: 20`` one level up, so that
254-
it counts for all child rules which don't have their own ``v`` defined.
248+
.. note::
255249

256-
::
250+
The delegation of constraints works not only for one level of
251+
sub-schedules. Sub-schedules can be nested as deep as desired and constraints
252+
are cumulated correctly.
253+
254+
We can go even further and move the ``v: 20`` one level up, so that it counts for
255+
all child rules which don't have their own ``v`` defined::
257256

258257
schedule:
259258
- v: 20
@@ -265,18 +264,18 @@ it counts for all child rules which don't have their own ``v`` defined.
265264
- { start: "18:00", end: "19:00" }
266265
- v: "OFF"
267266

268-
Note how the ``v`` for a rule is chosen. To find the value to use for a
269-
particular rule, the rule is first considered itself. In case it has no
270-
own ``v`` defined, all sub-schedule rules that led to this rule are then
271-
scanned for a ``v`` until one is found. When looking at the indentation
272-
of the YAML, this lookup is done from right to left.
267+
Note how the ``v`` for a rule is chosen. To find the value to use for a particular
268+
rule, the rule is first considered itself. In case it has no own ``v`` defined, all
269+
sub-schedule rules that led to this rule are then traversed and scanned for a ``v``
270+
until one is found. When looking at the indentation of the YAML, this lookup is done
271+
from right to left, so that the innermost value is used. The exact same approach is
272+
taken for ``start`` and ``end``.
273273

274-
I've to admit that this was a small and well arranged example, but the
275-
benefit becomes clearer when you start to write longer schedules, maybe
276-
with separate sections for the different seasons.
274+
I've to admit that this was a small and well arranged example, but the benefit becomes
275+
clearer when you start to write longer schedules, maybe with separate sections for
276+
the different seasons.
277277

278-
With this knowledge, writing quite powerful Schedy schedules should be
279-
easy and quick.
278+
With this knowledge, writing basic Schedy schedules should be straightforward.
280279

281-
The next chapter deals with expressions, which finally give you the
282-
power to do whatever you can do with Python, right inside your schedules.
280+
The next chapter deals with expressions, which finally give you the power to do
281+
whatever you can do with Python, right inside your schedules.

docs/apps/schedy/schedules/expressions/examples.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ holiday and normal modes.
163163
- "input_boolean.holidays"
164164

165165

166+
.. _schedy/schedules/expressions/examples/includeschedule:
167+
166168
Including Schedules Dynamically with ``IncludeSchedule()``
167169
----------------------------------------------------------
168170

0 commit comments

Comments
 (0)