:mod:`xdoctest.demo`
====================

.. py:module:: xdoctest.demo

.. autoapi-nested-parse::

   This file contains quick demonstrations of how to use xdoctest

   CommandLine:
       xdoctest -m xdoctest.demo

       xdoctest -m xdoctest.demo --verbose 0
       xdoctest -m xdoctest.demo --silent
       xdoctest -m xdoctest.demo --quiet



Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   xdoctest.demo.MyClass



Functions
~~~~~~~~~

.. autoapisummary::

   xdoctest.demo.myfunc


.. function:: myfunc()

   Demonstrates how to write a doctest.
   Prefix with `>>>` and ideally place in an `Example:` block.
   You can also change Example, Ignore will
   Prefix with `>>>` and ideally place in an `Example:` block.

   CommandLine:
       # it would be nice if sphinx.ext.napoleon could handle this
       xdoctest -m ~/code/xdoctest/xdoctest/demo.py myfunc

   .. rubric:: Example

   >>> result = myfunc()
   >>> assert result == 123

   Ignore:
       >>> # it would be nice if sphinx.ext.napoleon could ignore this
       >>> print('this test is not run')


.. py:class:: MyClass(*args, **kw)

   Bases: :class:`object`

   .. rubric:: Example

   >>> self = MyClass.demo()
   >>> print('self.data = {!r}'.format(self.data))

   .. method:: demo(cls, **kw)
      :classmethod:


      CommandLine:
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.demo
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.demo --say

      .. rubric:: Example

      >>> print('starting my doctest')
      >>> self = MyClass.demo(demo='thats my demo')
      >>> # xdoc: +REQUIRES(--say)
      >>> print('self.data = {!r}'.format(self.data))


   .. method:: always_fails()


      CommandLine:
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails --fail
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails --fail --really

          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails:0 --fail
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails:1 --fail
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails:2 --fail
          xdoctest -m ~/code/xdoctest/xdoctest/demo.py MyClass.always_fails:3 --fail --really

      .. rubric:: Example

      >>> # xdoctest: +REQUIRES(--fail)
      >>> raise Exception('doctest always fails')

      .. rubric:: Example

      >>> # xdoctest: +REQUIRES(--fail)
      >>> MyClass.demo().always_fails()

      .. rubric:: Example

      >>> # xdoctest: +REQUIRES(--fail)
      >>> print('there is no way to fail')
      There are so many ways to fail

      .. rubric:: Example

      >>> # xdoctest: +REQUIRES(--fail)
      >>> # xdoctest: +REQUIRES(--really)
      >>> raise Exception  # xdoctest: +SKIP
      >>> print('did you know')  # xdoctest: +IGNORE_WANT
      directives are useful
      >>> print('match this')
      ...
      >>> print('match this')  # xdoctest: -ELLIPSIS
      ...



