# 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 sys
import time
sys.path.append(os.path.abspath("./scripts/_ext"))
sys.path.append(os.path.abspath("./"))
# sys.path.insert(0, os.path.abspath('.'))
import gxdocconfig


# -- Project information -----------------------------------------------------

#project = time.strftime('%Y-%m-%d %H:%M:%S')
project = "SOC"
copyright = '解释权归杭州国芯所有'
author = 'NationalChip'

# The full version, including alpha/beta/rc tags
release = 'v1.0'


# -- 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.
#extensions = ['recommonmark', 'sphinx_markdown_tables']
extensions = gxdocconfig.extensions
extensions.extend([])
                    

one_page_one_api = 'yes'
no_build_dir = []
no_numbered_chapter = ['前言']

#html_js_files = [
#            'https://code.jquery.com/jquery-3.6.0.min.js',
#            ]
#html_js_files.append('singlehtml_nav.js')


#extensions = [
#        'breathe',
#        'exhale',
#        'myst_parser',
#        'genmodule',
##        'recommonmark'
#
#]
    
breathe_projects = {
        project : "./doxyoutput/XML",
        }

breathe_default_project = project

exhale_args = {
        "containmentFolder": "./exhalerst",
        "rootFileName":          "index.rst",
        "rootFileTitle":         project + " API",
        "doxygenStripFromPath":  "..",
        # Suggested optional arguments
        "createTreeView":        True,
        # TIP: if using the sphinx-bootstrap-theme, you need
        # "treeViewIsBootstrap": True,
        "exhaleExecutesDoxygen": False,
        #"exhaleDoxygenStdin":    "INPUT = ../include"
        "verboseBuild": False,
        "generateBreatheFileDirectives": False,
        #"rootFileTitle":"rootFileTitle",
        #"afterTitleDescription":"afterTitleDescription",
        #"afterHierarchyDescription":"afterHierarchyDescription",
        #"fullApiSubSectionTitle":"fullApiSubSectionTitle",
        #"afterBodySummary":"afterBodySummary",

        }

#myst_heading_slug_func 当跳转的锚点有问题时需要实现这个函数，接收一个字符串同时 返回一个字符串
myst_heading_anchors = 5 # h1-h5的标题都可以作为锚点
myst_enable_extensions = [
        "amsmath",
        "colon_fence",
        "deflist",
        "dollarmath",
        "html_admonition",
        "html_image",
        "attrs_image",
        #"linkify",
        "replacements",
        "smartquotes",
        "substitution",
        "tasklist",
        ]

# Tell sphinx what the primary language being documented is.
primary_domain = 'c'

# Tell sphinx what the pygments highlight language should be.
highlight_language = 'c'

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

# 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 = 'zh_CN'
language = 'zh'

# 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 = []


# -- 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'
#html_theme = 'piccolo_theme'
html_theme = 'sphinx_rtd_theme'
#html_theme = 'sphinxawesome_theme'
# all theme : https://sphinx-themes.org
# rtd_theme document: https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html
html_theme_options = {
    #'analytics_id': 'G-XXXXXXXXXX',  #  Provided by Google in your dashboard
    #'analytics_anonymize_ip': False,
    #'logo_only': False,
    #'display_version': True,
    #'prev_next_buttons_location': 'bottom',
    #'style_external_links': False,
    #'vcs_pageview_mode': '',
    #'style_nav_header_background': 'white',
    ## Toc options
    #'collapse_navigation': True,
    #'sticky_navigation': True,
    'navigation_depth': -1,
    #'includehidden': True,
    #'titles_only': False
}

# 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']

source_suffix = {
        '.rst': 'restructuredtext',
        '.txt': 'markdown',
        '.md': 'markdown',
        }

master_doc = gxdocconfig.master_doc


latex_engine = 'xelatex'

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
     'fncychap': r'\usepackage[Lenny]{fncychap}',
     'papersize': 'a4paper',
     'classoptions': ',oneside',

    # The font size ('10pt', '11pt' or '12pt').
    #
     'pointsize': '10pt',
     'maxlistdepth': '99',
     'preamble':r'''

        \usepackage{fancyhdr}
        \pagestyle{fancy}
        \usepackage{etoolbox}
        \patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}
        \hypersetup{
            colorlinks=true,
            linkcolor=blue,
            citecolor=blue,
            filecolor=blue,
            urlcolor=blue,
            %%pdfborder={0 0 0}
        }
        \usepackage{longtable}
        \usepackage{etoolbox}
        \AtBeginEnvironment{longtable}{\footnotesize}
        \let\origtabular\longtable
        \let\endorigtabular\endlongtable
        \let\origtabulary\longtable
        \let\endorigtabulary\endlongtable
        \usepackage{caption}
        \usepackage{draftwatermark}
        \SetWatermarkText{Nationalchip} % the Text
        \SetWatermarkLightness{0.9} % the lightness from 0 to 1, default 0.8
        \SetWatermarkScale{1.0} % the scale, default 1.2
        \captionsetup[figure]{name=}
        \captionsetup[table]{name=}
        \usepackage{tocloft}
        \cftsetindents{figure}{1.5em}{3.5em}
        \cftsetindents{table}{1.5em}{3.5em}
        \usepackage{etoolbox}
        \usepackage{xstring}
        \usepackage{minitoc}
        \usepackage{tabulary}
        \usepackage{tabularx}
        \usepackage{chngcntr}
        \usepackage{fourier}
        \AtBeginEnvironment{tabular}{\small}
        \AtBeginEnvironment{tabularx}{\small}
        \AtBeginEnvironment{tabulary}{\small}
        \AtBeginEnvironment{longtable}{\small}
        \AtBeginEnvironment{xltabular}{\small}
        \usepackage{graphicx}
        \usepackage{titling}
        \title{HIMPP V4.0 媒体处理软件}
        \author{文档版本\hspace{4em}04}
        \date{发布日期\hspace{4em}2022-05-29}
        \hypersetup{pdftitle={SOC CHIP TEST}, pdfauthor={gx test}}

        \begin{document}
        \begin{titlepage}
        \centering
        \includegraphics[width=0.4\paperwidth]{fengmian.png}\par\vspace{1cm}
        \vfill
        \raggedright{\scshape\LARGE\thetitle\par}
        %%\vspace{1.5cm}
        \raggedright{\huge\bfseries 开发参考\par}
        \vspace{2cm}
        \raggedright{\large\theauthor\par}
        \raggedright{\large\thedate\par}
        \vspace{4cm}
        \end{titlepage}

     '''

    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# 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, project + '.tex', project + ' manual Documentation',
     'liufei', 'manual', False),
]

