-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add rst parse option for continuing after parse error #14280
Conversation
aed8fb5
to
edcad00
Compare
arg: string) {.procvar.} = | ||
let mc = msgkind.whichMsgClass | ||
let a = messages[msgkind] % arg | ||
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import std/miscdollars
and use toLocation
which I've added recently as the single place where location formatting is defined (to allow easy override)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. Should I change the proc above as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somehow I missed that; yes por favor! (or in a different "cleanup" PR depending on whether this is staling or not)
I'm not yet convinced; can something like #14282 work instead? I can move do you have a minimal example where something like #14282 would not be sufficient?
IMO that should just error, but give a nice error with the sufficient context (possible with smthg like #14282 )
likewise |
@timotheecour In nimterop, @genotrance and I would like the ability to include arbitrary C docs and have them render regardless of if they contain errors or not. #14282 is nice, but it would not allow for this feature since it would just error and not include the docs at all, which is annoying at best and sometimes a huge pain. |
so I guess it relates to #13638 and nimterop/nimterop#61.
right now only rst is supported but your use case would add That way, it allows you to check your assumptions about comment format, and if comments are in a different format to begin with, unless we have an easy way to convert to rst, there's no point in trying to format to rst in the 1st place (eg it could give wrong results yet make the parser pass without error) also if you have concrete example file showing those C doc comments that would help this discussion |
@timotheecour that would be ideal. I would love to just remove the rst formatting in the first place. I agree it works better and would be fine with that solution. |
raw is un-interpreted so cannot raise note:instead of a new cmdline flag, one option is a pushable pragma: so that nimterop can simply have this: {.push docfmt:"raw".}
# .. nimterop generated code
{.pop.} and users don't need to have a custom command line invocation to generate docs |
I like that idea too, but have no idea how to implement it. I think for now it's simpler to do the |
the more I think of it the more the pragma makes sense. eg: This really is a module (or scope)-level annotation, not something a user should configure.
i can help if needed. As usual, easiest is to pick something that's similar in the compiler and track the code to see how it's implemented. You need to propagate from a One option is to restrict this feature to be at module scope for now, and then future implementations can relax that. So you could add a member in Beyond the wrapper use case for foreign/C doc comments, this feature could in future be used to allow writing your doc comments in markdown in a given module (via In any case, check with @Araq to make sure this can be accepted. |
I don't like it, usually the documentation is already bad enough, adding an option for having even less quality is a bad idea. What does "Ignore parsing errors" even mean? That effectively adds an unspecified error recovery mechanism to the existing RST parser. |
@Araq what about the option for |
Instead our RST/Markdown parser (yes, for the 100th time, it also does support markdown!) should get support for special syntactic construct where plaintext is inserted. Something like:
Or the same with triple backticks which I cannot write down here because markdown's triple backticks do not nest. |
They do.. increase the number of backticks in the nester block. e.g.
|
TIL... proc Mat*(rows: cint, cols: cint, `type`: cint) {.importcpp:"Mat::Mat(@)".} =
##[```
@overload
@param rows Number of rows in a 2D array.
@param cols Number of columns in a 2D array.
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
```]##
runnableExamples: discard not too bad? @jyapayne WDYT ? EDIT: it may also need to parse and remove the C++ comment markers (
not sure whether this should be handled in stdlib, docgen, or some nimble package though |
Hmm, I'll have to test it out! |
@timotheecour The triple backticks seems to work for now. Closing this |
Fixes: #8615
Adds the ability to specify a compiler flag to ignore rst parsing errors. This comes in handy when generating documentation or when the nim forum needs to render rst to html.