Skip to content

Commit 2c3dd12

Browse files
committed
fix docstring for .pyi
1 parent e577386 commit 2c3dd12

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

port/linux/package/pikascript/TemplateDevice.pyi

+6
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ class CAN(PikaStdDevice.CAN):
6969

7070

7171
def __del__(self): ...
72+
73+
74+
"""
75+
def test_doc_string_pyi():
76+
pass
77+
"""

src/PikaObj.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,8 @@ Arg* __eventListener_runEvent(PikaEventListener* listener,
30113011
pika_debug("event handler: %p", handler);
30123012
if (NULL == handler) {
30133013
pika_platform_printf(
3014-
"Error: can not find event handler by id: [0x%02" PRIxPTR "]\r\n", eventId);
3014+
"Error: can not find event handler by id: [0x%02" PRIxPTR "]\r\n",
3015+
eventId);
30153016
return NULL;
30163017
}
30173018
Arg* eventCallBack = obj_getArg(handler, "eventCallBack");

src/PikaVersion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#define PIKA_VERSION_MINOR 13
33
#define PIKA_VERSION_MICRO 4
44

5-
#define PIKA_EDIT_TIME "2024/08/11 01:43:35"
5+
#define PIKA_EDIT_TIME "2024/10/12 16:14:35"

tools/pikaCompiler/src/compiler.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,29 @@ impl Compiler {
435435
let lines: Vec<&str> = file_str.split('\n').collect();
436436
let mut last_line = String::from("");
437437
/* analyse each line */
438+
let mut inside_docstring = false;
438439
for line in lines.iter() {
439440
let mut line = line.replace("\r", "");
440-
/* replace \t with 4 spaces */
441441
line = line.replace("\t", " ");
442+
443+
// Check for docstring blocks (both single-line and multi-line)
444+
if line.trim().contains("\"\"\"") {
445+
let count = line.matches("\"\"\"").count();
446+
if count == 1 {
447+
// If we encounter just one set of """ and we are not inside a docstring block, start or end the block
448+
inside_docstring = !inside_docstring;
449+
continue;
450+
} else if count == 2 {
451+
// If there are two sets of """ on the same line, it's a single-line docstring, skip it
452+
continue;
453+
}
454+
}
455+
456+
// Skip lines inside the docstring block
457+
if inside_docstring {
458+
continue;
459+
}
460+
442461
if line.contains("(") && !line.contains(")") {
443462
last_line = line.clone();
444463
continue;
@@ -452,6 +471,7 @@ impl Compiler {
452471
continue;
453472
}
454473
}
474+
455475
self = match pkg_type {
456476
PackageType::CPackageTop | PackageType::CPackageInner => {
457477
Compiler::analyse_pyi_line(self, line.to_string(), &file_name, is_top_c_pkg)
@@ -461,6 +481,7 @@ impl Compiler {
461481
}
462482
};
463483
}
484+
464485
return self;
465486
}
466487

0 commit comments

Comments
 (0)