Closed lukelbd closed 4 years ago
After some investigation I think this has something to do with how the :parameters:
role is interpreted by the different sphinx versions.
It seems that older versions translate the :parameters:
role into a standard 2-column table (readthedocs default is sphinx 1.8.5) while newer versions translate the :parameters:
items into exactly like :param:
items roles (local version is sphinx 2.2.0). In my conf.py
I had napoleon_use_param
set to False
, i.e. I instructed napoleon to use :parameters:
, which caused this inconsistent behavior.
I now see that the gray section header-style is the default / "correct" behavior, so from now on I'll set napoleon_use_param
to True
. I used to like the smaller font size of the "incorrect" version, but since I now use page stubs for all of my class methods instead of concatenating them onto one page (thanks to a fork of automodapi), the larger font size is no issue.
P.S. Navigating to lib/python3.7/site-packages/sphinx/ext/napoleon/docstring.py
and replacing _parse_parameters_section
with
def _parse_parameters_section(self, section: str) -> List[str]:
fields = self._consume_fields()
if self._config.napoleon_use_param:
string = self._format_docutils_params(fields)
else:
string = self._format_fields(_('Parameters'), fields)
print(self._config.napoleon_use_param, 'section:')
print('\n'.join(string))
return string
confirmed that the napoleon_use_param
setting in conf.py
was indeed being respected.
Docstring
I have a docstring that looks like the following:
Parameters table: local vs. readthedocs
When I run
make html
on my computer, my parameter tables look like this:The corresponding HTML code looks like:
There is a "section header" with a gray background, and the font is normal sized.
When readthedocs builds my documentation, it looks like this:
The HTML code looks like this:
Instead, the parameters and options are in seperate columns and the font is much smaller. Note that with this format, I also have a lot of trouble embedding RST tables in the parameters section, because they do not have scroll bars and they bleed into the margin (see #18).
Examples from other published projects
Also, various other projects that use readthedocs generally look like the first example:
Summary
What could be causing this inconsistency? Which version is "correct"? The second example seems more correct to me (the gray headers look kind of weird), but it if that's the case, various other projects are suffering from the same problem.