Skip to content

Conversation

@chrisjsewell
Copy link
Member

No description provided.

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Dec 15, 2025

Currently, the major blocker appears to be that this function no longer seems to work properly:

def html_meta_to_nodes(
data: dict[str, Any], document: nodes.document, line: int, reporter: Reporter
) -> list[nodes.pending | nodes.system_message]:
"""Replicate the `meta` directive,
by converting a dictionary to a list of pending meta nodes
See:
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#html-metadata
"""
if not data:
return []
output = []
for key, value in data.items():
content = str(value or "")
meta_node = nodes.meta(content)
meta_node.source = document["source"]
meta_node.line = line
meta_node["content"] = content
try:
if not content:
raise ValueError("No content")
for i, key_part in enumerate(key.split()):
if "=" not in key_part and i == 0:
meta_node["name"] = key_part
continue
if "=" not in key_part:
raise ValueError(f"no '=' in {key_part}")
attr_name, attr_val = key_part.split("=", 1)
if not (attr_name and attr_val):
raise ValueError(f"malformed {key_part}")
meta_node[attr_name.lower()] = attr_val
except ValueError as error:
msg = reporter.error(f'Error parsing meta tag attribute "{key}": {error}.')
output.append(msg)
continue
pending = nodes.pending(
Filter,
{"component": "writer", "format": "html", "nodes": [meta_node]},
)
document.note_pending(pending)
output.append(pending)
return output

It leads to:

      File ".../docutils/transforms/components.py", line 50, in apply
        component = self.document.transformer.components[component_type]
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
    KeyError: 'writer'

Not sure what has changed to affect this yet, feedback / help welcome?

@AA-Turner
Copy link

@chrisjsewell Fairly sure this is a Docutils change rather than Sphinx. Notably Docutils doesn't seem to use Filter anywhere and the docstring notes it as unused & marked for removal.

Docutils currently uses the below code to add meta nodes:

https://github.com/docutils/docutils/blob/5d129e11e46967418b884019fc3855529a5d74cf/docutils/docutils/parsers/rst/directives/misc.py#L632-L635

Could you do similar here?

A

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Dec 16, 2025

Fairly sure this is a Docutils change rather than Sphinx

@AA-Turner the only change in dependencies is sphinx 8.2.3 to 9.0.4 (plus the addition of roman-numerals==4.0.0), the docutils version remains the same at 0.21.2 (docutils is stilled pinned <0.22)

is there anything you can think of that would change how docutils is initalised?

@chrisjsewell
Copy link
Member Author

is there anything you can think of that would change how docutils is initalised?

@AA-Turner perhaps it is something to do with sphinx-doc/sphinx#13673

@alexlancaster
Copy link

alexlancaster commented Dec 16, 2025

I noticed in the CI logs above, that the combination of Python 3.14 and Sphinx 9.0.4 does seem to pass on Windows for some reason: https://github.com/executablebooks/MyST-Parser/actions/runs/20259242759/job/58167505565?pr=1076 does this mean there might be some Python version and Sphinx interaction?

@chrisjsewell
Copy link
Member Author

does seem to pass on Windows for some reason

It's not actually passing, if you look in the log, it's an issue in the windows job step, that I've seen before; it doesn't "fail-fast" like Linux and takes the fact that the coverage xml command passes as the whole step passing

@alexlancaster
Copy link

It's not actually passing, if you look in the log, it's an issue in the windows job step, that I've seen before; it doesn't "fail-fast" like Linux and takes the fact that the coverage xml command passes as the whole step passing

Ah, well, makes sense. It did seem unusual that the failure would be platform dependent. So it's back to being a sphinx issue.

@AA-Turner
Copy link

AA-Turner commented Dec 18, 2025

114093cff01562a6a50f8c88b59c7b2fed52a39a is the first bad commit
commit 114093cff01562a6a50f8c88b59c7b2fed52a39a (HEAD, refs/bisect/bad)
Author: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Date:   Thu Jun 19 02:25:59 2025 +0100

    Use ``_parse_str_to_doctree()`` in ``Builder.read_doc()`` (#13676)

 sphinx/builders/__init__.py                        | 52 +++++++++++-----------
 sphinx/util/docutils.py                            | 16 ++++++-
 .../test_directive_object_description.py           |  2 +-
 3 files changed, 43 insertions(+), 27 deletions(-)

@AA-Turner
Copy link

@chrisjsewell I believe the error is fixed with sphinx-doc/sphinx#14194.

However, I would strongly suggest not using Filter anymore here, I think it is the correct long term solution given docutils.nodes.meta is now a first-class node.

A

@chrisjsewell
Copy link
Member Author

@chrisjsewell I believe the error is fixed with sphinx-doc/sphinx#14194.

Thanks! will try it out soon

However, I would strongly suggest not using Filter anymore here, I think it is the correct long term solution given docutils.nodes.meta is now a first-class node.

I didn't actually write this bit of code originally 😅 , so absolutely open to other solutions from you or anyone 👍

A

@chrisjsewell
Copy link
Member Author

@AA-Turner v9.1.0rc1 no longer has the KeyError: 'writer' issue, but still fails to create the initial field_list for font-matter as before, so it looks like a new solution may still be necessary

@AA-Turner
Copy link

What's the new error?

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for sphinx v9 MyST unusable with current Sphinx dev HEAD (future 8.3.0) Test failures with sphinx 8.2.3

4 participants