sphinx-d2lang/sphinxcontrib/d2lang/__init__.py

24 lines
502 B
Python
Raw Normal View History

2023-12-11 18:15:49 +01:00
try:
from sphinx.application import Sphinx
except:
pass
2023-12-10 08:08:50 +01:00
2023-12-09 23:11:43 +01:00
from .d2lang import D2langDirective
2023-12-10 08:09:52 +01:00
from typing import Any, Dict, List, Tuple
2023-12-10 21:35:56 +01:00
from shutil import which
2023-12-10 08:42:48 +01:00
2023-12-11 16:11:48 +01:00
__version__ = (0, 0, 1)
2023-12-09 23:11:43 +01:00
def setup(application: Sphinx) -> Dict[str, Any]:
"""
setup extension.
"""
2023-12-10 08:42:48 +01:00
if which('d2'):
application.add_directive('d2lang', D2langDirective)
2023-12-11 16:11:48 +01:00
return {"version": __version__, "parallel_read_safe": True}
2023-12-10 08:42:48 +01:00
else:
2023-12-11 16:11:48 +01:00
print("d2 binary not found in $PATH")
2023-12-10 08:42:48 +01:00
raise