add --processing:dots|filenames|off to customize hintProcessing (#17817)
This commit is contained in:
parent
56859fe851
commit
e4a3feeb92
15 changed files with 50 additions and 30 deletions
|
|
@ -343,6 +343,8 @@
|
||||||
|
|
||||||
- Added `--filenames:abs|canonical|magic` which replaces --listFullPaths:on|off
|
- Added `--filenames:abs|canonical|magic` which replaces --listFullPaths:on|off
|
||||||
|
|
||||||
|
- Added `--processing:dots|filenames|off` which customizes `hintProcessing`
|
||||||
|
|
||||||
- Source+Edit links now appear on top of every docgen'd page when
|
- Source+Edit links now appear on top of every docgen'd page when
|
||||||
`nim doc --git.url:url ...` is given.
|
`nim doc --git.url:url ...` is given.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1018,7 +1018,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType;
|
||||||
var flags = 0
|
var flags = 0
|
||||||
if not containsGarbageCollectedRef(typ): flags = flags or 1
|
if not containsGarbageCollectedRef(typ): flags = flags or 1
|
||||||
if not canFormAcycle(typ): flags = flags or 2
|
if not canFormAcycle(typ): flags = flags or 2
|
||||||
#else MessageOut("can contain a cycle: " & typeToString(typ))
|
#else echo("can contain a cycle: " & typeToString(typ))
|
||||||
if flags != 0:
|
if flags != 0:
|
||||||
m.s[cfsTypeInit3].addf("$1.flags = $2;$n", [nameHcr, rope(flags)])
|
m.s[cfsTypeInit3].addf("$1.flags = $2;$n", [nameHcr, rope(flags)])
|
||||||
discard cgsym(m, "TNimType")
|
discard cgsym(m, "TNimType")
|
||||||
|
|
|
||||||
|
|
@ -900,6 +900,16 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
of "canonical": conf.filenameOption = foCanonical
|
of "canonical": conf.filenameOption = foCanonical
|
||||||
of "legacyrelproj": conf.filenameOption = foLegacyRelProj
|
of "legacyrelproj": conf.filenameOption = foLegacyRelProj
|
||||||
else: localError(conf, info, "expected: abs|canonical|legacyRelProj, got: $1" % arg)
|
else: localError(conf, info, "expected: abs|canonical|legacyRelProj, got: $1" % arg)
|
||||||
|
of "processing":
|
||||||
|
incl(conf.notes, hintProcessing)
|
||||||
|
incl(conf.mainPackageNotes, hintProcessing)
|
||||||
|
case arg.normalize
|
||||||
|
of "dots": conf.hintProcessingDots = true
|
||||||
|
of "filenames": conf.hintProcessingDots = false
|
||||||
|
of "off":
|
||||||
|
excl(conf.notes, hintProcessing)
|
||||||
|
excl(conf.mainPackageNotes, hintProcessing)
|
||||||
|
else: localError(conf, info, "expected: dots|filenames|off, got: $1" % arg)
|
||||||
of "listfullpaths":
|
of "listfullpaths":
|
||||||
# xxx in future work, use `warningDeprecated`
|
# xxx in future work, use `warningDeprecated`
|
||||||
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
|
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
|
||||||
|
|
|
||||||
|
|
@ -545,7 +545,7 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
if conf.structuredErrorHook != nil:
|
if conf.structuredErrorHook != nil:
|
||||||
conf.structuredErrorHook(conf, info, s & kindmsg, sev)
|
conf.structuredErrorHook(conf, info, s & kindmsg, sev)
|
||||||
if not ignoreMsgBecauseOfIdeTools(conf, msg):
|
if not ignoreMsgBecauseOfIdeTools(conf, msg):
|
||||||
if msg == hintProcessing:
|
if msg == hintProcessing and conf.hintProcessingDots:
|
||||||
msgWrite(conf, ".")
|
msgWrite(conf, ".")
|
||||||
else:
|
else:
|
||||||
styledMsgWriteln(styleBright, loc, resetStyle, color, title, resetStyle, s, KindColor, kindmsg,
|
styledMsgWriteln(styleBright, loc, resetStyle, color, title, resetStyle, s, KindColor, kindmsg,
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,7 @@ type
|
||||||
implicitCmd*: bool # whether some flag triggered an implicit `command`
|
implicitCmd*: bool # whether some flag triggered an implicit `command`
|
||||||
selectedGC*: TGCMode # the selected GC (+)
|
selectedGC*: TGCMode # the selected GC (+)
|
||||||
exc*: ExceptionSystem
|
exc*: ExceptionSystem
|
||||||
|
hintProcessingDots*: bool # true for dots, false for filenames
|
||||||
verbosity*: int # how verbose the compiler is
|
verbosity*: int # how verbose the compiler is
|
||||||
numberOfProcessors*: int # number of processors
|
numberOfProcessors*: int # number of processors
|
||||||
lastCmdTime*: float # when caas is enabled, we measure each command
|
lastCmdTime*: float # when caas is enabled, we measure each command
|
||||||
|
|
@ -458,20 +459,25 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool
|
||||||
when defined(nimDebugUtils):
|
when defined(nimDebugUtils):
|
||||||
import debugutils
|
import debugutils
|
||||||
|
|
||||||
|
proc initConfigRefCommon(conf: ConfigRef) =
|
||||||
|
conf.selectedGC = gcRefc
|
||||||
|
conf.verbosity = 1
|
||||||
|
conf.hintProcessingDots = true
|
||||||
|
conf.options = DefaultOptions
|
||||||
|
conf.globalOptions = DefaultGlobalOptions
|
||||||
|
conf.filenameOption = foAbs
|
||||||
|
conf.foreignPackageNotes = foreignPackageNotesDefault
|
||||||
|
conf.notes = NotesVerbosity[1]
|
||||||
|
conf.mainPackageNotes = NotesVerbosity[1]
|
||||||
|
|
||||||
proc newConfigRef*(): ConfigRef =
|
proc newConfigRef*(): ConfigRef =
|
||||||
result = ConfigRef(
|
result = ConfigRef(
|
||||||
selectedGC: gcRefc,
|
|
||||||
cCompiler: ccGcc,
|
cCompiler: ccGcc,
|
||||||
verbosity: 1,
|
|
||||||
options: DefaultOptions,
|
|
||||||
globalOptions: DefaultGlobalOptions,
|
|
||||||
macrosToExpand: newStringTable(modeStyleInsensitive),
|
macrosToExpand: newStringTable(modeStyleInsensitive),
|
||||||
arcToExpand: newStringTable(modeStyleInsensitive),
|
arcToExpand: newStringTable(modeStyleInsensitive),
|
||||||
m: initMsgConfig(),
|
m: initMsgConfig(),
|
||||||
filenameOption: foAbs,
|
|
||||||
cppDefines: initHashSet[string](),
|
cppDefines: initHashSet[string](),
|
||||||
headerFile: "", features: {}, legacyFeatures: {}, foreignPackageNotes: foreignPackageNotesDefault,
|
headerFile: "", features: {}, legacyFeatures: {},
|
||||||
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
|
|
||||||
configVars: newStringTable(modeStyleInsensitive),
|
configVars: newStringTable(modeStyleInsensitive),
|
||||||
symbols: newStringTable(modeStyleInsensitive),
|
symbols: newStringTable(modeStyleInsensitive),
|
||||||
packageCache: newPackageCache(),
|
packageCache: newPackageCache(),
|
||||||
|
|
@ -513,6 +519,7 @@ proc newConfigRef*(): ConfigRef =
|
||||||
vmProfileData: newProfileData(),
|
vmProfileData: newProfileData(),
|
||||||
spellSuggestMax: spellSuggestSecretSauce,
|
spellSuggestMax: spellSuggestSecretSauce,
|
||||||
)
|
)
|
||||||
|
initConfigRefCommon(result)
|
||||||
setTargetFromSystem(result.target)
|
setTargetFromSystem(result.target)
|
||||||
# enable colors by default on terminals
|
# enable colors by default on terminals
|
||||||
if terminal.isatty(stderr):
|
if terminal.isatty(stderr):
|
||||||
|
|
@ -522,18 +529,11 @@ proc newConfigRef*(): ConfigRef =
|
||||||
|
|
||||||
proc newPartialConfigRef*(): ConfigRef =
|
proc newPartialConfigRef*(): ConfigRef =
|
||||||
## create a new ConfigRef that is only good enough for error reporting.
|
## create a new ConfigRef that is only good enough for error reporting.
|
||||||
# xxx FACTOR with `newConfigRef`
|
|
||||||
when defined(nimDebugUtils):
|
when defined(nimDebugUtils):
|
||||||
result = getConfigRef()
|
result = getConfigRef()
|
||||||
else:
|
else:
|
||||||
result = ConfigRef(
|
result = ConfigRef()
|
||||||
selectedGC: gcRefc,
|
initConfigRefCommon(result)
|
||||||
verbosity: 1,
|
|
||||||
options: DefaultOptions,
|
|
||||||
globalOptions: DefaultGlobalOptions,
|
|
||||||
filenameOption: foAbs,
|
|
||||||
foreignPackageNotes: foreignPackageNotesDefault,
|
|
||||||
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
|
|
||||||
|
|
||||||
proc cppDefine*(c: ConfigRef; define: string) =
|
proc cppDefine*(c: ConfigRef; define: string) =
|
||||||
c.cppDefines.incl define
|
c.cppDefines.incl define
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ type
|
||||||
config: ConfigRef
|
config: ConfigRef
|
||||||
|
|
||||||
proc verboseOpen(graph: ModuleGraph; s: PSym; idgen: IdGenerator): PPassContext =
|
proc verboseOpen(graph: ModuleGraph; s: PSym; idgen: IdGenerator): PPassContext =
|
||||||
#MessageOut('compiling ' + s.name.s);
|
let conf = graph.config
|
||||||
result = VerboseRef(config: graph.config, idgen: idgen)
|
result = VerboseRef(config: conf, idgen: idgen)
|
||||||
rawMessage(graph.config, hintProcessing, s.name.s)
|
let path = toFilenameOption(conf, s.position.FileIndex, conf.filenameOption)
|
||||||
|
rawMessage(conf, hintProcessing, path)
|
||||||
|
|
||||||
proc verboseProcess(context: PPassContext, n: PNode): PNode =
|
proc verboseProcess(context: PPassContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ Advanced options:
|
||||||
--filenames:abs|canonical|legacyRelProj
|
--filenames:abs|canonical|legacyRelProj
|
||||||
customize how filenames are rendered in compiler messages,
|
customize how filenames are rendered in compiler messages,
|
||||||
defaults to `abs` (absolute)
|
defaults to `abs` (absolute)
|
||||||
|
--processing:dots|filenames|off
|
||||||
|
show files as they're being processed by nim compiler
|
||||||
--declaredLocs:on|off show declaration locations in messages
|
--declaredLocs:on|off show declaration locations in messages
|
||||||
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
|
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
|
||||||
if `num` is not specified (or `auto`), return
|
if `num` is not specified (or `auto`), return
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ switch("path", "$nim/testament/lib") # so we can `import stdtest/foo` in this di
|
||||||
## prevent common user config settings to interfere with testament expectations
|
## prevent common user config settings to interfere with testament expectations
|
||||||
## Indifidual tests can override this if needed to test for these options.
|
## Indifidual tests can override this if needed to test for these options.
|
||||||
switch("colors", "off")
|
switch("colors", "off")
|
||||||
switch("listFullPaths", "off")
|
switch("filenames", "canonical")
|
||||||
switch("excessiveStackTrace", "off")
|
switch("excessiveStackTrace", "off")
|
||||||
|
|
||||||
# we only want to check the marked parts in the tests:
|
# we only want to check the marked parts in the tests:
|
||||||
|
|
|
||||||
2
nimsuggest/config.nims
Normal file
2
nimsuggest/config.nims
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# xxx not sure why this flag isn't needed: switch("processing", "filenames")
|
||||||
|
switch("filenames", "canonical")
|
||||||
|
|
@ -255,7 +255,6 @@ proc runEpcTest(filename: string): int =
|
||||||
options={poStdErrToStdOut, poUsePath,
|
options={poStdErrToStdOut, poUsePath,
|
||||||
poInteractive, poDaemon})
|
poInteractive, poDaemon})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
let inp = p.inputStream
|
|
||||||
var report = ""
|
var report = ""
|
||||||
var socket = newSocket()
|
var socket = newSocket()
|
||||||
try:
|
try:
|
||||||
|
|
@ -315,8 +314,12 @@ proc runTest(filename: string): int =
|
||||||
answer.add '\L'
|
answer.add '\L'
|
||||||
doReport(filename, answer, resp, report)
|
doReport(filename, answer, resp, report)
|
||||||
finally:
|
finally:
|
||||||
|
try:
|
||||||
inp.writeLine("quit")
|
inp.writeLine("quit")
|
||||||
inp.flush()
|
inp.flush()
|
||||||
|
except:
|
||||||
|
# assume it's SIGPIPE, ie, the child already died
|
||||||
|
discard
|
||||||
close(p)
|
close(p)
|
||||||
if report.len > 0:
|
if report.len > 0:
|
||||||
echo "==== STDIN ======================================"
|
echo "==== STDIN ======================================"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ proc main =
|
||||||
discard """
|
discard """
|
||||||
$nimsuggest --tester $file
|
$nimsuggest --tester $file
|
||||||
>chk $1
|
>chk $1
|
||||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk1 [Processing]";;0
|
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/tchk1.nim [Processing]";;0
|
||||||
chk;;skUnknown;;;;Error;;$file;;12;;0;;"identifier expected, but got \'keyword template\'";;0
|
chk;;skUnknown;;;;Error;;$file;;12;;0;;"identifier expected, but got \'keyword template\'";;0
|
||||||
chk;;skUnknown;;;;Error;;$file;;14;;0;;"nestable statement requires indentation";;0
|
chk;;skUnknown;;;;Error;;$file;;14;;0;;"nestable statement requires indentation";;0
|
||||||
chk;;skUnknown;;;;Error;;$file;;12;;0;;"implementation of \'foo\' expected";;0
|
chk;;skUnknown;;;;Error;;$file;;12;;0;;"implementation of \'foo\' expected";;0
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ discard compiles(2 + "hello")
|
||||||
discard """
|
discard """
|
||||||
$nimsuggest --tester $file
|
$nimsuggest --tester $file
|
||||||
>chk $1
|
>chk $1
|
||||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk_compiles [Processing]";;0
|
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/tchk_compiles.nim [Processing]";;0
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ foo()
|
||||||
discard """
|
discard """
|
||||||
$nimsuggest --tester $file
|
$nimsuggest --tester $file
|
||||||
>chk $1
|
>chk $1
|
||||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"ttempl_inst [Processing]";;0
|
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/ttempl_inst.nim [Processing]";;0
|
||||||
chk;;skUnknown;;;;Hint;;$file;;4;;3;;"template/generic instantiation from here";;0
|
chk;;skUnknown;;;;Hint;;$file;;4;;3;;"template/generic instantiation from here";;0
|
||||||
chk;;skUnknown;;;;Warning;;$file;;2;;11;;"foo [User]";;0
|
chk;;skUnknown;;;;Warning;;$file;;2;;11;;"foo [User]";;0
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ proc isSuccess(input: string): bool =
|
||||||
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
||||||
# note: this doesn't handle colors, eg: `\e[1m\e[0m\e[32mHint:`; while we
|
# note: this doesn't handle colors, eg: `\e[1m\e[0m\e[32mHint:`; while we
|
||||||
# could handle colors, there would be other issues such as handling other flags
|
# could handle colors, there would be other issues such as handling other flags
|
||||||
# that may appear in user config (eg: `--listFullPaths`).
|
# that may appear in user config (eg: `--filenames`).
|
||||||
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
|
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
|
||||||
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
|
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
|
||||||
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ else: # don't run twice the same test
|
||||||
of 5: nimcache / htmldocsDirname
|
of 5: nimcache / htmldocsDirname
|
||||||
else: file.parentDir / htmldocsDirname
|
else: file.parentDir / htmldocsDirname
|
||||||
|
|
||||||
var cmd = fmt"{nim} doc --index:on --listFullPaths --hint:successX:on --nimcache:{nimcache} {options[i]} {file}"
|
var cmd = fmt"{nim} doc --index:on --filenames:abs --hint:successX:on --nimcache:{nimcache} {options[i]} {file}"
|
||||||
removeDir(htmldocsDir)
|
removeDir(htmldocsDir)
|
||||||
let (outp, exitCode) = execCmdEx(cmd)
|
let (outp, exitCode) = execCmdEx(cmd)
|
||||||
check exitCode == 0
|
check exitCode == 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue