Add ability for rst parser to continue on errors
This commit is contained in:
parent
5fa7d374c4
commit
926ae2ec64
5 changed files with 58 additions and 11 deletions
|
|
@ -437,6 +437,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
|||
conf.docSeeSrcUrl = arg
|
||||
of "docroot":
|
||||
conf.docRoot = if arg.len == 0: "@default" else: arg
|
||||
of "docignoreparseerrors":
|
||||
conf.docIgnoreParseErrors = true
|
||||
of "mainmodule", "m":
|
||||
discard "allow for backwards compatibility, but don't do anything"
|
||||
of "define", "d":
|
||||
|
|
|
|||
|
|
@ -146,8 +146,13 @@ proc parseRst(text, filename: string,
|
|||
rstOptions: RstParseOptions;
|
||||
conf: ConfigRef): PRstNode =
|
||||
declareClosures()
|
||||
var msgHandler: MsgHandler
|
||||
if conf.docIgnoreParseErrors:
|
||||
msgHandler = rst.noExceptionMsgHandler
|
||||
else:
|
||||
msgHandler = compilerMsgHandler
|
||||
result = rstParse(text, filename, line, column, hasToc, rstOptions,
|
||||
docgenFindFile, compilerMsgHandler)
|
||||
docgenFindFile, msgHandler)
|
||||
|
||||
proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
|
||||
ext: string, dir: RelativeDir; guessTarget: bool): AbsoluteFile =
|
||||
|
|
@ -170,9 +175,14 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
|||
result.module = module
|
||||
result.conf = conf
|
||||
result.cache = cache
|
||||
var msgHandler: MsgHandler
|
||||
if conf.docIgnoreParseErrors:
|
||||
msgHandler = rst.noExceptionMsgHandler
|
||||
else:
|
||||
msgHandler = defaultMsgHandler
|
||||
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
||||
conf.configVars, filename.string, {roSupportRawDirective, roSupportMarkdown},
|
||||
docgenFindFile, compilerMsgHandler)
|
||||
docgenFindFile, msgHandler)
|
||||
|
||||
if conf.configVars.hasKey("doc.googleAnalytics"):
|
||||
result.analytics = """
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ type
|
|||
docSeeSrcUrl*: string # if empty, no seeSrc will be generated. \
|
||||
# The string uses the formatting variables `path` and `line`.
|
||||
docRoot*: string ## see nim --fullhelp for --docRoot
|
||||
docIgnoreParseErrors*: bool ## continue parsing docs if errors occur
|
||||
|
||||
# the used compiler
|
||||
cIncludes*: seq[AbsoluteDir] # directories to search for included files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue