Permalink
Browse files

Extended API documentation to include all significant methods.

  • Loading branch information...
1 parent 7e17e8b commit 17e0d322932c58fb06e67f3bf628e52c1ca47ffb @CalumJEadie committed Sep 18, 2012
Showing with 41 additions and 22 deletions.
  1. +41 −22 microbuild/microbuild.py
View
63 microbuild/microbuild.py
@@ -18,7 +18,7 @@
def build(module,args):
"""
- Build the specified module.
+ Build the specified module with specified arguments.
@type module: module
@type args: list of arguments
@@ -34,34 +34,18 @@ def build(module,args):
_run_from_task_name(module,args.task)
def _run_from_task_name(module,task_name):
+ """
+ @type module: module
+ @type task_name: string
+ @param task_name: Task name, exactly corresponds to function name.
+ """
# Create logger.
logger = _get_logger(module)
task = getattr(module,task_name)
_run(module,logger,task,set([]))
-def _get_logger(module):
-
- # Create Logger
- logger = logging.getLogger(os.path.basename(module.__file__))
- logger.setLevel(logging.DEBUG)
-
- # Create console handler and set level to debug
- ch = logging.StreamHandler()
- ch.setLevel(logging.DEBUG)
-
- # Create formatter
- formatter = logging.Formatter(_LOGGING_FORMAT)
-
- # Add formatter to ch
- ch.setFormatter(formatter)
-
- # Add ch to logger
- logger.addHandler(ch)
-
- return logger
-
def _run(module,logger,task,completed_tasks):
"""
@type module: module
@@ -104,6 +88,10 @@ def _run(module,logger,task,completed_tasks):
return completed_tasks
def _create_parser(module):
+ """
+ @type module: module
+ @rtype: argparse.ArgumentParser
+ """
# Get all tasks.
tasks = _get_tasks(module)
@@ -195,6 +183,8 @@ def __call__(self,func):
def ignore(obj):
"""
Decorator to specify that a task should be ignored.
+
+ @type obj: function or Task, depending on order @ignore and @task used
"""
obj.ignorable = True
return obj
@@ -230,6 +220,8 @@ def is_ignorable(self):
def _get_tasks(module):
"""
Returns all functions marked as tasks.
+
+ @type module: module
"""
# Get all functions that are marked as task and pull out the task object
# from each (name,value) pair.
@@ -238,5 +230,32 @@ def _get_tasks(module):
def _get_max_name_length(module):
"""
Returns the length of the longest task name.
+
+ @type module: module
"""
return max([len(task.__name__) for task in _get_tasks(module)])
+
+def _get_logger(module):
+ """
+ @type module: module
+ @rtype: logging.Logger
+ """
+
+ # Create Logger
+ logger = logging.getLogger(os.path.basename(module.__file__))
+ logger.setLevel(logging.DEBUG)
+
+ # Create console handler and set level to debug
+ ch = logging.StreamHandler()
+ ch.setLevel(logging.DEBUG)
+
+ # Create formatter
+ formatter = logging.Formatter(_LOGGING_FORMAT)
+
+ # Add formatter to ch
+ ch.setFormatter(formatter)
+
+ # Add ch to logger
+ logger.addHandler(ch)
+
+ return logger

0 comments on commit 17e0d32

Please sign in to comment.