Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: more machine-readable error messages #1686

Closed
foolip opened this issue Jun 1, 2020 · 3 comments
Closed

Feature request: more machine-readable error messages #1686

foolip opened this issue Jun 1, 2020 · 3 comments

Comments

@foolip
Copy link
Collaborator

foolip commented Jun 1, 2020

Bikeshed has a --line-numbers argument which will sometimes print the line an error was associated with. However, it's documented as hacky:

Hacky support for outputting line numbers on all error messages. Disables output, as this is hacky and might mess up your source.

Feature request: use https://www.gnu.org/prep/standards/html_node/Errors.html or something with a consistent pattern for errors, especially including the source file (#1516 is related)

Given that, and ideally being able to print a line number in more cases, it would be straightforward to create a GitHub Action that would annotate the source where the errors are. Proof of concept:
w3c/webdriver-bidi@ccd32f9#annotation_222823575

@tabatkins
Copy link
Collaborator

I'm not seeing how anything you're suggesting here would address the hackiness - did you intend them to?

It's hacky because, even tho LXML exposes a lineNumber attribute on its elements, that attribute is always None. The documentation claims it should work and offers no caveats, but it never has, so I dunno. Instead, I run a regex over the lines, looking for things that might be start tags and putting a line-number attribute on them. This, obviously, can misfire on things that are start-tag-like but wouldn't be recognized by the parser, like code in <xmp>; this doesn't affect the accuracy of the line numbers, but it can corrupt your output, thus why I turn off output.

@foolip
Copy link
Collaborator Author

foolip commented Jun 1, 2020

I didn't know in what the hackiness consists, so I thought "ideally being able to print a line number in more cases" would cover it. Sounds like it can also be wrong, then :)

@tabatkins
Copy link
Collaborator

Closing this - due to the gradual switchover to my bespoke HTML parser, most error messages now have non-hacky line numbers (and the branch I'm working on right now will add/improve even more).

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

No branches or pull requests

4 participants
@jyasskin @foolip @tabatkins and others