0

When using autoclass to document a dataclass you get a "Parameters" section after the class docstrings. How can you remove this? Here is a visual of what I'd like to achieve:

enter image description here

Edit: here is the class definition from the example:

class Dense(Module):
  """A linear transformation applied over the last dimension of the input.

  Attributes:
    features: the number of output features.
    use_bias: whether to add a bias to the output (default: True).
    dtype: the dtype of the computation (default: infer from input and params).
    param_dtype: the dtype passed to parameter initializers (default: float32).
    precision: numerical precision of the computation see `jax.lax.Precision`
      for details.
  """
  features: int
  use_bias: bool = True
  dtype: Optional[Dtype] = None
  param_dtype: Dtype = jnp.float32
  precision: PrecisionLike = None
  kernel_init: Callable[[PRNGKey, Shape, Dtype], Array] = default_kernel_init
  bias_init: Callable[[PRNGKey, Shape, Dtype], Array] = zeros
Cristian Garcia
  • 9,630
  • 6
  • 54
  • 75
  • Is sphinx taking that outright from your class docstring? – Bijay Regmi May 27 '22 at 17:09
  • I don't think so, the docstring only has an `Attributes` section. Sphinx seems to take this from either the class annotations or the `__init__` signature. – Cristian Garcia May 27 '22 at 17:14
  • If I put a "Parameters" section in a docstring, I do get "Parameters" in the output, otherwise not (see https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html?highlight=napoleon#docstring-sections). You only have an "Attributes" section. I don't know how to reproduce the problem. – mzjn May 27 '22 at 18:33

1 Answers1

0

I suspect that you have autodoc_typehints = "description" in your Sphinx conf.py. If you remove that, it'll use the default signature setting, which won't show that parameters section. See here

However, if you do want to keep autodoc_typehints = "description" you must use Args: or Parameters: instead of Attributes:. I know this isn't quite right too, but it's a fix.

Nelson Yeung
  • 3,262
  • 3
  • 19
  • 29