jbms / sphinx-immaterial

Adaptation of the popular mkdocs-material material design theme to the sphinx documentation system
https://jbms.github.io/sphinx-immaterial/
Other
177 stars 28 forks source link

force all objinfo icons to visually account for text's descender #290

Closed 12rambau closed 10 months ago

12rambau commented 10 months ago

Fix #289

before after
2bndy5 commented 10 months ago

Since the text is customizable (even the font being used is customizable), I think the better solution is to put the colored bg color in a :before pseudo element that won't affect the line height (too much) and encompass the text from descendor to ascendor (arbitrary of the font family used). This way people who enter a lower-case letter in their config don't get an unexpected capitol letter. Probably somewhere in here: https://github.com/jbms/sphinx-immaterial/blob/5756b7fabfde981e27a0cc1a3e9459bc897e9d7b/src/assets/stylesheets/main/_api.scss#L257-L263

2bndy5 commented 10 months ago

This solution assumes that all uppercase letters (in English) have no descendors, but Q actually does. Thus this won't fully resolve the issue: image using

object_description_options = [
    ("py:parameter", dict(toc_icon_class="data", toc_icon_text="Q")),
]

I have found that by changing the span element's display type to inline-table, then we get something more universally desirable.

using config from above:

image

using default config:

image which was done with the following patch:

--- a/src/assets/stylesheets/main/_api.scss
+++ b/src/assets/stylesheets/main/_api.scss
@@ -239,7 +239,7 @@ $objinfo-icon-size: 16px;
 }

 .objinfo-icon {
-  display: inline-block;
+  display: inline-table;
   flex-shrink: 0;
   width: $objinfo-icon-size;
   height: $objinfo-icon-size;
12rambau commented 10 months ago

This solution assumes that all uppercase letters (in English) have no descendors, but Q actually does. Thus this won't fully resolve the issue:

As you see I'm a fool ;-)

I rollback my changes and opt for your solution instead, it works like a charm !