Replies: 2 comments 10 replies
-
This sounds good, although I think we should have some way for themes to opt-in to this extension, such that the extension refuses to work if run with an incompatible theme. One way I can think of opt-ing in, is to use sphinx-margin.compatible-themes =
sphinx-book-theme = sphinx-book-theme |
Beta Was this translation helpful? Give feedback.
9 replies
-
Today I re-discovered https://github.com/ulrobix/sphinxcontrib-contentui, which provides something similar: https://sphinxcontrib-contentui.readthedocs.io/en/latest/columns.html |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
In a recent Twitter thread, @astrojuanlu noted that the Sphinx RTD theme might also make good use of the margin content in the Sphinx Book Theme.
This looks like the following
and was inspired by the Tufte CSS theme:
Implementation
There's nothing inherently fancy about the Margin, it is basically just this directive that sub-classes the
Sidebar
directive:https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/__init__.py#L257
and then some light CSS to make it pop-out to the right of the main content, with a reduced size and width:
mostly here: https://github.com/executablebooks/sphinx-book-theme/blob/master/src/scss/_page.scss#L509
and a little bit here: https://github.com/executablebooks/sphinx-book-theme/blob/master/src/scss/_page.scss#L127
Future enhancements
Having a standalone extension might make it easier to extend functionality of the
Margin
directive to allow for things like margin sidenotes, and usage across themes might make it more likely that we uncover edge-case bugs etc.Question
Would it be useful if we spun out the Margin directive into a separate Sphinx extension like
sphinx-margin
? It would come with some pre-determined CSS that would behave something like the following:Sidebar
and then add amargin
class.XXX
amount, then do the following:.margin
,.margin-caption
, ortag_margin
classes will have the following properties:em
- .2If a theme needed to change the behavior, this could be done with theme-specific CSS that takes this extension into account.
That said, I think the big question is whether this could be general enough that it would actually behave consistently across themes. Obviously this would only work for themes that had a significant margin on the right side, though I think this is somewhat common!
Would this be useful?
I am curious if @pradyunsg @astrojuanlu or @ericholscher would find an extension like this useful for re-use across themes, instead of being embedded in the sphinx-book-theme. Moreover, I wonder if you think it is doable or if this is too much CSS shenanigans to get right.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions