summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-08-02 23:05:08 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-08-10 13:56:39 -0400
commitbf0494fcc00e816c2972112a1ae2e0580053cbb8 (patch)
treede3c97ca6bfa120d2b2b631610cbd28eca88cc19
parent169cd7e61934a9c852d109d65226b10b332283a0 (diff)
downloadmeson-bf0494fcc00e816c2972112a1ae2e0580053cbb8.tar.gz
hotdoc module: avoid monkeypatch crime by properly subclassing ExternalProgram
-rw-r--r--mesonbuild/modules/hotdoc.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py
index f5916ebe8..a272b683d 100644
--- a/mesonbuild/modules/hotdoc.py
+++ b/mesonbuild/modules/hotdoc.py
@@ -15,8 +15,8 @@ from __future__ import annotations
'''This module provides helper functions for generating documentation using hotdoc'''
-import os
-import subprocess
+import os, subprocess
+import typing as T
from mesonbuild import mesonlib
from mesonbuild import mlog, build
@@ -44,6 +44,11 @@ MIN_HOTDOC_VERSION = '0.8.100'
file_types = (str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex)
+class HotdocExternalProgram(ExternalProgram):
+ def run_hotdoc(self, cmd: T.List[str]) -> int:
+ return subprocess.run(self.get_command() + cmd, stdout=subprocess.DEVNULL).returncode
+
+
class HotdocTargetBuilder:
def __init__(self, name, state, hotdoc, interpreter, kwargs):
@@ -400,17 +405,13 @@ class HotDocModule(ExtensionModule):
def __init__(self, interpreter):
super().__init__(interpreter)
- self.hotdoc = ExternalProgram('hotdoc')
+ self.hotdoc = HotdocExternalProgram('hotdoc')
if not self.hotdoc.found():
raise MesonException('hotdoc executable not found')
version = self.hotdoc.get_version(interpreter)
if not mesonlib.version_compare(version, f'>={MIN_HOTDOC_VERSION}'):
raise MesonException(f'hotdoc {MIN_HOTDOC_VERSION} required but not found.)')
- def run_hotdoc(cmd):
- return subprocess.run(self.hotdoc.get_command() + cmd, stdout=subprocess.DEVNULL).returncode
-
- self.hotdoc.run_hotdoc = run_hotdoc
self.methods.update({
'has_extensions': self.has_extensions,
'generate_doc': self.generate_doc,