qapi_domain.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. QAPI domain extension.
  3. """
  4. from __future__ import annotations
  5. from typing import (
  6. TYPE_CHECKING,
  7. AbstractSet,
  8. Any,
  9. Dict,
  10. Tuple,
  11. )
  12. from sphinx.domains import Domain, ObjType
  13. from sphinx.util import logging
  14. if TYPE_CHECKING:
  15. from sphinx.application import Sphinx
  16. logger = logging.getLogger(__name__)
  17. class QAPIDomain(Domain):
  18. """QAPI language domain."""
  19. name = "qapi"
  20. label = "QAPI"
  21. object_types: Dict[str, ObjType] = {}
  22. directives = {}
  23. roles = {}
  24. initial_data: Dict[str, Dict[str, Tuple[Any]]] = {}
  25. indices = []
  26. def merge_domaindata(
  27. self, docnames: AbstractSet[str], otherdata: Dict[str, Any]
  28. ) -> None:
  29. pass
  30. def resolve_any_xref(self, *args: Any, **kwargs: Any) -> Any:
  31. # pylint: disable=unused-argument
  32. return []
  33. def setup(app: Sphinx) -> Dict[str, Any]:
  34. app.setup_extension("sphinx.directives")
  35. app.add_domain(QAPIDomain)
  36. return {
  37. "version": "1.0",
  38. "env_version": 1,
  39. "parallel_read_safe": True,
  40. "parallel_write_safe": True,
  41. }