Documentation and formatting fixes

This commit is contained in:
riley 2021-09-28 01:36:12 -04:00
parent 134d71f44d
commit 9686e43ec2
2 changed files with 10 additions and 12 deletions

View file

@ -57,14 +57,14 @@ class Todo(TodoObject):
else: # catch-all for unlisted notes else: # catch-all for unlisted notes
return 0 return 0
def _get_parent(self, level, obj: TodoObject, obj_type: Type[TodoObject] = None): def _get_parent(self, level: int, obj: TodoObject, obj_type: Optional[Type[TodoObject]] = None):
"""Gets the parent for an object at level X. """Gets the parent for an object at level X.
If an object with a lower level cannot be found within the obj, it will return the obj. If an object with a lower level cannot be found within the obj, it will return the obj.
Args: Args:
level (int): The level to find the parent for. level (int): The level to find the parent for.
obj (TodoObject): Object to grab parents from. obj (TodoObject): Object to grab parents from.
obj_type (Type[TodoObject]): The type of the object the parent should be. Default is None. obj_type (Type[TodoObject], optional): The type of the object the parent should be. Default is None.
Returns: Returns:
TodoObject: The object found. TodoObject: The object found.

View file

@ -24,10 +24,10 @@ class TodoObject:
Args: Args:
immediate (bool, optional): Whether it should return immediate children only. Defaults to False. immediate (bool, optional): Whether it should return immediate children only. Defaults to False.
obj_type (Optional[Type[T]], optional): Specify the types of children to return. Defaults to None. obj_type (Type[Note | Category | Task], optional): Specify the types of children to return. Defaults to None.
Returns: Returns:
list[T]: [description] list[Note | Category | Task]: Returns all children that match the criteria.
""" """
output = [] output = []
for child in self.children: for child in self.children:
@ -45,10 +45,10 @@ class TodoObject:
"""Get all parents of an object. Optionally specify a class of TodoObject to return. """Get all parents of an object. Optionally specify a class of TodoObject to return.
Args: Args:
obj_type (Optional[Type[T]], optional): Specify the types of parents to return. Defaults to None. obj_type (Type[Note | Category | Task], optional): Specify the types of parents to return. Defaults to None.
Returns: Returns:
list[T]: List of parents found. list[Note | Category | Task]: List of parents found.
""" """
output = [] output = []
for parent in self.parents: for parent in self.parents:
@ -67,7 +67,6 @@ class TodoObject:
Returns: Returns:
str: the markdown text generated str: the markdown text generated
""" """
output = "" output = ""
for i in self.get_children(): for i in self.get_children():
if len(output) > 0: if len(output) > 0:
@ -127,13 +126,12 @@ class TodoObject:
complete (Optional[bool], optional): If true, return completed tasks only, inverse if False. Defaults to None. complete (Optional[bool], optional): If true, return completed tasks only, inverse if False. Defaults to None.
Returns: Returns:
Task: [description] Task: Returns the task found
""" """
for task in self.get_tasks(immediate, complete): for task in self.get_tasks(immediate, complete):
if re.match(regex, task.text): if re.match(regex, task.text):
return task return task
def get_categories(self, immediate: bool = False) -> list[Category]: def get_categories(self, immediate: bool = False) -> list[Category]:
"""Gets all categories from children of the TodoObject. """Gets all categories from children of the TodoObject.
@ -150,7 +148,7 @@ class TodoObject:
immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False. immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False.
Returns: Returns:
Category: [description] Category: Returns the category found.
""" """
for category in self.get_categories(immediate): for category in self.get_categories(immediate):
if re.match(regex, category.text): if re.match(regex, category.text):
@ -161,7 +159,7 @@ class TodoObject:
Args: Args:
immediate (bool, optional): Whether or not it should return immeduate children only. Defaults to False. immediate (bool, optional): Whether or not it should return immeduate children only. Defaults to False.
c
Returns: Returns:
Note: Returns all notes found. Note: Returns all notes found.
""" """
@ -175,7 +173,7 @@ c
immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False. immediate (bool, optional): Whether or not it should return immediate children only. Defaults to False.
Returns: Returns:
Note: [description] Note: Returns the note found.
""" """
for note in self.get_notes(immediate): for note in self.get_notes(immediate):
if re.match(regex, note.text): if re.match(regex, note.text):