import importlib import inspect import os import sys from typing import Any from typing import Dict sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('..')) project = 'Pomice' copyright = '2023, cloudwithax' author = 'cloudwithax' release = '2.2' extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.linkcode', 'myst_parser', ] myst_enable_extensions = [ "amsmath", "colon_fence", "deflist", "dollarmath", "fieldlist", "html_admonition", "html_image", "replacements", "smartquotes", "strikethrough", "substitution", "tasklist", ] myst_heading_anchors = 3 templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # We need to include this because discord.py has special tags # they inlcude within their docstrings that dont parse # right within our docs rst_prolog = """ .. |coro| replace:: This function is a |coroutine_link|_. .. |maybecoro| replace:: This function *could be a* |coroutine_link|_. .. |coroutine_link| replace:: *coroutine* .. _coroutine_link: https://docs.python.org/3/library/asyncio-task.html#coroutine """ html_theme = 'furo' html_static_path = ['_static'] html_title = "Pomice" language = "en" html_theme_options: Dict[str, Any] = { "footer_icons": [ { "name": "GitHub", "url": "https://github.com/cloudwithax/pomice", "html": """ """, "class": "", }, ], "source_repository": "https://github.com/cloudwithax/pomice", "source_branch": "main", "source_directory": "docs/", } # Grab lines from source files and embed into the docs # so theres a point of reference def linkcode_resolve(domain, info): # i absolutely MUST add this here or else # the docs will not build. fuck sphinx try: if domain != 'py': return None if not info['module']: return None mod = importlib.import_module(info["module"]) if "." in info["fullname"]: objname, attrname = info["fullname"].split(".") obj = getattr(mod, objname) try: obj = getattr(obj, attrname) except AttributeError: return None else: obj = getattr(mod, info["fullname"]) try: file = inspect.getsourcefile(obj) lines = inspect.getsourcelines(obj) except TypeError: # e.g. object is a typing.Union return None file = os.path.relpath(file, os.path.abspath("..")) start, end = lines[1], lines[1] + len(lines[0]) - 1 return f"https://github.com/cloudwithax/pomice/blob/main/{file}#L{start}-L{end}" except: pass