# -*- coding: utf-8 -*-
#
# SimPhoNy-Mayavi documentation build configuration file
#


def mock_modules():
    import sys

    from mock import MagicMock

    MOCK_MODULES = []
    MOCK_TYPES = []

    try:
        import numpy  # noqa
    except ImportError:
        MOCK_MODULES = ['numpy']

    try:
        import simphony  # noqa
    except ImportError:
        MOCK_MODULES.extend([
            'simphony',
            'simphony.testing',
            'simphony.testing.utils',
            'simphony.cuds',
            'simphony.cuds.abstractmesh',
            'simphony.cuds.abstractparticles',
            'simphony.cuds.abstractlattice'])

    try:
        import mayavi  # noqa
    except ImportError:
        MOCK_MODULES.extend((
            'tvtk',
            'tvtk.api',
            'mayavi',
            'mayavi.sources',
            'mayavi.sources.vtk_data_source',
            'mayavi.tools',
            'mayavi.tools.tools'))

        from traits.api import HasTraits
        class VTKDataSource(HasTraits):
            pass

    class Mock(MagicMock):

        TYPES = {mock_type: VTKDataSource}

        @classmethod
        def __getattr__(self, name):

            return Mock.TYPES.get(name, Mock(mocked_name=name))

        def __call__(self, *args, **kwards):
            return Mock()

        @property
        def __name__(self):
            return self.mocked_name

    sys.modules.update(
        (mod_name, Mock(mocked_name=mod_name)) for mod_name in MOCK_MODULES)
    print 'mocking modules {} and types {}'.format(MOCK_MODULES, MOCK_TYPES)

# -- General configuration ------------------------------------------------

# check and mock missing modules
mock_modules()


extensions = [
    'sphinx.ext.autodoc',
    #'sphinx.ext.intersphinx',
    #'sphinx.ext.todo',
    #'sphinx.ext.coverage',
    #'sphinx.ext.mathjax',
    #'sphinx.ext.ifconfig',
    #'sphinx.ext.viewcode',
    'sphinx.ext.autosummary',
    'trait_documenter',
    'sectiondoc']
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'SimPhoNy-Mayavi'
copyright = u'2015, SimPhoNy FP7 Collaboration'
version = '0.1.0'
release = '0.1.0.dev0'
pygments_style = 'sphinx'

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}

# -- Options for HTML output ----------------------------------------------

html_theme = 'default'
html_logo = '_static/simphony_logo.png'
html_static_path = ['_static']
htmlhelp_basename = 'SimPhoNy-MayaviDoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {}
latex_documents = [(
    'index', 'SimPhoNy-Mayavi.tex', u'SimPhoNy-Mayavi Documentation',
    u'SimPhoNy FP7 Collaboration', 'manual')]
latex_logo = '_static/simphony_logo.png'

# -- Options for manual page output ---------------------------------------

man_pages = [(
    'index', 'simphony', u'SimPhoNy-Mayavi Documentation',
    [u'SimPhoNy FP7 Collaboration'], 1)]

# -- Options for Texinfo output -------------------------------------------

texinfo_documents = [(
    'index', 'SimPhoNy', u'SimPhoNy-Mayavi Documentation',
    u'SimPhoNy FP7 Collaboration', 'SimPhoNy-Mayavi', 'Visualisation tools',
    'Miscellaneous'),
]

# -- Options for Epub output ----------------------------------------------

epub_title = u'SimPhoNy-Mayavi'
epub_author = u'SimPhoNy FP7 Collaboration'
epub_publisher = u'SimPhoNy FP7 Collaboration'
epub_copyright = u'2015, SimPhoNy FP7 Collaboration'
epub_exclude_files = ['search.html']

@@ -1088,17 +1088,23 @@
  = %7B
-mock_type
+'VTKDataSource'
 : VT

fix dictionary key