Sphinx: how to change the function signature display format?

Question:

I have a sphinx theme that renders function signatures using italics rather than code.

(my_function(arg1, arg2) rather than my_function(arg1, arg2))

I’d like to change that behavior, but I’m not sure how… Any ideas?

I’m using autodoc so most of my .rst files just look like this rather than explicitly listed functions (if that helps to know).

.. automodule:: my_module
   :members:
   :undoc-members:
   :show-inheritance:

The theme in question is sphinx_material https://bashtage.github.io/sphinx-material/, maybe I should just switch themes, but it’s pretty except for function signatures being italicized rather than rendered as code.

For an example function documentation, see here: https://bashtage.github.io/sphinx-material/pymethod.html?highlight=send_message

Asked By: C. McCracken

||

Answers:

Thanks to Steve and some more searching, I was able to do this:

See here for how to add custom CSS: How to add custom css file to Sphinx?

In my case, what I needed in the custom.css file was

@import 'material_sphinx.css';

.sig.sig-object.py{
    font-feature-settings: "kern";
    font-family: "Roboto Mono", "Courier New", Courier, monospace;
    background: #f8f8f8;
}
Answered By: C. McCracken