sphinx_rtd_theme
sphinx_rtd_theme copied to clipboard
:cpp:expr: is not rendered as monospace
Problem
Exactly what the title says. According to the Sphinx documentation, :cpp:expr:
should render as code, while :cpp:texpr:
should render as normal text.
Reproducible Project
This is the offending code in my docs:
.. cpp:function:: m64::frame& back()
.. cpp:function:: const m64::frame& back() const
Returns a reference to the last frame of this M64.
Equivalent to :cpp:expr:`(*this)[this->size() - 1]` or :cpp:expr:`*(this->end())`.
Error Logs/Results
This is what comes out:
Expected Results
The text marked as :cpp:expr:
should be in monospace font (style class cpp-expr
, for anyone messing with the CSS)
Environment Info
- Python Version: 3.8
- Sphinx Version: 4.0.3
- RTD Theme Version: 0.5.2
I also notice that there is no colouring of keywords. Does the theme derive from the basic
theme in Sphinx or some other theme?
From the Sphinx side, what can we do to better propagate basic CSS changes to the RTD theme?
I managed to do a quick workaround ... add the following to your stylesheet.
.cpp-expr {
background: #fff;
background-clip: initial;
background-color: #fff;
border: 1px solid #e1e4e5;
box-sizing: border-box;
color: #404040;
font-family: SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;
font-size: 75%;
font-weight: 700;
line-height: 24px;
max-width: 100%;
overflow-x: auto;
padding: 2px 5px;
white-space: normal;
}
But someone who knows better can do a proper fix...
https://github.com/sphinx-doc/sphinx/blob/v5.3.0/tests/test_domain_cpp.py#L1313 'span'
to 'code'
?
But someone who knows better can do a proper fix...
I can at least give some pointers, as the CSS "interface" for Sphinx is not really documented. This particular stuff was added/changed in https://github.com/sphinx-doc/sphinx/pull/9023:
- All signature-like elements have the class
sig
. - Declarations, e.g.,
.. py:function::
or.. cpp:function::
further havesig-object
. - Inline elements (of which I think only
:cpp:expr:
/:cpp:texpr:
exists) instead havesig-inline
. - Each signature-like element further have the name of the domain as a class, e.g.,
py
orcpp
.
So, all :cpp:expr:
/:cpp:texpr:
can be selected with .sig-inline.cpp
. If you want all C++ domain objects to be selected, then .sig.cpp
.