Skip to content

Commit

Permalink
fix docstring for .pyi
Browse files Browse the repository at this point in the history
  • Loading branch information
pikasTech committed Oct 12, 2024
1 parent e577386 commit 2c3dd12
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions port/linux/package/pikascript/TemplateDevice.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ class CAN(PikaStdDevice.CAN):


def __del__(self): ...


"""
def test_doc_string_pyi():
pass
"""
3 changes: 2 additions & 1 deletion src/PikaObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/PikaVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 22 additions & 1 deletion tools/pikaCompiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -461,6 +481,7 @@ impl Compiler {
}
};
}

return self;
}

Expand Down

0 comments on commit 2c3dd12

Please sign in to comment.