title: ReadTheDocs will not autogenerate API documentation for a project that uses Matplotlib
body: <p>I am able to use Sphinx to auto generate my project's API documentation locally, but I run into trouble when I try to use ReadTheDocs.  When ReadTheDocs builds the documentation, the API pages are all blank (see <a href="http://clearplot.readthedocs.org/en/latest/api/clearplot.axes.html" rel="nofollow">this</a>, for example).  After I read <a href="http://blog.rtwilson.com/how-to-make-your-sphinx-documentation-compile-with-readthedocs-when-youre-using-numpy-and-scipy/" rel="nofollow">this blog entry</a>, I realized the solution is to mock things like numpy and matplotlib.  So I added the following line to my <code>conf.py</code></p>
  
  <pre><code>autodoc_mock_imports = ['numpy', 'matplotlib', 'matplotlib.pyplot', 'matplotlib.patches', 'matplotlib.path', 'matplotlib.lines', 'matplotlib.text', 'matplotlib.transforms', 'matplotlib.artist', 'cpickle']
  </code></pre>
  
  <p>With that addition, I cannot build the API documentation locally or on ReadTheDocs, because of the following two Sphinx issues.  </p>
  
  <p>Issue #1:  </p>
  
  <p>When I build the documentation I get the following error.</p>
  
  <pre><code>/Users/Ben/Documents/Python/clearplot/doc/source/api/clearplot.rst:19: WARNING: autodoc: failed to import module u'clearplot'; the following exception was raised:
  Traceback (most recent call last):
  File "/Users/Ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
  __import__(self.modname)
  File "/Users/Ben/Documents/Python/clearplot/clearplot/__init__.py", line 33, in &lt;module&gt;
  mpl_version = _parse_version_string(_mpl.__version__)
  File "/Users/Ben/Documents/Python/clearplot/clearplot/__init__.py", line 19, in _parse_version_string
  v_list = v.split(".")
  AttributeError: type object '__version__' has no attribute 'split'
  </code></pre>
  
  <p>I have confirmed that this error comes from simply doing <code>matplotlib.__version__.split(".")</code>.  I couldn't figure out how to solve this issue quickly so I commented it out.</p>
  
  <p>Issue #2: </p>
  
  <p>Now, I get the following error when I build the documentation.</p>
  
  <pre><code>/Users/Ben/Documents/Python/clearplot/doc/source/api/clearplot.rst:19: WARNING: autodoc: failed to import module u'clearplot'; the following exception was raised:
  Traceback (most recent call last):
  File "/Users/Ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
  __import__(self.modname)
  File "/Users/Ben/Documents/Python/clearplot/clearplot/__init__.py", line 45, in &lt;module&gt;
  import params
  File "/Users/Ben/Documents/Python/clearplot/clearplot/params.py", line 19, in &lt;module&gt;
  _mpl.rcParams['backend'] = 'Qt4Agg'
  TypeError: '_MockModule' object does not support item assignment
  </code></pre>
  
  <p>If I comment out the offending line (<code>_mpl.rcParams['backend'] = 'Qt4Agg'</code>), I get the same error for the next line because my <code>params</code> module is full of assignments to the <code>matplotlib.rcParams</code> dictionary.  </p>
  
  <p>Both of these issues look like a pain to fix.  Is there a better way?  If not, how should I solve Issue #1 and #2?</p>
  
  <p>From reading <a href="http://www.voidspace.org.uk/python/mock/examples.html#mocking-a-dictionary-with-magicmock" rel="nofollow">this</a> it looks like there is a work around for using dictionaries with mock.  Should I search for a similar solution for using something as basic as the string that comes from <code>matplotlib.__version__</code>?</p>
  
  <p>In case it helps, the code on github is <a href="https://github.com/breedlun/clearplot" rel="nofollow">here</a>.</p>