18
18
class Node (NS_Node ):
19
19
"""
20
20
Derived from `treebeard.NS_Node <https://django-treebeard.readthedocs.io/en/latest/ns_tree.html#treebeard.ns_tree.NS_Node>`_.
21
- Holds structure of syntax tree. All objects are linked using the
21
+ Holds the structure of the syntax tree. All objects are linked using the
22
22
`django contenttypes framework <https://docs.djangoproject.com/en/2.1/ref/contrib/contenttypes/>`_.
23
23
Interprets code using the :func:`business_logic.models.Node.interpret` method.
24
- Can acts as parent of code block if not contains content_object.
25
- Can contains comment.
24
+ Can act as a parent of a code block if it does not contain a content_object.
25
+ Can contain a comment.
26
26
27
27
See Also:
28
28
* :class:`business_logic.models.NodeCache`
@@ -54,7 +54,7 @@ def ensure_content_object_saved(**kwargs):
54
54
@classmethod
55
55
def add_root (cls , ** kwargs ):
56
56
"""
57
- Adds a root node to the tree. Saves content_objects if needed .
57
+ Adds a root node to the tree. Saves content_objects if necessary .
58
58
Args:
59
59
**kwargs: kwargs for :class:`business_logic.models.Node` constructor
60
60
@@ -66,7 +66,7 @@ def add_root(cls, **kwargs):
66
66
67
67
def add_child (self , ** kwargs ):
68
68
"""
69
- Adds a child to the node. Saves content_objects if needed .
69
+ Adds a child to the node. Saves content_objects if necessary .
70
70
71
71
Args:
72
72
**kwargs: kwargs for :class:`business_logic.models.Node` constructor
@@ -79,7 +79,7 @@ def add_child(self, **kwargs):
79
79
80
80
def delete (self ):
81
81
"""
82
- Removes a node and all it’s descendants, and content_objects if needed .
82
+ Removes a node and all its descendants, and content_objects if necessary .
83
83
"""
84
84
if (self .object_id and self .content_object and
85
85
self .content_type .app_label == ContentType .objects .get_for_model (self .__class__ ).app_label ):
@@ -92,10 +92,10 @@ def delete(self):
92
92
93
93
def clone (self ):
94
94
"""
95
- Creates a clone of entire tree starting from self
95
+ Creates a clone of the entire tree starting from self.
96
96
97
97
Returns:
98
- :class:`business_logic.models.Node`: root node of cloned tree
98
+ :class:`business_logic.models.Node`: root node of the cloned tree.
99
99
100
100
"""
101
101
class CloneVisitor (NodeVisitor ):
@@ -133,7 +133,7 @@ def visit(self, node):
133
133
134
134
def interpret (self , ctx ):
135
135
"""
136
- Interprets the held code.
136
+ Interprets the code held .
137
137
138
138
Args:
139
139
ctx(:class:`business_logic.models.Context`): execution context
@@ -204,7 +204,7 @@ def is_content_object_interpret_children_itself(self):
204
204
205
205
def pprint (self ):
206
206
"""
207
- Prints entire tree starting from self to stdout.
207
+ Prints the entire tree starting from self to stdout.
208
208
209
209
Utility function for development purposes.
210
210
"""
@@ -223,18 +223,18 @@ def visit(self, node):
223
223
224
224
class NodeCache :
225
225
"""
226
- Creates cache with preloaded content objects for entire tree
227
- on first call of get_children().
226
+ Creates a cache with preloaded content objects for the entire tree
227
+ on the first call of get_children().
228
228
229
- Uses `1 + n` SQL queries, where n is count of used content types.
229
+ Uses `1 + n` SQL queries, where n is the count of used content types.
230
230
231
231
"""
232
232
def __init__ (self ):
233
233
self ._initialized = False
234
234
235
235
def get_children (self , node ):
236
236
"""
237
- Returns cached child nodes
237
+ Returns the cached child nodes.
238
238
239
239
Args:
240
240
node(:class:`business_logic.models.Node`): parent node
@@ -285,11 +285,11 @@ def _initialize(self, node):
285
285
286
286
class NodeCacheHolder (object ):
287
287
"""
288
- Implements get_children() function using :class:`business_logic.models.NodeCache`
288
+ Implements the get_children() function using :class:`business_logic.models.NodeCache`.
289
289
"""
290
290
def get_children (self , node ):
291
291
"""
292
- Returns cached child nodes
292
+ Returns the cached child nodes.
293
293
294
294
Args:
295
295
node(:class:`business_logic.models.Node`): parent node
@@ -306,8 +306,8 @@ class NodeVisitor(NodeCacheHolder):
306
306
"""
307
307
Utility class for tree traversal.
308
308
309
- Derived class should implement the :func:`business_logic.models.NodeVisitor.visit` method.
310
- Traversal is made by executing :func:`business_logic.models.NodeVisitor.preorder`
309
+ The derived class should implement the :func:`business_logic.models.NodeVisitor.visit` method.
310
+ Traversal is made by executing the :func:`business_logic.models.NodeVisitor.preorder`
311
311
or :func:`business_logic.models.NodeVisitor.postorder` method.
312
312
313
313
Examples:
@@ -316,7 +316,7 @@ class NodeVisitor(NodeCacheHolder):
316
316
"""
317
317
def visit (self , node , * args , ** kwargs ):
318
318
"""
319
- Main method which should be realised in derived classes
319
+ Main method which should be implemented in derived classes.
320
320
321
321
Args:
322
322
node(:class:`business_logic.models.Node`): currently processed node
@@ -332,7 +332,7 @@ def preorder(self, node, *args, **kwargs):
332
332
Tree traversal from top to bottom.
333
333
334
334
Args:
335
- node(:class:`business_logic.models.Node`): node for starting tree traversal
335
+ node(:class:`business_logic.models.Node`): node for starting the tree traversal
336
336
*args: arbitrary args which should be passed to :func:`business_logic.models.NodeVisitor.visit`
337
337
**kwargs: arbitrary kwargs which should be passed to :func:`business_logic.models.NodeVisitor.visit`
338
338
"""
@@ -345,7 +345,7 @@ def postorder(self, node, *args, **kwargs):
345
345
Tree traversal from bottom to top.
346
346
347
347
Args:
348
- node(:class:`business_logic.models.Node`): node for starting tree traversal
348
+ node(:class:`business_logic.models.Node`): node for starting the tree traversal
349
349
*args: arbitrary args which should be passed to :func:`business_logic.models.NodeVisitor.visit`
350
350
**kwargs: arbitrary kwargs which should be passed to :func:`business_logic.models.NodeVisitor.visit`
351
351
"""
0 commit comments