{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "sphinxext",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The IPython Sphinx Directive is in 'beta' and currently under active development. Improvements to the code or documentation are welcome!"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "ipython",
              "domain": "rst",
              "role": "dir",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " directive is a stateful shell that can be used in "
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "reStructured text"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " files."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "It knows about standard ipython prompts, and extracts the input and output lines.  These prompts will be renumbered starting at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ".  The inputs will be fed to an embedded ipython interpreter and the outputs from that interpreter will be inserted as well.  For example, code blocks like the following    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. ipython::\n\n   In [136]: x = 2\n\n   In [137]: x**3\n   Out[137]: 8",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "will be rendered as"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [136]: x = 2\n\nIn [137]: x**3\nOut[137]: 8",
          "execution_status": null
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This tutorial should be read side-by-side with the Sphinx source for this document because otherwise you will see only the rendered output and not the code that generated it.  Excepting the example above, we will not in general be showing the literal ReST in this document that generates the rendered output."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "IPython Sphinx Directive"
        }
      ],
      "level": 0,
      "target": "ipython_directive"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The IPython directive takes a number of options detailed here."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "Create an IPython directive.\n\n.. rst:directive:option:: doctest\n\n   Run a doctest on IPython code blocks in rst.\n\n.. rst:directive:option:: python\n\n   Used to indicate that the relevant code block does not have IPython prompts.\n\n.. rst:directive:option:: okexcept\n\n   Allow the code block to raise an exception.\n\n.. rst:directive:option:: okwarning\n\n   Allow the code block to emit an warning.\n\n.. rst:directive:option:: suppress\n\n   Silence any warnings or expected errors.\n\n.. rst:directive:option:: verbatim\n\n   A noop that allows for any text to be syntax highlighted as valid IPython code.\n\n.. rst:directive:option:: savefig: OUTFILE [IMAGE_OPTIONS]\n\n   Save output from matplotlib to *outfile*.",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "It's important to note that all of these options can be used for the entire directive block or they can decorate individual lines of code as explained in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "pseudo-decorators",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "sphinxext"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Directive and options"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The state from previous sessions is stored, and standard error is trapped. At doc build time, ipython's output and std err will be inserted, and prompts will be renumbered. So the prompt below should be renumbered in the rendered docs, and pick up where the block above left off."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "  In [138]: z = x*3   # x is recalled from previous block\n\n  In [139]: z\n  Out[139]: 6\n\n  In [142]: print(z)\n  6\n\n  In [141]: q = z[)   # this is a syntax error -- we trap ipy exceptions\n  ------------------------------------------------------------\n     File \"<ipython console>\", line 1\n       q = z[)   # this is a syntax error -- we trap ipy exceptions\n\t     ^\n  SyntaxError: invalid syntax",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Persisting the Python session across IPython directive blocks"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The embedded interpreter supports some limited markup.  For example, you can put comments in your ipython sessions, which are reported verbatim.  There are some handy \"pseudo-decorators\" that let you doctest the output.  The inputs are fed to an embedded ipython session and the outputs from the ipython session are inserted into your doc.  If the output in your doc and in the ipython session don't match on a doctest assertion, an error will occur."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [1]: x = 'hello world'\n\n# this will raise an error if the ipython output is different\n@doctest\nIn [2]: x.upper()\nOut[2]: 'HELLO WORLD'\n\n# some readline features cannot be supported, so we allow\n# \"verbatim\" blocks, which are dumped in verbatim except prompts\n# are continuously numbered\n@verbatim\nIn [3]: x.st<TAB>\nx.startswith  x.strip",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For more information on @doctest decorator, please refer to the end of this page in Pseudo-Decorators section."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Adding documentation tests to your IPython directive"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Multi-line input is supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [130]: url = 'http://ichart.finance.yahoo.com/table.csv?s=CROX\\\n   .....: &d=9&e=22&f=2009&g=d&a=1&br=8&c=2006&ignore=.csv'\n\nIn [131]: print(url.split('&'))\n['http://ichart.finance.yahoo.com/table.csv?s=CROX', 'd=9', 'e=22',",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Multi-line input"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The IPython Sphinx Directive makes it possible to test the outputs that you provide with your code. To do this, decorate the contents in your directive block with one of the options listed above."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If an IPython doctest decorator is found, it will take these steps when your documentation is built:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Run the "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "input"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " lines in your IPython directive block against the current Python kernel (remember that the session"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "persists across IPython directive blocks);"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Compare the "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "output"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " of this with the output text that you've put in the IPython directive block (what comes"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "after "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "Out[NN]",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ");"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If there is a difference, the directive will raise an error and your documentation build will fail."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "You can do doctesting on multi-line output as well.  Just be careful when using non-deterministic inputs like random numbers in the ipython directive, because your inputs are run through a live interpreter, so if you are doctesting random output you will get an error.  Here we \"seed\" the random number generator for deterministic output, and we suppress the seed line so it doesn't show up in the rendered output"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [133]: import numpy.random\n\n@suppress\nIn [134]: numpy.random.seed(2358)\n\n@doctest\nIn [135]: numpy.random.rand(10,2)\nOut[135]:\narray([[0.64524308, 0.59943846],\n       [0.47102322, 0.8715456 ],\n       [0.29370834, 0.74776844],\n       [0.99539577, 0.1313423 ],\n       [0.16250302, 0.21103583],\n       [0.81626524, 0.1312433 ],\n       [0.67338089, 0.72302393],\n       [0.7566368 , 0.07033696],\n       [0.22591016, 0.77731835],\n       [0.0072729 , 0.34273127]])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For more information on @suppress and @doctest decorators, please refer to the end of this file in Pseudo-Decorators section."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Another demonstration of multi-line input and output"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [106]: print(x)\njdh\n\nIn [109]: for i in range(10):\n   .....:     print(i)\n   .....:\n   .....:\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Most of the \"pseudo-decorators\" can be used an options to ipython mode.  For example, to setup matplotlib pylab but suppress the output, you can do.  When using the matplotlib "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "use"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " directive, it should occur before any import of pylab.  This will not show up in the rendered docs, but the commands will be executed in the embedded interpreter and subsequent line numbers will be incremented to reflect the inputs     "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. ipython::\n   :suppress:\n   :okexcept:\n\n   In [144]: from matplotlib.pylab import *\n\n   In [145]: ion()",
          "execution_status": null
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [144]: from matplotlib.pylab import *\n\nIn [145]: ion()",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Likewise, you can set "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ":doctest:"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ":verbatim:"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to apply these settings to the entire block.  For example,"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [9]: cd mpl/examples/\n/home/jdhunter/mpl/examples\n\nIn [10]: pwd\nOut[10]: '/home/jdhunter/mpl/examples'\n\n\nIn [14]: cd mpl/examples/<TAB>\nmpl/examples/animation/        mpl/examples/misc/\nmpl/examples/api/              mpl/examples/mplot3d/\nmpl/examples/axes_grid/        mpl/examples/pylab_examples/\nmpl/examples/event_handling/   mpl/examples/widgets\n\nIn [14]: cd mpl/examples/widgets/\n/home/msierig/mpl/examples/widgets\n\nIn [15]: !wc *\n    2    12    77 README.txt\n   40    97   884 buttons.py\n   26    90   712 check_buttons.py\n   19    52   416 cursor.py\n  180   404  4882 menu.py\n   16    45   337 multicursor.py\n   36   106   916 radio_buttons.py\n   48   226  2082 rectangle_selector.py\n   43   118  1063 slider_demo.py\n   40   124  1088 span_selector.py\n  450  1274 12457 total",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "You can create one or more pyplot plots and insert them with the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "@savefig"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " decorator."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For more information on @savefig decorator, please refer to the end of this page in Pseudo-Decorators section."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "@savefig plot_simple.png width=4in\nIn [151]: plot([1,2,3]);\n\n# use a semicolon to suppress the output\n@savefig hist_simple.png width=4in\nIn [151]: hist(np.random.randn(10000), 100);",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In a subsequent session, we can update the current figure with some text, and then resave"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [151]: ylabel('number')\n\nIn [152]: title('normal distribution')\n\n@savefig hist_with_text.png width=4in\nIn [153]: grid(True)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "You can also have function definitions included in the source."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [3]: def square(x):\n   ...:     \"\"\"\n   ...:     An overcomplicated square function as an example.\n   ...:     \"\"\"\n   ...:     if x < 0:\n   ...:         x = abs(x)\n   ...:     y = x * x\n   ...:     return y\n   ...:",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Then call it from a subsequent section."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [4]: square(3)\nOut [4]: 9\n\nIn [5]: square(-2)\nOut [5]: 4",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Testing directive outputs"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Pure python code is supported by the optional argument "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "python",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". In this pure python syntax you do not include the output from the python interpreter. The following markup     "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. ipython:: python\n\n   foo = 'bar'\n   print(foo)\n   foo = 2\n   foo**2",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Renders as"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "foo = 'bar'\nprint(foo)\nfoo = 2\nfoo**2",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "We can even plot from python, using the savefig decorator, as well as, suppress output with a semicolon"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "@savefig plot_simple_python.png width=4in\nplot([1,2,3]);",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For more information on @savefig decorator, please refer to the end of this page in Pseudo-Decorators section."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similarly, std err is inserted"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "foo = 'bar'\nfoo[)",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Writing Pure Python Code"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Comments are handled and state is preserved"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "# comments are handled\nprint(foo)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you don't see the next code block then the options work."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "ioff()\nion()",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Handling Comments"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Multi-line input is handled."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "line = 'Multi\\\n        line &\\\n        support &\\\n        works'\nprint(line.split('&'))",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Functions definitions are correctly parsed"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "def square(x):\n    \"\"\"\n    An overcomplicated square function as an example.\n    \"\"\"\n    if x < 0:\n        x = abs(x)\n    y = x * x\n    return y",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "And persist across sessions"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "print(square(3))\nprint(square(-2))",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Pretty much anything you can do with the ipython code, you can do with a simple python script. Obviously, though it doesn't make sense to use the doctest option."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Splitting Python statements across lines"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here are the supported decorators, and any optional arguments they take.  Some of the decorators can be used as options to the entire block (eg "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "verbatim"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "suppress"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), and some only apply to the line just below them (eg "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "savefig"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ")."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "@suppress"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "execute the ipython input block, but suppress the input and output     block from the rendered output.  Also, can be applied to the entire     "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ".. ipython"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " block as a directive option with "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ":suppress:"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "@verbatim"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "insert the input and output block in verbatim, but auto-increment     the line numbers. Internally, the interpreter will be fed an empty     string, so it is a no-op that keeps line numbering consistent.     Also, can be applied to the entire "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ".. ipython"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " block as a     directive option with "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ":verbatim:"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "@savefig OUTFILE [IMAGE_OPTIONS]"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "save the figure to the static directory and insert it into the     document, possibly binding it into a minipage and/or putting     code/figure label/references to associate the code and the     figure. Takes args to pass to the image directive ("
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "scale"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ",     "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "width"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ", etc can be kwargs); see "
                },
                {
                  "__type": "Link",
                  "__tag": 4049,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "image options"
                    }
                  ],
                  "url": "http://docutils.sourceforge.net/docs/ref/rst/directives.html#image",
                  "title": ""
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "     for details."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "@doctest"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Compare the pasted in output in the ipython block with the output     generated at doc build time, and raise errors if they don't     match. Also, can be applied to the entire "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ".. ipython"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " block as a     directive option with "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": ":doctest:"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Pseudo-Decorators"
        }
      ],
      "level": 1,
      "target": "pseudo-decorators"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ipython_savefig_dir"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The directory in which to save the figures. This is relative to the     Sphinx source directory. The default is "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "html_static_path",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ipython_rgxin"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The compiled regular expression to denote the start of IPython input     lines. The default is "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "re.compile('In \\[(\\d+)\\]:\\s?(.*)\\s*')",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". You     shouldn't need to change this."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ipython_rgxout"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The compiled regular expression to denote the start of IPython output     lines. The default is "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "re.compile('Out\\[(\\d+)\\]:\\s?(.*)\\s*')",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". You     shouldn't need to change this."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ipython_promptin"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The string to represent the IPython input prompt in the generated ReST.     The default is "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "'In [%d]:'",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". This expects that the line numbers are used     in the prompt."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ipython_promptout"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The string to represent the IPython prompt in the generated ReST. The     default is "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "'Out [%d]:'",
                  "domain": null,
                  "role": null,
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". This expects that the line numbers are used     in the prompt."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Configuration Options"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Automatically generated documentation"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}