from sys import platform
from pathlib import Path
from clang.cindex import Config

# -- Project information -----------------------------------------------------
project = 'zenoh-pico'
copyright = '2017, 2022 ZettaScale Technology Inc'
author = 'ZettaScale Zenoh team'
release = '0.11.0.0'

# -- General configuration ---------------------------------------------------
master_doc = 'index'
extensions = ['sphinx_c_autodoc', 'sphinx_c_autodoc.napoleon']
language = 'c'
c_autodoc_roots = ['../include/zenoh-pico/api/']

# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'

breathe_debug_trace_directives = True

if platform == "darwin":
    LIBCLANG_FILE = Path("/Library/Developer/CommandLineTools/usr/lib/libclang.dylib")
    LIBCLANG_CELLAR = Path("/usr/local/Cellar/llvm/14.0.6/lib/libclang.dylib")
    if LIBCLANG_FILE.is_file():
        Config.set_library_file(LIBCLANG_FILE)
    elif LIBCLANG_CELLAR.is_file():
        Config.set_library_file(LIBCLANG_CELLAR)
    else:
        raise ValueError(f"libclang not found. \nTried: \n {LIBCLANG_FILE}\n {LIBCLANG_CELLAR}")

elif platform == "win32":
    raise ValueError("Windows not supported yet for building docs.")

else:
    Config.set_library_file('/usr/lib/llvm-14/lib/libclang.so.1') # Required for readthedocs
