# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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 re
from datetime import date
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------
year = date.today().year
project = u'NVIDIA Cloud Native Technologies'
copyright = u'2018-%s, NVIDIA Corporation' % year
author = u'NVIDIA Corporation'


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

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
copybutton_prompt_text = "$ "
copybutton_only_copy_prompt_lines = False
extensions = [
    'sphinx.ext.ifconfig',
    'sphinx.ext.extlinks',
    'sphinx_copybutton',
    'sphinx.ext.autosectionlabel',
    'sphinx_tabs.tabs',
    'sphinxcontrib.blockdiag',
    'sphinx.ext.intersphinx',
]
blockdiag_fontpath = '/usr/share/fonts/truetype/Roboto-Regular.ttf'
blockdiag_antialias = True
# http://blockdiag.com/en/blockdiag/examples.html
# color picker: https://www.rapidtables.com/web/color/RGB_Color.html

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
html_additional_pages = {
    "index": "cnt-landing-page.html",
    "contents": "cnt-landing-page.html"
}


# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'contents'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

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

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']

# -- 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 = "sphinx_rtd_theme"
html_show_sourcelink = False

# 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 = {
    'canonical_url': 'https://docs.nvidia.com/datacenter/cloud-native/',
    'collapse_navigation': True,
    'sticky_navigation': True,
    'display_version': False,
    'logo_only': True,
    'navigation_depth': 2,
    'includehidden': True,
    'display_version': False,
    'prev_next_buttons_location': "bottom",
    'style_external_links': False,
}
html_logo = "assets/NVLogo_H_B&W.png"

# Download favicon and set it (the variable `html_favicon`) for this project.
# It must be relative path.
html_favicon = "_static/nvidia.ico"

# 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']
html_css_files = ['css/custom.css']

html_js_files = [
    'js/google-analytics/google-analytics-tracker.js',
    'js/google-analytics/google-analytics-write.js',
    '//assets.adobedtm.com/b92787824f2e0e9b68dc2e993f9bd995339fe417/satelliteLib-7ba51e58dc61bcb0e9311aadd02a0108ab24cc6c.js',
]

# Add timestamp to each page
html_last_updated_fmt = '%Y-%m-%d'

intersphinx_mapping = {
    'dcgm': ('https://docs.nvidia.com/datacenter/dcgm/latest/', None),
}


source_parsers = {
    '.md': 'myst_parser.sphinx_',
}

def setup(app):
    count_unique_visitor_script = os.getenv("ADD_NVIDIA_VISITS_COUNTING_SCRIPT")
    if count_unique_visitor_script:
        app.add_js_file(count_unique_visitor_script)
