#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# PyLaDe documentation build configuration file, created by
# sphinx-quickstart on Wed Apr  5 13:30:04 2017.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme
import recommonmark
from recommonmark.transform import AutoStructify
from recommonmark.parser import CommonMarkParser

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

extensions = ['sphinx.ext.autodoc',
    'sphinx.ext.todo',
    'sphinx.ext.viewcode',
    'sphinx.ext.githubpages',
    'sphinx.ext.napoleon']

# Why autosummary? It solves 'WARNING: toctree references unknown document'
# http://stackoverflow.com/questions/20381883/python-sphinx-autosummary-error

# This solves 'toctree contains reference to nonexisting document' warnings.
# But it also hides the methods. So I don't want to use it. The problem is only
# with the sphinx_rtd_theme for some reason.
# See http://stackoverflow.com/questions/39285808/sphinx-autosummary-toctree-contains-reference-to-nonexisting-document-warnings
# numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# Add recommonmark for markdown support

source_parsers = {
    '.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md']
# source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'PyLaDe'
copyright = '2017, <NAME>'
author = '<NAME>'

# The short X.Y version.
version = '0.1.0'
# The full version, including alpha/beta/rc tags.
release = '0.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'

# Use ReadTheDocs theme. (Removed for incompatibilities with numpydoc)
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# sphinx_rtd_theme options
# html_theme_options = {
#     'collapse_navigation': False,
#     'display_version': False,
#     'navigation_depth': 3,
# }

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'PyLaDedoc'


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

latex_elements = {
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'PyLaDe.tex', 'PyLaDe Documentation',
     '<NAME>', 'manual'),
]


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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, 'pylade', 'PyLaDe Documentation',
     [author], 1)
]


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

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'PyLaDe', 'PyLaDe Documentation',
     author, 'PyLaDe', 'One line description of project.',
     'Miscellaneous'),
]

# -- Other customization options ---------------------------------------------

add_module_names = False

# recommonmark AutoStructify for markdown to rst
# See: https://github.com/rtfd/recommonmark/blob/master/docs/auto_structify.md
github_docs_root = 'https://github.com/fievelk/pylade/'
def setup(app):
    app.add_config_value('recommonmark_config', {
            'url_resolver': lambda url: github_docs_root + url,
            'enable_auto_toc_tree': True,
            'auto_toc_tree_section': 'Contents',
            }, True)
    app.add_transform(AutoStructify)
