2

If I take the very simple python file:

def magic_function(parameter1):
    """
    Do magic with parameter1.

    :param parameter1: The first of all paramters
    :type parameter1: nd_array
    """
    return parameter1

I get the type right after the parameter:

enter image description here

If I now use numpy style together with napoleon:

def magic_function(parameter1):
    """
    Do magic with parameter1.

    Parameters
    ==========
    parameter1: nd_array
        The first of all paramters

    """
    return parameter1

I end up with this ugly setup

enter image description here

The issue seems to be that nd_array is not a valid type which for the default sphinx does not seem to be a problem, but for napoleon this seems to matter, as for example type int works perfectly.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
NOhs
  • 2,780
  • 3
  • 25
  • 59
  • What version of Sphinx and Napoleon do you use? If you are using an old version, this problem might be fixed in the latest version. – Maxime Launois Jun 17 '19 at 18:07
  • Sphinx 2.1.1. Which is currently the latest Version on Github. Since Napoleon ships with sphinx, I do not know if there is a separate version of Napoleon. – NOhs Jun 17 '19 at 23:02

1 Answers1

0

I am not sure if the following would work for nd_array, but I assume it should as it works for built-in types (str,list, float, etc.). Here is a small example of what works for me:

def get_case_id_from_file_name(file_name):
    """ Retrieve case ID from file name.

    Parameters
    ----------
    str file_name
        Name of the test file to retrieve the case ID from.

    Returns
    -------
    list
        A list of split file name with case ID in it.
    """
    return file_name.split('_')

Output:

enter image description here

SuperKogito
  • 2,998
  • 3
  • 16
  • 37
  • Yeah, with valid types it works (see also end of question), just not with descriptive types such as `nd_array`. – NOhs Jul 01 '19 at 14:57