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

Add tests for :manpage: inside a title #11705

Merged
merged 11 commits into from
Feb 14, 2024

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Oct 4, 2023

Fix #11673.

By fixing this, I observed a weird behaviour. In order to determine the HTML title of the page, we store a real title node and not just a string. Then, we create a fake document and render it. However, by doing so, the Sphinx transformations are never called on that fake document, but the writer is called! That means that there are some visitor methods that assume that a transformation was called, but this is not the case for those partial documents.

I think we need to rethink about this in order to decouple the interaction. I don't know if there are other methods that could fail because of that.

@AA-Turner
Copy link
Member

Could you open an issue for the title rendering piece?

A

@@ -425,7 +425,7 @@ def render_partial(self, node: Node | None) -> dict[str, str]:
if node is None:
return {'fragment': ''}

doc = new_document('<partial node>')
doc = new_partial_document()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just setting an attribute?

Suggested change
doc = new_partial_document()
doc = new_document('<partial node>')
doc['is_partial'] = True

and then doc.get('is_partial', False) to test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep the old behaviour in case there was someone somewhere who relied on that. Also, it's to remind us that we have possible partial documents somewhere and that we always need to be aware of.

On the other hand, using an attribute may lead false positive where a user would define this specific attribute. When using the source + special name we may avoid these cases (is_partial may be a "simple" attribute name that may be used in some projects).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm averse to introducing new infrastructure around this if it isn't something we want to keep long-term. So I would prefer the attribute approach (keeping the document name the same), we could use _is_partial or some mangled name if we need to.

A

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use _is_partial or some mangled name if we need to.

That's fine by me then! Actually I don't know whether we'll keep it long-term or not since I don't know if we will be able to fix this issue on partial documents.

I'll do the update next week (I'me quite busy these days).

@picnixz picnixz changed the title Allow :manpage: inside a title Add tests for :manpage: inside a title Feb 3, 2024
@picnixz
Copy link
Member Author

picnixz commented Feb 3, 2024

So, color me surprised but #11825 actually fixed this PR. So I'm only adding some tests now to ensure that the behaviour is as expected.

@picnixz picnixz merged commit 0838682 into sphinx-doc:master Feb 14, 2024
22 checks passed
@picnixz picnixz deleted the fix/11673-manpage-in-headings branch February 14, 2024 09:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

heading with :manpage: role results in failed build
2 participants