rodolphebarbanneau / python-docstring-highlighter

Syntax highlighting for Python Docstring in VSCode.
https://marketplace.visualstudio.com/items?itemName=rodolphebarbanneau.python-docstring-highlighter
MIT License
48 stars 1 forks source link

Some instances where things are improperly highlighted with numpy syntax #8

Open scarere opened 1 week ago

scarere commented 1 week ago

Does not properly recognise the 'See Also' section of the numpy format because the header has a space in it. Also, for instances where a parameter description is multiple lines, if the last line only has a single word, it gets mistaken as an argument. In fact any line with a single word is mistaken as an argument. I propose using indentation to figure out whether something is part of a description or is a argument or return type.

scarere commented 1 week ago

Also forgot to mention that return types that start with a capital letter (eg. Callable, Sequence) are mistaken as sections. Further more if the type has square brackets (eg. Sequence[str]) then it is not highlighted at all

scarere commented 1 week ago

Just noticed another case in which highlighting doesn't work. In numpy docstrings one can have two parameters of the same type on the same line. Eg.

"""
Parameters
---------------
array1, array2 : NDArray
    Two input paramaters of the same type.
"""

It seems the space and the comma throw off docstring highlighter from detecting them as parameters

rodolphebarbanneau commented 20 hours ago

Hello @scarere,

Thank you for your additional feedback. Let me address each point you've raised:

  1. See Also and similar sections: I will implement a new rule to colorize sections where all words are capitalized.

  2. Multi-line descriptions ending with a single word: This remains challenging as we can't determine if it's a paragraph or a new section without multi-line context. The current rule prevents colorization with a final dot (e.g., foo is colorized but foo. isn't).

  3. Callable, Sequence: If a line contains only Callable, there's no way to infer whether it's a type or a section title (except if we add for instance a list of words to check within the regex, but I'm not considering that option for the moment). This is a limitation of the single-line regex approach of TextMate.

  4. Sequence[str]: This will be fixed in the next version.

  5. Parameters of the same type on a single line (NumPy style): Indeed, the current pattern doesn't check for two or more arguments. This will be fixed in the upcoming version.

To summarize, the following enhancements are planned for the next version:

If you notice any other issues, please let me know.

Thank you again for your valuable input and for helping improve this extension.

rodolphebarbanneau commented 16 hours ago

The extension has been updated to version 0.2.4, addressing the issues you reported. The update is now available on the VSCode marketplace.

Feel free to rate the extension on the marketplace to support it if you find it useful.

Thanks again for your feedback.