Cyberslas 84402e755f Fix Python Function List not showing functions
Functions defined at the top of the file or below a class with nothing in between would not show in the Function List.
This changes the function regex to fix this. A small unit test that the old regex won't pass but the new will included.

Close #9844
2021-05-11 23:48:22 +02:00

41 lines
1.0 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==========================================================================\
|
| To learn how to make your own language parser, please check the following
| link:
| https://npp-user-manual.org/docs/function-list/
|
\=========================================================================== -->
<NotepadPlus>
<functionList>
<!-- ====================================================== [ Python ] -->
<parser
displayName="Python"
id ="python_syntax"
commentExpr="(?s:'''.*?''')|(?m-s:#.*?$)"
>
<classRange
mainExpr ="^class\x20\K.*?(?=\n\S|\Z)"
>
<className>
<nameExpr expr="\w+(?=\s*[\(|:])" />
</className>
<function
mainExpr="\sdef\x20\K.+?(?=:)"
>
<functionName>
<funcNameExpr expr=".*" />
</functionName>
</function>
</classRange>
<function
mainExpr="^def\x20\K.+?(?=:)"
>
<functionName>
<nameExpr expr=".*" />
</functionName>
</function>
</parser>
</functionList>
</NotepadPlus>