Make rstgen work with gcsafe (#20534)

* Make rstgen work with gcsafe

Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com>

* add tests and fixes

* if nimHasWarningAsError

Co-authored-by: Danil Yarantsev <tiberiumk12@gmail.com>
This commit is contained in:
ringabout 2022-10-11 00:56:01 +08:00 • committed by GitHub
commit e290b028ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 9 deletions

View file

@ -88,7 +88,7 @@ type
## for hyperlinks. See renderIndexTerm proc for details.
id*: int ## A counter useful for generating IDs.
onTestSnippet*: proc (d: var RstGenerator; filename, cmd: string; status: int;
content: string)
content: string) {.gcsafe.}
escMode*: EscapeMode
curQuotationDepth: int
@ -283,7 +283,7 @@ proc dispA(target: OutputTarget, dest: var string,
proc `or`(x, y: string): string {.inline.} =
result = if x.len == 0: y else: x
proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string)
proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string) {.gcsafe.}
## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration.
##
## Before using this proc you need to initialise a ``RstGenerator`` with
@ -1028,7 +1028,7 @@ proc renderCodeLang*(result: var string, lang: SourceLanguage, code: string,
proc renderNimCode*(result: var string, code: string, target: OutputTarget) =
renderCodeLang(result, langNim, code, target)
proc renderCode(d: PDoc, n: PRstNode, result: var string) =
proc renderCode(d: PDoc, n: PRstNode, result: var string) {.gcsafe.} =
## Renders a code (code block or inline code), appending it to `result`.
##
## If the code block uses the ``number-lines`` option, a table will be
@ -1592,7 +1592,7 @@ $content
proc rstToHtml*(s: string, options: RstParseOptions,
config: StringTableRef,
msgHandler: MsgHandler = rst.defaultMsgHandler): string =
msgHandler: MsgHandler = rst.defaultMsgHandler): string {.gcsafe.} =
## Converts an input rst string into embeddable HTML.
##
## This convenience proc parses any input string using rst markup (it doesn't