jbms / sphinx-immaterial

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

`sphinx_immaterial_custom_admonitions` not applying `classes` by default #352

Closed mhostetter closed 3 months ago

mhostetter commented 3 months ago

Hello, again. Thanks for all the hard work on this great theme!

I made a custom admonition like so. I assumed that "classes": ["collapsible"], would automatically make it collapsible (and collapsed).

sphinx_immaterial_custom_admonitions = [
    {
        "name": "nomenclature",
        "title": "Variable nomenclature",
        "classes": ["collapsible"],
        "icon": "fontawesome/solid/arrow-down-a-z",
        "color": (108, 117, 125),  # --sd-color-secondary
    },
]

However, when I instantiate the admonition like so, I get the following result.

    .. nomenclature::

        - $k$: Symbol index

image

If I explicitly add :collapsible:, then it works.

    .. nomenclature::
        :collapsible:

        - $k$: Symbol index

image

Is this the desired effect? Thanks, as always.

2bndy5 commented 3 months ago

Is this the desired effect?

Yes. The :collapsible: directive option does not have anything to do with CSS classes. If you define a custom CSS classes in the config, then you should also define the style rule(s) in CSS that should be applied. Note: the classes config option is a convenience to augment the default value used by the :class: directive option.

2bndy5 commented 3 months ago

FWIW, I'm not excited by the suggestion that the collapsible should/could be defined at the config level. Implementing such a "feature" might be too brittle to maintain, given the multitude of supported/overridden admonition and version directives.

mhostetter commented 3 months ago

Ok, thanks. I confused directive options and CSS classes. I'll add the directive option to the places I want to use it. Thanks.