sphinx-contrib / napoleon

Other
149 stars 48 forks source link

Custom parameter section name added #10

Open AleksandarPetrov opened 5 years ago

AleksandarPetrov commented 5 years ago

When using

napoleon_use_param = False
napoleon_custom_sections = [('Custom name', 'Parameters')]

The Custom name section will have the formatting of the Parameters section, but the custom name. This follows the way the Example section worked (it already takes the custom name).

This was requested also in this issue: https://github.com/sphinx-contrib/napoleon/issues/2

rknegjens commented 4 years ago

This would be very helpful. Is there a reason it hasn't been merged?

mcrav commented 4 years ago

Can this be merged or a reason given why it's not merged?

McSinyx commented 4 years ago

This is already available in upstream Sphinx, if you're not stuck with <=1.2.

mcrav commented 4 years ago

Thanks for the reply. I'm maybe being silly, but can't see how this is meant to work?

napoleon_custom_sections = [('Section Name', 'Parameters')]

The above in conf.py adds the section with correct formatting but replaces the name with Parameters. The desired behaviour here is that the formatting is used but the custom name remains.

McSinyx commented 4 years ago

I'm sorry, I read the diff and thought this is about something similar to this. I'm not exactly sure how this patch accomplishes that and how we can have this in latest Sphinx.

rknegjens commented 4 years ago

I'm not exactly sure how this patch accomplishes that and how we can have this in latest Sphinx.

In my experience this patch works as advertised.

gyahalom commented 4 years ago

Just to note though that the required use of

napoleon_use_param = False

Breaks proper formatting of type hints

oesteban commented 3 years ago

@mcrav Thanks for the reply. I'm maybe being silly, but can't see how this is meant to work?

napoleon_custom_sections = [('Section Name', 'Parameters')]

The above in conf.py adds the section with correct formatting but replaces the name with Parameters. The desired behaviour here is that the formatting is used but the custom name remains.

With sphinx-4.0 and

napoleon_custom_sections = [('Section Name', 'params_type')]

this works as expected (i.e., instead of parameters, the intended section name is preserved and sphinx renders section name accordingly).

@rknegjens In my experience this patch works as advertised.

Yes, and the feature in Sphinx that @McSinyx linked does too. I'm unclear on whether this is true for Sphinx-3.0, but certainly for +4.0.