simplistix / sybil

Automated testing for the examples in your documentation.
https://sybil.readthedocs.io/en/latest/
Other
74 stars 14 forks source link

Unhelpful error with missing final linefeed #60

Closed hynek closed 12 months ago

hynek commented 1 year ago

This took me a moment to figure out and I feel like the DX could be better.

If you have a file that doesn't have a final line feed like the following:

# Integrations

```{toctree}
:maxdepth: 1

flask
pyramid
custom

And there's no `\n` behind the three backticks, you get an error like this:

sybil.parsers.abstract.lexers.LexingException: Could not match '(?<=\n)\\n' in /Users/hynek/FOSS/svcs/docs/integrations/index.md: E ':maxdepth: 1\n\nflask\npyramid\ncustom\n'



I know enough re to shoot myself into the foot, so I figured it out quite quick, but I think it would be good to have a nicer error message.
cjw296 commented 1 year ago

What kind of error message would work for you here? It's tricky given the flexible nature of the lexing and parsing; the error message says what pattern couldn't be matched, and gives the text it failed to match against already...

hynek commented 1 year ago

Maybe an error message in general and not a traceback? It's kinda difficult to find the necessary info if you don't know what you're looking for.

cjw296 commented 1 year ago

Do you know how I could implement that? I can't think of a sensible way to originate this other than an exception....

cjw296 commented 12 months ago

Okay, don't think I can make the error message better, but I have fixed the bug with lexing fenced code blocks at the end of documents without newlines in https://github.com/simplistix/sybil/commit/a9c7c80422939794fd05045182225193241fb6bc