From 8edbcafb27cd56fe271c9a9accc9304bf9637ba7 Mon Sep 17 00:00:00 2001 From: zoldalma <46655437+zoldalma999@users.noreply.github.com> Date: Sun, 26 Jan 2025 12:06:39 +0100 Subject: [PATCH] Fix formatting --- buildconfig/stubs/pygame/window.pyi | 6 +++++- docs/reST/ext/documenters.py | 7 ++++++- src_c/doc/window_doc.h | 24 ++++++++++++------------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index 3202702212..c56a642f11 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -292,7 +292,11 @@ class Window: def maximum_size(self, value: Point) -> None: ... @property def position(self) -> tuple[int, int]: - """Get or set the window position in screen coordinates.""" + """Get or set the window position in screen coordinates. + + The position may be a tuple of (x, y) coordiantes or ``WINDOWPOS_CENTERED`` or + ``WINDOWPOS_UNDEFINED``. The origin is the topleft of the main display. + """ @position.setter def position(self, value: Union[int, Point]) -> None: ... diff --git a/docs/reST/ext/documenters.py b/docs/reST/ext/documenters.py index b02a9739f4..a25b2ba95b 100644 --- a/docs/reST/ext/documenters.py +++ b/docs/reST/ext/documenters.py @@ -41,6 +41,11 @@ def build_signatures(object): if arg_string: arg_string = arg_string[2:] + if object.obj["type"] == "property": + arg_string = "" + else: + arg_string = f"({arg_string})" + if ret.count("[") > 2 or ret.count(",") > 3: ret = ret.split("[")[0] if ret in ("Optional", "Union"): @@ -49,7 +54,7 @@ def build_signatures(object): # Shorten "pygame.module.X" types to "X" ret = re.sub(r"pygame(.[a-zA-Z0-9_]+)+", lambda x: x.group(1)[1:], ret) - yield f"| :sg:`{name}({arg_string}) -> {ret}`" + yield f"| :sg:`{name}{arg_string} -> {ret}`" def get_doc(env, obj): diff --git a/src_c/doc/window_doc.h b/src_c/doc/window_doc.h index 665780a618..6495da670e 100644 --- a/src_c/doc/window_doc.h +++ b/src_c/doc/window_doc.h @@ -1,23 +1,23 @@ /* Auto generated file: with make_docs.py . Docs go in docs/reST/ref/ . */ -#define DOC_WINDOW "Window(title='pygame window', size=(640, 480), position=WINDOWPOS_UNDEFINED, **flags) -> Window\nPygame object that represents a window." +#define DOC_WINDOW "Window(title='pygame window', size=(640, 480), position=WINDOWPOS_UNDEFINED, *, fullscreen=..., fullscreen_desktop=..., opengl=..., vulkan=..., hidden=..., borderless=..., resizable=..., minimized=..., maximized=..., mouse_grabbed=..., keyboard_grabbed=..., input_focus=..., mouse_focus=..., allow_high_dpi=..., mouse_capture=..., always_on_top=..., utility=...) -> Window\nPygame object that represents a window." #define DOC_WINDOW_GRABMOUSE "grab_mouse -> bool\nGet or set the window's mouse grab mode." #define DOC_WINDOW_GRABKEYBOARD "grab_keyboard -> bool\nGet or set the window's keyboard grab mode." -#define DOC_WINDOW_MOUSEGRABBED "mouse_grabbed() -> bool\nGet if the mouse cursor is confined to the window (**read-only**)." -#define DOC_WINDOW_KEYBOARDGRABBED "keyboard_grabbed() -> bool\nGet if the keyboard shortcuts are captured by the window (**read-only**)." -#define DOC_WINDOW_FOCUSED "focused() -> bool\nGet if the window is focused (**read-only**)." +#define DOC_WINDOW_MOUSEGRABBED "mouse_grabbed -> bool\nGet if the mouse cursor is confined to the window (**read-only**)." +#define DOC_WINDOW_KEYBOARDGRABBED "keyboard_grabbed -> bool\nGet if the keyboard shortcuts are captured by the window (**read-only**)." +#define DOC_WINDOW_FOCUSED "focused -> bool\nGet if the window is focused (**read-only**)." #define DOC_WINDOW_TITLE "title -> str\nGet or set the window title." #define DOC_WINDOW_RESIZABLE "resizable -> bool\nGet or set whether the window is resizable." #define DOC_WINDOW_BORDERLESS "borderless -> bool\nGets or sets whether the window is borderless." #define DOC_WINDOW_ALWAYSONTOP "always_on_top -> bool\nGet or set whether the window is always on top." -#define DOC_WINDOW_ID "id() -> int\nGet the unique window ID (**read-only**)." -#define DOC_WINDOW_MOUSERECT "mouse_rect() -> Optional[Rect]\nGet or set the mouse confinement rectangle of the window." -#define DOC_WINDOW_SIZE "size() -> tuple[int, int]\nGet or set the window size in pixels." -#define DOC_WINDOW_MINIMUMSIZE "minimum_size() -> tuple[int, int]\nGet or set the minimum size of the window's client area." -#define DOC_WINDOW_MAXIMUMSIZE "maximum_size() -> tuple[int, int]\nGet or set the maximum size of the window's client area." -#define DOC_WINDOW_POSITION "position() -> tuple[int, int]\nGet or set the window position in screen coordinates." +#define DOC_WINDOW_ID "id -> int\nGet the unique window ID (**read-only**)." +#define DOC_WINDOW_MOUSERECT "mouse_rect -> Optional[Rect]\nGet or set the mouse confinement rectangle of the window." +#define DOC_WINDOW_SIZE "size -> tuple[int, int]\nGet or set the window size in pixels." +#define DOC_WINDOW_MINIMUMSIZE "minimum_size -> tuple[int, int]\nGet or set the minimum size of the window's client area." +#define DOC_WINDOW_MAXIMUMSIZE "maximum_size -> tuple[int, int]\nGet or set the maximum size of the window's client area." +#define DOC_WINDOW_POSITION "position -> tuple[int, int]\nGet or set the window position in screen coordinates." #define DOC_WINDOW_OPACITY "opacity -> float\nGet or set the window opacity, between 0.0 (fully transparent) and 1.0 (fully opaque)." -#define DOC_WINDOW_OPENGL "opengl() -> bool\nGet if the window supports OpenGL." -#define DOC_WINDOW_UTILITY "utility() -> bool\nGet if the window is an utility window (**read-only**)." +#define DOC_WINDOW_OPENGL "opengl -> bool\nGet if the window supports OpenGL." +#define DOC_WINDOW_UTILITY "utility -> bool\nGet if the window is an utility window (**read-only**)." #define DOC_WINDOW_FROMDISPLAYMODULE "from_display_module() -> Window\nCreate a Window object using window data from display module." #define DOC_WINDOW_GETSURFACE "get_surface() -> Surface\nGet the window surface." #define DOC_WINDOW_FLIP "flip() -> None\nUpdate the display surface to the window."