title: How do I get Sphinx to test code embedded in documentation?
body: <p>If this code is a blockquote in my documentation, what do I need to do to make <a href="http://sphinx.pocoo.org/" rel="nofollow noreferrer">Sphinx</a> run it when the documentation is generated? I tried adding</p>
  
  <pre><code>.. testcode::
  
      import datetime
      def today():
          return datetime.datetime.now().date()
      if True:
          today()
  </code></pre>
  
  <p>to one of the <code>.rst</code> sources and the Sphinx doctest extension to <code>conf.py</code>, but I got an error complaining about unexpected indentation on the first line of the function body. Is Sphinx's doctest able to run functions defined in the documentation?</p>