prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  celery.contrib.sphinx fails with Sphinx 1.6.1
  When using the `celery.contrib.sphinx` extension with Sphinx 1.6.1 with Celery 4.0.2 the following occurs:
  
  ```
  Exception occurred:
    File "/home/ubuntu/virtualenvs/venv-system/lib/python2.7/site-packages/celery/contrib/sphinx.py", line 72, in setup
      app.domains['py'].directives['task'] = TaskDirective
  AttributeError: 'Sphinx' object has no attribute 'domains'
  The full traceback has been saved in /tmp/sphinx-err-oOWabx.log, if you want to report the issue to the developers.
  Please also report this if it was a user error, so that a better error message can be provided next time.
  A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
  make: *** [html] Error 1
  ```
  
  The `domains` property seems to have been removed in sphinx-doc/sphinx#3656 and I think this line needs to be replaced with the [`add_directive` method](http://www.sphinx-doc.org/en/stable/extdev/appapi.html#sphinx.application.Sphinx.add_directive) (or more likely the [`add_directive_to_domain` method](http://www.sphinx-doc.org/en/stable/extdev/appapi.html#sphinx.application.Sphinx.add_directive_to_domain)).
  
  </issue>
  <code>
  [start of celery/contrib/sphinx.py]
  1 # -*- coding: utf-8 -*-
  2 """Sphinx documentation plugin used to document tasks.
  3 
  4 Introduction
  5 ============
  6 
  7 Usage
  8 -----
  9 
  10 Add the extension to your :file:`docs/conf.py` configuration module:
  11 
  12 .. code-block:: python
  13 
  14     extensions = (...,
  15                   'celery.contrib.sphinx')
  16 
  17 If you'd like to change the prefix for tasks in reference documentation
  18 then you can change the ``celery_task_prefix`` configuration value:
  19 
  20 .. code-block:: python
  21 
  22     celery_task_prefix = '(task)'  # < default
  23 
  24 With the extension installed `autodoc` will automatically find
  25 task decorated objects and generate the correct (as well as
  26 add a ``(task)`` prefix), and you can also refer to the tasks
  27 using `:task:proj.tasks.add` syntax.
  28 
  29 Use ``.. autotask::`` to manually document a task.
  30 """
  31 from __future__ import absolute_import, unicode_literals
  32 from inspect import formatargspec
  33 from sphinx.domains.python import PyModulelevel
  34 from sphinx.ext.autodoc import FunctionDocumenter
  35 from celery.app.task import BaseTask
  36 from celery.five import getfullargspec
  37 
  38 
  39 class TaskDocumenter(FunctionDocumenter):
  40     """Document task definitions."""
  41 
  42     objtype = 'task'
  43     member_order = 11
  44 
  45     @classmethod
  46     def can_document_member(cls, member, membername, isattr, parent):
  47         return isinstance(member, BaseTask) and getattr(member, '__wrapped__')
  48 
  49     def format_args(self):
  50         wrapped = getattr(self.object, '__wrapped__', None)
  51         if wrapped is not None:
  52             argspec = getfullargspec(wrapped)
  53             fmt = formatargspec(*argspec)
  54             fmt = fmt.replace('\\', '\\\\')
  55             return fmt
  56         return ''
  57 
  58     def document_members(self, all_members=False):
  59         pass
  60 
  61 
  62 class TaskDirective(PyModulelevel):
  63     """Sphinx task directive."""
  64 
  65     def get_signature_prefix(self, sig):
  66         return self.env.config.celery_task_prefix
  67 
  68 
  69 def setup(app):
  70     """Setup Sphinx extension."""
  71     app.add_autodocumenter(TaskDocumenter)
  72     app.domains['py'].directives['task'] = TaskDirective
  73     app.add_config_value('celery_task_prefix', '(task)', True)
  74
  [end of celery/contrib/sphinx.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/celery/contrib/sphinx.py b/celery/contrib/sphinx.py
  --- a/celery/contrib/sphinx.py
  +++ b/celery/contrib/sphinx.py
  @@ -69,5 +69,5 @@
   def setup(app):
       """Setup Sphinx extension."""
       app.add_autodocumenter(TaskDocumenter)
  -    app.domains['py'].directives['task'] = TaskDirective
  +    app.add_directive_to_domain('py', 'task', TaskDirective)
       app.add_config_value('celery_task_prefix', '(task)', True)
  
verification_info: {"golden_diff": "diff --git a/celery/contrib/sphinx.py b/celery/contrib/sphinx.py\n--- a/celery/contrib/sphinx.py\n+++ b/celery/contrib/sphinx.py\n@@ -69,5 +69,5 @@\n def setup(app):\n     \"\"\"Setup Sphinx extension.\"\"\"\n     app.add_autodocumenter(TaskDocumenter)\n-    app.domains['py'].directives['task'] = TaskDirective\n+    app.add_directive_to_domain('py', 'task', TaskDirective)\n     app.add_config_value('celery_task_prefix', '(task)', True)\n", "issue": "celery.contrib.sphinx fails with Sphinx 1.6.1\nWhen using the `celery.contrib.sphinx` extension with Sphinx 1.6.1 with Celery 4.0.2 the following occurs:\r\n\r\n```\r\nException occurred:\r\n  File \"/home/ubuntu/virtualenvs/venv-system/lib/python2.7/site-packages/celery/contrib/sphinx.py\", line 72, in setup\r\n    app.domains['py'].directives['task'] = TaskDirective\r\nAttributeError: 'Sphinx' object has no attribute 'domains'\r\nThe full traceback has been saved in /tmp/sphinx-err-oOWabx.log, if you want to report the issue to the developers.\r\nPlease also report this if it was a user error, so that a better error message can be provided next time.\r\nA bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!\r\nmake: *** [html] Error 1\r\n```\r\n\r\nThe `domains` property seems to have been removed in sphinx-doc/sphinx#3656 and I think this line needs to be replaced with the [`add_directive` method](http://www.sphinx-doc.org/en/stable/extdev/appapi.html#sphinx.application.Sphinx.add_directive) (or more likely the [`add_directive_to_domain` method](http://www.sphinx-doc.org/en/stable/extdev/appapi.html#sphinx.application.Sphinx.add_directive_to_domain)).\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Sphinx documentation plugin used to document tasks.\n\nIntroduction\n============\n\nUsage\n-----\n\nAdd the extension to your :file:`docs/conf.py` configuration module:\n\n.. code-block:: python\n\n    extensions = (...,\n                  'celery.contrib.sphinx')\n\nIf you'd like to change the prefix for tasks in reference documentation\nthen you can change the ``celery_task_prefix`` configuration value:\n\n.. code-block:: python\n\n    celery_task_prefix = '(task)'  # < default\n\nWith the extension installed `autodoc` will automatically find\ntask decorated objects and generate the correct (as well as\nadd a ``(task)`` prefix), and you can also refer to the tasks\nusing `:task:proj.tasks.add` syntax.\n\nUse ``.. autotask::`` to manually document a task.\n\"\"\"\nfrom __future__ import absolute_import, unicode_literals\nfrom inspect import formatargspec\nfrom sphinx.domains.python import PyModulelevel\nfrom sphinx.ext.autodoc import FunctionDocumenter\nfrom celery.app.task import BaseTask\nfrom celery.five import getfullargspec\n\n\nclass TaskDocumenter(FunctionDocumenter):\n    \"\"\"Document task definitions.\"\"\"\n\n    objtype = 'task'\n    member_order = 11\n\n    @classmethod\n    def can_document_member(cls, member, membername, isattr, parent):\n        return isinstance(member, BaseTask) and getattr(member, '__wrapped__')\n\n    def format_args(self):\n        wrapped = getattr(self.object, '__wrapped__', None)\n        if wrapped is not None:\n            argspec = getfullargspec(wrapped)\n            fmt = formatargspec(*argspec)\n            fmt = fmt.replace('\\\\', '\\\\\\\\')\n            return fmt\n        return ''\n\n    def document_members(self, all_members=False):\n        pass\n\n\nclass TaskDirective(PyModulelevel):\n    \"\"\"Sphinx task directive.\"\"\"\n\n    def get_signature_prefix(self, sig):\n        return self.env.config.celery_task_prefix\n\n\ndef setup(app):\n    \"\"\"Setup Sphinx extension.\"\"\"\n    app.add_autodocumenter(TaskDocumenter)\n    app.domains['py'].directives['task'] = TaskDirective\n    app.add_config_value('celery_task_prefix', '(task)', True)\n", "path": "celery/contrib/sphinx.py"}]}