From 6aa4625b7677561c5022262980ce2c9febedb0d5 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Thu, 30 Oct 2025 15:57:17 -0400 Subject: [PATCH] fix: correct module docstring newline escaping Fixed module-level docstring in PyModuleDef where double-backslash newlines (\\n) were appearing as literal "\n" text in help(mcrfpy) output. Changed from escaped newlines (\\n) to actual newlines (\n) so the C compiler interprets them correctly. Before: help(mcrfpy) showed "McRogueFace Python API\\n\\nCore game..." After: help(mcrfpy) shows proper formatting with line breaks The issue was in the PyDoc_STR() macro call - it doesn't interpret escape sequences, so the string literal itself needs to have proper newlines. --- src/McRFPy_API.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/McRFPy_API.cpp b/src/McRFPy_API.cpp index 7ba99ab..ba27675 100644 --- a/src/McRFPy_API.cpp +++ b/src/McRFPy_API.cpp @@ -188,27 +188,27 @@ static PyMethodDef mcrfpyMethods[] = { static PyModuleDef mcrfpyModule = { PyModuleDef_HEAD_INIT, /* m_base - Always initialize this member to PyModuleDef_HEAD_INIT. */ "mcrfpy", /* m_name */ - PyDoc_STR("McRogueFace Python API\\n\\n" - "Core game engine interface for creating roguelike games with Python.\\n\\n" - "This module provides:\\n" - "- Scene management (createScene, setScene, currentScene)\\n" - "- UI components (Frame, Caption, Sprite, Grid)\\n" - "- Entity system for game objects\\n" - "- Audio playback (sound effects and music)\\n" - "- Timer system for scheduled events\\n" - "- Input handling\\n" - "- Performance metrics\\n\\n" - "Example:\\n" - " import mcrfpy\\n" - " \\n" - " # Create a new scene\\n" - " mcrfpy.createScene('game')\\n" - " mcrfpy.setScene('game')\\n" - " \\n" - " # Add UI elements\\n" - " frame = mcrfpy.Frame(10, 10, 200, 100)\\n" - " caption = mcrfpy.Caption('Hello World', 50, 50)\\n" - " mcrfpy.sceneUI().extend([frame, caption])\\n"), + PyDoc_STR("McRogueFace Python API\n\n" + "Core game engine interface for creating roguelike games with Python.\n\n" + "This module provides:\n" + "- Scene management (createScene, setScene, currentScene)\n" + "- UI components (Frame, Caption, Sprite, Grid)\n" + "- Entity system for game objects\n" + "- Audio playback (sound effects and music)\n" + "- Timer system for scheduled events\n" + "- Input handling\n" + "- Performance metrics\n\n" + "Example:\n" + " import mcrfpy\n" + " \n" + " # Create a new scene\n" + " mcrfpy.createScene('game')\n" + " mcrfpy.setScene('game')\n" + " \n" + " # Add UI elements\n" + " frame = mcrfpy.Frame(10, 10, 200, 100)\n" + " caption = mcrfpy.Caption('Hello World', 50, 50)\n" + " mcrfpy.sceneUI().extend([frame, caption])\n"), -1, /* m_size - Setting m_size to -1 means that the module does not support sub-interpreters, because it has global state. */ mcrfpyMethods, /* m_methods */ NULL, /* m_slots - An array of slot definitions ... When using single-phase initialization, m_slots must be NULL. */