Skip to content

Commit 17262e1

Browse files
gh-87904: Document curses classes
Add docstrings for the curses.window, curses.error, curses.panel.panel and curses.panel.error classes. Document the panel class and its error exception in curses.panel.rst, using the real lowercase panel name.
1 parent 12add38 commit 17262e1

3 files changed

Lines changed: 48 additions & 20 deletions

File tree

Doc/library/curses.panel.rst

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ displayed. Panels can be added, moved up or down in the stack, and removed.
1616
Functions
1717
---------
1818

19+
The module :mod:`!curses.panel` defines the following exception:
20+
21+
22+
.. exception:: error
23+
24+
Exception raised when a curses panel library function returns an error.
25+
26+
1927
The module :mod:`!curses.panel` defines the following functions:
2028

2129

@@ -48,73 +56,75 @@ The module :mod:`!curses.panel` defines the following functions:
4856
Panel objects
4957
-------------
5058

51-
Panel objects, as returned by :func:`new_panel` above, are windows with a
52-
stacking order. There's always a window associated with a panel which determines
53-
the content, while the panel methods are responsible for the window's depth in
54-
the panel stack.
59+
.. class:: panel
60+
61+
Panel objects, as returned by :func:`new_panel` above, are windows with a
62+
stacking order. There's always a window associated with a panel which
63+
determines the content, while the panel methods are responsible for the
64+
window's depth in the panel stack.
5565

56-
Panel objects have the following methods:
66+
Panel objects have the following methods:
5767

5868

59-
.. method:: Panel.above()
69+
.. method:: panel.above()
6070

6171
Returns the panel above the current panel.
6272

6373

64-
.. method:: Panel.below()
74+
.. method:: panel.below()
6575

6676
Returns the panel below the current panel.
6777

6878

69-
.. method:: Panel.bottom()
79+
.. method:: panel.bottom()
7080

7181
Push the panel to the bottom of the stack.
7282

7383

74-
.. method:: Panel.hidden()
84+
.. method:: panel.hidden()
7585

7686
Returns ``True`` if the panel is hidden (not visible), ``False`` otherwise.
7787

7888

79-
.. method:: Panel.hide()
89+
.. method:: panel.hide()
8090

8191
Hide the panel. This does not delete the object, it just makes the window on
8292
screen invisible.
8393

8494

85-
.. method:: Panel.move(y, x)
95+
.. method:: panel.move(y, x)
8696

8797
Move the panel to the screen coordinates ``(y, x)``.
8898

8999

90-
.. method:: Panel.replace(win)
100+
.. method:: panel.replace(win)
91101

92102
Change the window associated with the panel to the window *win*.
93103

94104

95-
.. method:: Panel.set_userptr(obj)
105+
.. method:: panel.set_userptr(obj)
96106

97107
Set the panel's user pointer to *obj*. This is used to associate an arbitrary
98108
piece of data with the panel, and can be any Python object.
99109

100110

101-
.. method:: Panel.show()
111+
.. method:: panel.show()
102112

103113
Display the panel (which might have been hidden), placing it on top of
104114
the panel stack.
105115

106116

107-
.. method:: Panel.top()
117+
.. method:: panel.top()
108118

109119
Push panel to the top of the stack.
110120

111121

112-
.. method:: Panel.userptr()
122+
.. method:: panel.userptr()
113123

114124
Returns the user pointer for the panel. This might be any Python object.
115125

116126

117-
.. method:: Panel.window()
127+
.. method:: panel.window()
118128

119129
Returns the window object associated with the panel.
120130

Modules/_curses_panel.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,13 @@ static PyMethodDef PyCursesPanel_Methods[] = {
672672

673673
/* -------------------------------------------------------*/
674674

675+
PyDoc_STRVAR(PyCursesPanel_Type_doc,
676+
"A curses panel.\n"
677+
"\n"
678+
"Panel objects are returned by new_panel().");
679+
675680
static PyType_Slot PyCursesPanel_Type_slots[] = {
681+
{Py_tp_doc, (void *)PyCursesPanel_Type_doc},
676682
{Py_tp_clear, PyCursesPanel_Clear},
677683
{Py_tp_dealloc, PyCursesPanel_Dealloc},
678684
{Py_tp_traverse, PyCursesPanel_Traverse},
@@ -821,8 +827,10 @@ _curses_panel_exec(PyObject *mod)
821827
}
822828

823829
/* For exception _curses_panel.error */
824-
state->error = PyErr_NewException(
825-
"_curses_panel.error", NULL, NULL);
830+
state->error = PyErr_NewExceptionWithDoc(
831+
"_curses_panel.error",
832+
"Exception raised when a curses panel library function returns an error.",
833+
NULL, NULL);
826834

827835
if (PyModule_AddObjectRef(mod, "error", state->error) < 0) {
828836
return -1;

Modules/_cursesmodule.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,14 @@ static PyGetSetDef PyCursesWindow_getsets[] = {
30953095
{NULL, NULL, NULL, NULL } /* sentinel */
30963096
};
30973097

3098+
PyDoc_STRVAR(PyCursesWindow_Type_doc,
3099+
"A curses window.\n"
3100+
"\n"
3101+
"Window objects are returned by initscr() and newwin(), and by the\n"
3102+
"methods that create subwindows and pads.");
3103+
30983104
static PyType_Slot PyCursesWindow_Type_slots[] = {
3105+
{Py_tp_doc, (void *)PyCursesWindow_Type_doc},
30993106
{Py_tp_methods, PyCursesWindow_methods},
31003107
{Py_tp_getset, PyCursesWindow_getsets},
31013108
{Py_tp_dealloc, PyCursesWindow_dealloc},
@@ -5528,7 +5535,10 @@ cursesmodule_exec(PyObject *module)
55285535
}
55295536

55305537
/* For exception curses.error */
5531-
state->error = PyErr_NewException("_curses.error", NULL, NULL);
5538+
state->error = PyErr_NewExceptionWithDoc(
5539+
"_curses.error",
5540+
"Exception raised when a curses library function returns an error.",
5541+
NULL, NULL);
55325542
if (state->error == NULL) {
55335543
return -1;
55345544
}

0 commit comments

Comments
 (0)