1.. include:: ../global.inc
2.. _decorators.follows:
3.. index::
4    pair: @follows; Syntax
5
6.. seealso::
7
8    * :ref:`@follows <new_manual.follows>` in the **Ruffus** Manual
9    * :ref:`Decorators <decorators>` for more decorators
10
11    .. note::
12
13        Only missing directories are created.
14
15        In other words, the same directory can be specified multiple times safely without, for example, being recreated repeatedly.
16        Sometimes, for pipelines with multiple entry points, this is the only way to make sure that certain working or output
17        directories are always created or available *before* the pipeline runs.
18
19
20############
21follows
22############
23
24.. _decorators.follows.mkdir:
25
26.. |task| replace:: `task`
27.. _task: `decorators.follows.task`_
28.. |task_name| replace:: `"task_name"`
29.. _task_name: `decorators.follows.task_name`_
30.. |directory_name| replace:: `directory_name`
31.. _directory_name: `decorators.follows.directory_name`_
32
33***************************************************************************************************************************************************
34*@follows*\ (|task|_ | |task_name|_ | :ref:`mkdir<decorators.mkdir>` (|directory_name|_), [more_tasks, ...])
35***************************************************************************************************************************************************
36    **Purpose:**
37
38        Indicates either
39
40            * task dependencies
41            * that the task requires a directory to be created first *if necessary*. (Existing directories will not be overwritten)
42
43
44    **Example**::
45
46        def task1():
47            print "doing task 1"
48
49        @follows(task1)
50        def task2():
51            print "doing task 2"
52
53
54    **Parameters:**
55
56.. _decorators.follows.task:
57
58    * *task*:
59        a list of tasks which have to be run **before** this function
60
61.. _decorators.follows.task_name:
62
63    * *"task_name"*:
64        Dependencies can be quoted function names.
65        Quoted function names allow dependencies to be added before the function is defined.
66
67        Functions in other modules need to be fully qualified.
68
69
70.. _decorators.follows.directory_name:
71
72    * *directory_name*:
73        Directories which need to be created (*only if they don't exist*) before
74        the task is run can be specified via a ``mkdir`` indicator object:
75
76            ::
77
78                @follows(task_x, mkdir("/output/directory") ...)
79                def task():
80                    pass
81
82
83