numpy / numpy/numpydoc

How should class variables be documented?

Open
#612 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
355
Forks
181
Avg merge
1d 9h
Merged PRs (30d)
3

Description

I'm currently dealing with the case that I want to document a class variable with numpydoc while hacking on docstub. How would I do that? Concretely

class Foo:
    """Short summary.

    Attributes
    ----------
    my_instance_var : int
    """

    my_class_var = 3

    def __init__(self):
        my_instance_var = 2

Should I add this to the existing "Attributes" section, perhaps typed with typing.ClassVar[int] or int, class variable?

@stefanv suggested that custom sections https://github.com/numpy/numpydoc/issues/202 might be a way to address this as well.

Apologies if I missed an existing discussion or documentation about this; I looked but didn't find one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing numpydoc documentation conventions and the custom-sections discussion in issue 202, then compare them with docstub's handling of the shown class. Document a decided convention for class variables, including whether they belong in Attributes and how their type should be written.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.