-
-
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
Fix docgen snippet numbering #13507
Fix docgen snippet numbering #13507
Conversation
genotrance
commented
Feb 26, 2020
- Fix snippet file name - everything was 101 - also print snippet if error
- Reduce noise in snippet and example compilation
- Reduce specific warnings, hints in koch docs
compiler/docgen.nim
Outdated
@@ -159,6 +159,7 @@ proc getOutFile2(conf: ConfigRef; filename: RelativeFile, | |||
else: | |||
result = getOutFile(conf, filename, ext) | |||
|
|||
var gIdx = 101 |
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.
This introduces global state and I don't understand why it's needed.
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.
Fixed
compiler/docgen.nim
Outdated
rawMessage(conf, hintExecuting, c2) | ||
if execShellCmd(c2) != status: | ||
echo importStmt & content |
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.
No, the compiler doesn't use echo
for error reporting and this PR is about making the compiler less noisy, not moreso.
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.
Idea was to print the snippet code that failed, makes it easier to debug the problematic snippet instead of having to search the snippet numerically in source file.
Removed for now.
tools/kochdocs.nim
Outdated
@@ -5,7 +5,7 @@ import os, strutils, osproc, sets | |||
const | |||
gaCode* = " --doc.googleAnalytics:UA-48159761-1" | |||
# --warning[LockLevel]:off pending #13218 | |||
nimArgs = "--warning[LockLevel]:off --hint[Conf]:off --hint[Path]:off --hint[Processing]:off -d:boot --putenv:nimversion=$#" % system.NimVersion | |||
nimArgs = "--warning[LockLevel]:off --warning[Deprecated]:off --warning[UnusedImport]:off --warning[RedefinitionOfLabel]:off --hint[Conf]:off --hint[Path]:off --hint[Processing]:off --hint[XDeclaredButNotUsed]:off -d:boot --putenv:nimversion=$#" % system.NimVersion |
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.
This line seems to be the only necessary line to accomplish what your PR title says.
compiler/docgen.nim
Outdated
@@ -211,7 +211,8 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef, | |||
writeFile(outp, importStmt & content) | |||
let c = if cmd.startsWith("nim "): os.getAppFilename() & cmd.substr(3) | |||
else: cmd | |||
let c2 = c % quoteShell(outp) | |||
let subst = if "-r" in c: "-r" else: "$1" | |||
let c2 = c.replace(subst, "--verbosity:0 --hints:off " & subst) % quoteShell(outp) |
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.
Why not let c2 = (c & "--verbosity:0 --hints:off") % quoteShell(outp)"
?
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.
Can't put flags after the filename.
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.
Ok, but let subst = if "-r" in c: "-r" else: "$1"
is suspicious. Why does -r
lack the $1
part?
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.
Not all tests are run so -r isn't common. But when it is, these flags have to go before it, hence looking for both.
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.
-r seems fragile, eg would trigger for --rangeChecks:on
a more robust solution would identify the position right before the filename in nim cmd -flag1 -flag2 filename arg
, ideally by reusing same code compiler uses instead of duplicating logic
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.
Open to ideas but like I said, these params have to go before -r. How about " -r "
?
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.
these params have to go before -r
anything between nim binary and filename can go anywhere:
nim c --rangeChecks:on -r main
nim c -r --rangeChecks:on main
nim --rangeChecks:on -r c main
How about " -r "
not robust to things like:
nim c -r -d:mystr:"foo -r bar" main
(there are more such cases, eg --passC, --passL etc)
sure, these may be rare/edge cases, but I think it's just better to reuse (not re-implement) the logic nim compiler itself uses
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.
how about instead adding --verbosity:0 --hints:off
to here:
tools/kochdocs.nim:235:27: commands[i] = nim & " rst2html $# --git.url:$# -o:$# --index:on $#" %
=> see comment below for a better idea
Only freebsd is failing in unrelated test. |
I like the spirit of this PR but not the current implementation.
compiler/main.nim:
here's all the warnings produced:https://gist.github.com/timotheecour/397948fa2017e147e62e1b4044561060 we can do analysis on this eg:
=> see #13550 which addresses at the compiler level some of those irrelevant warnings; IMO it's a better approach, eg it doesn't suppress |
I'm fine if this can be fixed in compiler as well as by fixing the actual warnings, there's too many though. Fact is that nim doc warnings are not really attended to, nim doc isn't run in the main CI so there's too many warnings flooding the logs. Nightlies are already a long process. I can trim this PR to just fixing the snippet numbering. |
#13550 will fix a lot of these; subsequent PRs to fix remaining ones are welcome
out of sight, out of mind; they're much more likely to be attended to if we surface them. Indeed, many tests are only run via
you mean
maybe that one might be ok, I don't care either way for that specific one |
I've cleaned up this PR to just fix the docgen snippet numbering. |