<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_apiary_doc(task_router):
 """Generate apiary documentation. Create a Apiary generator and add application packages to it. :param task_router: task router, injected :type task_router: TaskRouter :return: apiary generator :rtype: ApiaryDoc """

    generator = ApiaryDoc()

    for m in task_router.get_task_packages() + get_method_packages():
        m = importlib.import_module(m)
        generator.docmodule(m)

    return generator