-
Notifications
You must be signed in to change notification settings - Fork 0
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
report issue somehow #158
Comments
Please note, I'm on my phone. Your code may already report it now. But I don't think I saw it earlier when I was formatting "partial go code" |
Do you mean printing that formatting with a formatter failed, or the actual formatting error? |
Right now if you are not using debug. You cannot know there was something that wasn't in the right format to be formatted. I would expect something at least like file1.md (unchanged) 13ms Or you display the error log you display with the debug mode with the line and error, but only when an error occurs. Or it could be a sum up. I think that your tool should help to report fenced blocks that contains invalid code. But then you might report things you are not able to handle, so you will get bug report with examples. As I do,it would be better than displaying nothing except in debug mode |
Seems like the best option. |
Is there anything else to do on this issue? I'm unsure and I'm a bit lost in what you implemented vs what I suggested |
I still want to add a log for formatter errors.
After implementing The same thing happened when I tried reporting all errors/missing formatters at the end. The current implementation (with default log level and without --debug) goes something like this: `$PATH1` formatting `$LANGUAGE` block from :`$LINE_START` to :`$LINE_END` using `$FORMATTER`
`$PATH1` finished in `$DURATION`ms
`$PATH2` formatting `$LANGUAGE` block from :`$LINE_START` to :`$LINE_END` using `$FORMATTER`
`$PATH2` formatting `$LANGUAGE` block from :`$LINE_START` to :`$LINE_END` using `$FORMATTER`
`$PATH2` formatting `$LANGUAGE` block from :`$LINE_START` to :`$LINE_END` using `$FORMATTER`
`$PATH2` finished in `$DURATION`ms (unchanged)
`$PATH3` formatting `$LANGUAGE` block from :`$LINE_START` to :`$LINE_END` using `$FORMATTER`
`$FORMATTER_NAME` not found in path
`$PATH3` finished in `$DURATION`ms (unchanged) I am thinking that the formatter error could look something like this
For reference these are the existing ones. Formatter info (debug):
Finished changed (info):
Finished unchanged (info, but dimmed):
Missing binary (warn):
|
I tried playing around with formatter stderr on by default but it was a bit messy since some formatters (looking at you taplo) spam stderr. |
One thing I noticed locally is that mdsf now reports warning about missing formatter:
For example, I don't have But I get this error message 'goimports' not found in path Thus, the message is displayed each time I launch the formatter even on a formatted text whatever.md finished in 1581ms
I would expect to have something like that For example, this file is not formatted
Here there is no need to warn there that goimports was not found. Then when running mdsf again on same file
I would only expect to see a warning when there is NO formatter found for a block
|
I am still not happy with the way warnings/errors are reported. You are right that missing formatters could all be printed after, or omitted unless all are missing. It all kinda depends on the expected user behaviour, but since we are only 2 users (i think? 🤷🏼). If the user is using mdsf without a config I don't really see a need for printing missing formatters since they haven't actually configured anything. Users with configs might want to know that their tool is missing? From a code perspective printing before is a lot easier since it is sequential and no state is needed. I am thinking about adding support for linters, which would be a lot harder when printing after, since I would have to hijack stderr of the process instead of just letting it inherit.
It actually did that before if you had
(This might be completely unrelated to what you meant, I just got on a roll 😁) The way the formatter config works (or atleast should 😅) is that a single level list tries to format using all tools {
"go": ["goimports", "gofumpt", "gofmt"]
} which would translate to flowchart TB
goimports["format using goimports"]
--> gofumpt["format using gofumpts"]
--> gofmt["format using gofmt"]
--> exit
Whereas nested list are used for fallbacks {
"go": [["goimports", "gofumpt", "gofmt"]]
} flowchart TB
goimports["format using goimports"]
gofumpt["format using gofumpts"]
gofmt["format using gofmt"]
exit["exit"]
goimports --> success1["success?"]
success1 -- true --- exit
success1 -- false --- gofumpt
gofumpt --> success2["success?"]
success2 -- true --- exit
success2 -- false --- gofmt
gofmt --> exit
The reason behind this architecture is rooted in python, where you might have a tool for sorting your imports (isort, usort) and a different for formatting (black, yapf, etc). A "common" config could look something like this {
"python": [
["usort", "isort"],
["black", "yapf"]
]
} Which would mean flowchart TB
usort
isort
black
yapf
exit
usort --> success1["success?"]
success1 -- true --- black
success1 -- false --- isort
isort --> success2["success?"]
success2 -- true --- black
success2 -- false --- black
black --> success3["success?"]
success3 -- true --- exit
success3 -- false --- yapf
yapf --> exit
Missing formatters should most likely be merged/omitted for nested blocks if atleast one succeeds, but flat lists should warn. |
Your code is a markdown code snippet formatter. That's the project purpose OK.
Your code is formatting block that could be invalid.
So your code is somehow also a linter, as you are able to know when you are facing an error when formatting a code block.
In debug mode I can see the code that are invalid (or with an strafe, I'm unsure)
What about reporting something like a warning aside file names to say you face x errors when processing a file.
The text was updated successfully, but these errors were encountered: