How to mark and highlight types in Python with napoleon / Google Style

114 views
Skip to first unread message

c.b...@posteo.jp

unread,
Mar 11, 2022, 8:54:42 AM3/11/22
to sphinx-users
Hello,

I wonder about if and how types of function/method parameters are
highlighted.

A good example about "highlighting" is the Pandas docu.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.compare.html
Here you see the type and the default value behind the parameter name.

And the Paramters are a list under the method name. I like that.

I am aware that pandas does use numpy style instead of Google/Napoleon.
But I do not like the syntax of numpy-style just its output.

So the question is how I could archive something like this with
napoleon? Does it depend on the theme? I tried alabaster and
sphinx_rtd_theme.

Looking into the source this is extracted from pythons type annotation
and not from the docstring.

I was looking into the google guide and could not find a recommendation
it. There is just one section where also type annotations are used.
https://google.github.io/styleguide/pyguide.html

In my sphinx output the types are not "highlighted". The type annotation
is part of the method name. I also tried "parameter (type): Description"
syntax. In that case "parameter (type)" became the parameter name
itself. No visual separation between name and type.

In which direction I should look?

Kind
Christian
Reply all
Reply to author
Forward
0 new messages