Skip to content

Conversation

JWCook
Copy link
Collaborator

@JWCook JWCook commented Jan 28, 2023

Fixes #42

Here's what I found:

  • The missing pieces of Inliner state are set in docutils.parsers.rst.states.RSTState.inline_text() -> Inliner.parse()
    • Includes Inliner.document, reporter, and language
  • So docutils is assuming that if any role is being processed, then inline_text() has already been called to parse the relevant text.
  • In this case, the role is XRefBadgeRole (used to create a badge with a link), but there is no corresponding text.
  • Typically, that role would have been created by putting {bdg} or {button-ref} in a document and letting sphinx-design parse it. Instead, we've skipped that step and directly made a XRefBadgeRole object.
  • As long as tags wasn't the first line of the document, inline_text() would have already been called by another role or directive's run() method.
  • Somehow, the equivalent path in myst-parser doesn't have the same limitation.

@JWCook JWCook force-pushed the fix-rst-inliner-state branch from c127f4e to 672ed5b Compare January 28, 2023 19:56
@melissawm
Copy link
Owner

This is awesome - thank you!! I tested locally as well, looks like this does fix the problem. Let's give this a go, I will cut a release and if anything unexpected comes up we'll fix later. Cheers!

@melissawm melissawm merged commit bce0090 into melissawm:main Jan 28, 2023
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.

Docs build fails if tag directive is in the first line of file
2 participants