Movatterモバイル変換


[0]ホーム

URL:


Navigation

Consolidated Fields

Sphinx can useconsolidated fields with mixed results.

Without

The first example is traditional Sphinx with some extra glitz.

fox.foxy(size,weight,age)

Return the maximum speed for a fox.

Parameters:
  • size – The size of the fox (in meters)
  • weight (float) – The weight of the fox (in stones)
  • age (int) – The age of the fox (in years)
Returns:

  • velocity (float) – The velocity of the fox.

It was autodoc’d from this docstrings:

deffoxy(size,weight,age):"""    Return the maximum speed for a fox.    :parameter size: The size of the fox (in meters)    :parameter weight: The weight of the fox (in stones)    :type weight: float    :parameter age: The age of the fox (in years)    :type age: int    :returns: - **velocity** (`float`) -- The velocity of the fox.    :rtype: `float`    """returnsize/age

With

The second and third examples are consolidated fields. The second uses bulletsand the third indentation.

fox.fox_velocity(size,weight,age)

Return the maximum speed for a fox.

Parameters:
  • size:float

    The size of the fox (in meters)

  • weight:float

    The weight of the fox (in stones)

  • age:int

    The age of the fox (in years)

Returns:
  • velocity:float

    The velocity of the fox.

Personally I like the indented version, it reads well, and also formats well insphinx, except the arguments are not boldface, although the arg types areitalicized.

fox.fox_speed(size,weight,age)

Return the maximum speed for a fox.

Parameters:
  • size –floatThe size of the fox (in meters)
  • weight –floatThe weight of the fox (in stones)
  • age –intThe age of the fox (in years)
Returns:

speedThe speed of the fox.

Which corresponds to these docstrings:

deffox_velocity(size,weight,age):"""    Return the maximum speed for a fox.    :Parameters:    - `size`: The size of the fox (in meters)    - `weight`: The weight of the fox (in stones)    - `age`: The age of the fox (in years)    :Returns:    - `velocity`: The velocity of the fox.    """returnsize/agedeffox_speed(size,weight,age):"""    Return the maximum speed for a fox.    :Parameters:      size        The size of the fox (in meters)      weight : float        The weight of the fox (in stones)      age : int        The age of the fox (in years)    :Returns:      speed : float        The speed of the fox.    """returnsize/age

Table Of Contents

Previous topic

NumPyDoc vs. Sphinx and Google Format

This Page

Quick search

Enter search terms or a module, class or function name.

Navigation

© Copyright 2014, Mark Mikofski. Created usingSphinx 1.2.1.

[8]ページ先頭

©2009-2025 Movatter.jp