Fix autocomplete & hover unit tests#1012
Fix autocomplete & hover unit tests#1012DonJayamanne merged 1 commit intoDonJayamanne:masterfrom robodair:master
Conversation
|
|
||
| export function highlightCode(docstring: string): string { | ||
| // Add blank line | ||
| docstring = EOL + EOL + docstring + EOL + EOL; |
There was a problem hiding this comment.
These EOL should be kept.
Because some blocks are ended with 'blank line' or EOF (end of file), I added two EOL (making a blank line) before and after the docstring to make it easier to match with regex.
To fix the unit tests, I think trim() the docstring at the end of this function makes more sense.
There was a problem hiding this comment.
Perhaps I didn't read through this closely enough before making changes to fix the tests up. My intention was to ensure the docstring was in a known state with exactly a certain amount of whitespace either end. I'll change it to have the two lines and do a trim at the end.
Also I'm curious - what's the circumstance that the docstrings would end with EOF?
There was a problem hiding this comment.
Oh, my wrong expression 😅. It's not EOF, just the end of the docstring.
To elaborate, taking this docstring as an example
>>> fun1()
a
>>> fun2()
b
There are two 'doctest' blocks above.
Assuming that EOL is \n, above code is >>> fun1()\na\n\n>>> fun2()\nb.
It can be split into two parts
>>> fun1()\na\n\n>>> fun2()\nb
Now it's clear why I need to add two \n\n after the docstring
Then I replace them using regexs (from reStructuredText syntax to Markdown syntax).
After the replacements (at the end of the function), those blank lines are not needed anymore.
So you don't need to add a EOL after you trim() it.
|
Some formats were broken by these changes 😥 |
|
Hopefully I've fixed that in #1048 |
No description provided.