Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinx-build command line parsing broken on Sphinx 8.1 #912

Closed
alcarney opened this issue Oct 13, 2024 · 2 comments · Fixed by #913
Closed

sphinx-build command line parsing broken on Sphinx 8.1 #912

alcarney opened this issue Oct 13, 2024 · 2 comments · Fixed by #913
Labels
bug Something isn't working lsp Issues that relate to the language server
Milestone

Comments

@alcarney
Copy link
Member

alcarney commented Oct 13, 2024

Expected behavior

Esbonio's sphinx agent be able to parse a sphinx-build command correctly

Actual behavior

Esbonio rasies a cryptic error message when trying to launch a Sphinx process.

I'm still investigating but it appears that the latest release of Sphinx has broken the way esbonio tries to re-use Sphinx's command line parser.

Log output

[esbonio.SphinxManager] Unable to start SphinxClient: 'srcdir'
Traceback (most recent call last):
  File "/var/home/alex/Projects/swyddfa/esbonio/develop/.vscode/extensions/esbonio/bundled/libs/esbonio/server/features/sphinx_manager/client_subprocess.py", line 220, in start
    self.sphinx_info = await self.protocol.send_request_async(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pygls.exceptions.JsonRpcInternalError: 'srcdir'

(Optional) Settings from conf.py

No response

@alcarney alcarney added bug Something isn't working triage Issues needing triage lsp Issues that relate to the language server and removed triage Issues needing triage labels Oct 13, 2024
@alcarney alcarney added this to the 1.0 milestone Oct 13, 2024
@alcarney alcarney added this to Esbonio Oct 13, 2024
@github-project-automation github-project-automation bot moved this to Todo in Esbonio Oct 13, 2024
@alcarney
Copy link
Member Author

alcarney commented Oct 13, 2024

The relevant code:

        if args[0] == "sphinx-build":
            args = args[1:]

        # The easiest way to handle this is to just call sphinx-build but with
        # the Sphinx app object patched out - then we just use all the args it
        # was given!
        with mock.patch("sphinx.cmd.build.Sphinx") as m_Sphinx:
            sphinx_build(args)

        if m_Sphinx.call_args is None:
            return None

        signature = inspect.signature(Sphinx)
        keys = signature.parameters.keys()

        values = m_Sphinx.call_args[0]
        sphinx_args = {k: v for k, v in zip(keys, values)}

        if sphinx_args is None:
            return None

        # `sphinx_args` at this point is an empty dictionary!
        return cls(
            src_dir=sphinx_args["srcdir"],
            conf_dir=sphinx_args["confdir"],
            build_dir=sphinx_args["outdir"],
            builder_name=sphinx_args["buildername"],
            doctree_dir=sphinx_args["doctreedir"],
            config_overrides=sphinx_args.get("confoverrides", {}),
            force_full_build=sphinx_args.get("freshenv", False),
            keep_going=sphinx_args.get("keep_going", False),
            num_jobs=sphinx_args.get("parallel", 1),
            quiet=sphinx_args.get("status", 1) is None,
            silent=sphinx_args.get("warning", 1) is None,
            tags=sphinx_args.get("tags", []),
            verbosity=sphinx_args.get("verbosity", 0),
            warning_is_error=sphinx_args.get("warningiserror", False),
        )

@alcarney
Copy link
Member Author

alcarney commented Oct 13, 2024

Sphinx switched from passing arguments positionally to using keywords, which changes the shape of the m_Sphinx.call_args object
sphinx-doc/sphinx@fadb6b1#diff-4aea2ac365ab5325b530ac42efc67feac98db110e7f943ea13b5cf88f4260e59R334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lsp Issues that relate to the language server
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant