From 9df80d9935aaf25b93d165ee0f1e6ed9f54a87ab Mon Sep 17 00:00:00 2001 From: leake Date: Wed, 12 Nov 2025 08:01:31 -0700 Subject: [PATCH 1/2] The shlex.quote is breaking file paths that have spaces in them, as it adds an extra quote so files look like "'my file with spaces.h'" rather than simply "my file with spaces.h". Removing the shlex lines fixes that issue. --- pybind11_mkdoc/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pybind11_mkdoc/__init__.py b/pybind11_mkdoc/__init__.py index 34e7514..327c30c 100644 --- a/pybind11_mkdoc/__init__.py +++ b/pybind11_mkdoc/__init__.py @@ -35,9 +35,9 @@ def _append_include_dir(args: list, include_dir: str, verbose: bool = True): """ if os.path.isdir(include_dir): - args.append(f"-I{shlex.quote(include_dir)}") + args.append(f"-I{include_dir}") elif verbose: - print(f"Include directoy '{shlex.quote(include_dir)}' does not exist!") + print(f"Include directoy '{include_dir}' does not exist!") def _append_definition(args: list, definition: str, verbose: bool = True): @@ -62,8 +62,8 @@ def _append_definition(args: list, definition: str, verbose: bool = True): try: macro, value = definition.strip().split('=') - macro = shlex.quote(macro.strip()) - value = shlex.quote(value.strip()) if value else '1' + macro = macro.strip() + value = value.strip() if value else '1' args.append(f"-D{macro}={value}") except ValueError as exc: @@ -72,9 +72,9 @@ def _append_definition(args: list, definition: str, verbose: bool = True): if re.search(r'^[A-Za-z_][A-Za-z0-9_]*', definition): args.append(f"-D{definition}") else: - print(f"Failed to parse definition: {shlex.quote(definition)}") + print(f"Failed to parse definition: {definition}") except: - print(f"Failed to parse definition: {shlex.quote(definition)}") + print(f"Failed to parse definition: {definition}") @@ -128,10 +128,10 @@ def main(): _append_definition(mkdoc_args, arg[2:]) else: # append argument as is and hope for the best - mkdoc_args.append(shlex.quote(arg)) + mkdoc_args.append(arg) for header in parsed_args.header: - mkdoc_args.append(shlex.quote(header)) + mkdoc_args.append(header) mkdoc(mkdoc_args, docstring_width, mkdoc_out) From 5149ce32eb3513404288a95abc42cb4d14528042 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 12 Nov 2025 16:25:34 -0500 Subject: [PATCH 2/2] Apply suggestions from code review --- pybind11_mkdoc/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pybind11_mkdoc/__init__.py b/pybind11_mkdoc/__init__.py index 327c30c..4ef6481 100644 --- a/pybind11_mkdoc/__init__.py +++ b/pybind11_mkdoc/__init__.py @@ -37,7 +37,7 @@ def _append_include_dir(args: list, include_dir: str, verbose: bool = True): if os.path.isdir(include_dir): args.append(f"-I{include_dir}") elif verbose: - print(f"Include directoy '{include_dir}' does not exist!") + print(f"Include directory {include_dir!r} does not exist!") def _append_definition(args: list, definition: str, verbose: bool = True): @@ -61,7 +61,7 @@ def _append_definition(args: list, definition: str, verbose: bool = True): """ try: - macro, value = definition.strip().split('=') + macro, _, value = definition.partition('=') macro = macro.strip() value = value.strip() if value else '1'