Skip to content

Fix autocomplete & hover unit tests#1012

Merged
DonJayamanne merged 1 commit intoDonJayamanne:masterfrom
robodair:master
Jun 11, 2017
Merged

Fix autocomplete & hover unit tests#1012
DonJayamanne merged 1 commit intoDonJayamanne:masterfrom
robodair:master

Conversation

@robodair
Copy link
Contributor

No description provided.

@DonJayamanne DonJayamanne merged commit 75be488 into DonJayamanne:master Jun 11, 2017

export function highlightCode(docstring: string): string {
// Add blank line
docstring = EOL + EOL + docstring + EOL + EOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

@yzhang-gh yzhang-gh Jun 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yzhang-gh
Copy link
Contributor

Some formats were broken by these changes 😥

@robodair
Copy link
Contributor Author

Hopefully I've fixed that in #1048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants