diff --git a/port/linux/package/pikascript/TemplateDevice.pyi b/port/linux/package/pikascript/TemplateDevice.pyi index 538b08d12..06d16c3fc 100644 --- a/port/linux/package/pikascript/TemplateDevice.pyi +++ b/port/linux/package/pikascript/TemplateDevice.pyi @@ -69,3 +69,9 @@ class CAN(PikaStdDevice.CAN): def __del__(self): ... + + +""" +def test_doc_string_pyi(): + pass +""" diff --git a/src/PikaObj.c b/src/PikaObj.c index d3eae4d75..2255ab6e3 100644 --- a/src/PikaObj.c +++ b/src/PikaObj.c @@ -3011,7 +3011,8 @@ Arg* __eventListener_runEvent(PikaEventListener* listener, pika_debug("event handler: %p", handler); if (NULL == handler) { pika_platform_printf( - "Error: can not find event handler by id: [0x%02" PRIxPTR "]\r\n", eventId); + "Error: can not find event handler by id: [0x%02" PRIxPTR "]\r\n", + eventId); return NULL; } Arg* eventCallBack = obj_getArg(handler, "eventCallBack"); diff --git a/src/PikaVersion.h b/src/PikaVersion.h index 7ab05e919..98a81a3cc 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -2,4 +2,4 @@ #define PIKA_VERSION_MINOR 13 #define PIKA_VERSION_MICRO 4 -#define PIKA_EDIT_TIME "2024/08/11 01:43:35" +#define PIKA_EDIT_TIME "2024/10/12 16:14:35" diff --git a/tools/pikaCompiler/src/compiler.rs b/tools/pikaCompiler/src/compiler.rs index 465b6ae48..57f2b467e 100644 --- a/tools/pikaCompiler/src/compiler.rs +++ b/tools/pikaCompiler/src/compiler.rs @@ -435,10 +435,29 @@ impl Compiler { let lines: Vec<&str> = file_str.split('\n').collect(); let mut last_line = String::from(""); /* analyse each line */ + let mut inside_docstring = false; for line in lines.iter() { let mut line = line.replace("\r", ""); - /* replace \t with 4 spaces */ line = line.replace("\t", " "); + + // Check for docstring blocks (both single-line and multi-line) + if line.trim().contains("\"\"\"") { + let count = line.matches("\"\"\"").count(); + if count == 1 { + // If we encounter just one set of """ and we are not inside a docstring block, start or end the block + inside_docstring = !inside_docstring; + continue; + } else if count == 2 { + // If there are two sets of """ on the same line, it's a single-line docstring, skip it + continue; + } + } + + // Skip lines inside the docstring block + if inside_docstring { + continue; + } + if line.contains("(") && !line.contains(")") { last_line = line.clone(); continue; @@ -452,6 +471,7 @@ impl Compiler { continue; } } + self = match pkg_type { PackageType::CPackageTop | PackageType::CPackageInner => { Compiler::analyse_pyi_line(self, line.to_string(), &file_name, is_top_c_pkg) @@ -461,6 +481,7 @@ impl Compiler { } }; } + return self; }