Skip to content

Conversation

@tetrapod00
Copy link
Contributor

@tetrapod00 tetrapod00 commented Jan 29, 2025

In #10462 we updated our dependency on sphinxcontrib-video, which added the ability to specify alignment for videos in sphinx-contrib/video#40. However, that changed the existing alignment behavior.

In the 4.3 (current stable) branch of the docs, before we bumped the dependency, videos were left-aligned:
firefox_FENvnNFgY0
In the current latest branch, after we updated the dependency, videos are now default left-aligned, but when placed immediately before a section header, appear next to the header rather than above it:
firefox_gNWoq656FW

I believe this is due to some assumptions made by the video plugin. When you set :align: left (see here), div containing the video has the align-left class, and similarly for :align: center becoming align-center, etc.

The theme used by the docs for the plugin does:

.align-left {
  text-align: left;
}

While our theme does:

.rst-content .align-left {
  float: left;
  margin: 0 24px 24px 0;
}

Similarly, our theme does not actually center when using align-center our theme's centering using align-center does not work on the 100% width div used by the video plugin.

Our Sphinx theme is mostly not our own, but is based on the Sphinx RTD theme. We could probably align our version of align-center and align-left with the assumptions made by the plugin, but that may have side effects. We should perhaps investigate this later.

Rejected solution:
Use :align: center. Since this doesn't use float, it doesn't cause a wrapping problem, and it matches the behavior of our 4.3 docs. But it is also still aligned left, while semantically it says "centered".

Proposed solution:
Use the align-default, along with some custom CSS to either left- or center-align, depending on what we think looks better. Currently this PR center-aligns. As best I can tell, this is unused in the Sphinx RTD theme so we can freely set CSS for it without worrying about side effects.

I think it's still worth investigating later if we can use either align-left or align-center instead, but that would likely involve some CSS changes anyway to override what the default Sphinx RTD theme is doing. So it doesn't really save any technical complexity.

Here's what the options look like, with a video placed immediately before a section header. Only the first option uses custom CSS; it is what is implemented in this PR.
msedge_xwe4eLSsAn

(BTW, thanks @markdibarry for catching this while we're still in beta!)

@tetrapod00 tetrapod00 added bug area:manual Issues and PRs related to the Manual/Tutorials section of the documentation area:engine details Issues and PRs related to the Engine Details section of the documentation labels Jan 29, 2025
@tetrapod00 tetrapod00 added this to the 4.4 milestone Jan 29, 2025
@skyace65 skyace65 added the content:website Issues related to adding website features and fixing bugs, whether on the front or back-end label Jan 31, 2025
Copy link
Contributor

@skyace65 skyace65 left a comment

Choose a reason for hiding this comment

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

I built this locally and everything looks good!

* theme does not follow, so we set the `align-default` class instead to avoid
* collisions and have full control of how videos are aligned. */
.align-default {
text-align: center
Copy link
Contributor Author

@tetrapod00 tetrapod00 Jan 31, 2025

Choose a reason for hiding this comment

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

Suggested change
text-align: center
text-align: left

If we would rather keep exact parity with existing behavior, we can do this. I chose to center the videos because:

  1. The original report of this problem on RC implied to me that centering might be the desired behavior (even though in 4.3 our videos were aligned left!)
  2. Images using the .. figure: role are generally aligned center, images using the .. image: role are generally aligned left (implicitly). So there is some precedent for center alignment.
  3. I think it looks better :)

I don't really care all that much one way or another. This is something we should perhaps standardize (for images) at some point, along with guidelines about whether/when to use .. figure: or .. image:.

Copy link
Member

Choose a reason for hiding this comment

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

This broke tables in the class reference (and possibly elsewhere) I think, they're now all centered and it really isn't readable

@mhilbrunner mhilbrunner merged commit 36359b2 into godotengine:master Feb 3, 2025
1 check passed
@mhilbrunner
Copy link
Member

Thanks for doing this!

@tetrapod00
Copy link
Contributor Author

Reverted in #10610.

@tetrapod00 tetrapod00 changed the title Fix video alignment after dependency update Fix video alignment after dependency update (reverted) Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:engine details Issues and PRs related to the Engine Details section of the documentation area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug content:website Issues related to adding website features and fixing bugs, whether on the front or back-end

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants