Add doctype: RST|Markdown|RstMarkdown pragma (#20252)

* Add `doctype: RST|Markdown|RstMarkdown` pragma

Implements https://github.com/nim-lang/RFCs/issues/68 ,
see also discussion in https://github.com/nim-lang/Nim/issues/17987

The permitted values:
* `markdown`, which is default. It still contains nearly all of
  the RST supported but it is assumed that in time we will give up
  most or all RST features in this mode
* `rst`, without any extensions
* `RstMarkdown` — compatibility with Nim 1.x. It's basically RST
  with those Markdown features enabled that don't conflict with RST.

* Apply suggestions from code review

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Additional fix in spirit of review

* Fix test after #20188

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
This commit is contained in:
Andrey Makarov 2022-08-23 21:49:53 +03:00 • committed by GitHub
commit 14656154ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 158 additions and 4 deletions

View file

@ -36,7 +36,7 @@ proc testNimDoc(prjDir, docsDir: string; switches: NimSwitches; fixup = false) =
if nimBuildIndexSwitches != "":
exec("$1 buildIndex $2" % [nimExe, nimBuildIndexSwitches])
for expected in walkDirRec(prjDir / "expected/"):
for expected in walkDirRec(prjDir / "expected/", checkDir=true):
let produced = expected.replace('\\', '/').replace("/expected/", "/$1/" % [docsDir])
if not fileExists(produced):
echo "FAILURE: files not found: ", produced
@ -79,5 +79,14 @@ let
"$1/$2" % [test2Dir, test2DocsDir]])
testNimDoc(test2Dir, test2DocsDir, test2Switches, fixup)
# Test `nim doc` on file with `{.doctype.}` pragma
let
test3PrjDir = "test_doctype"
test3PrjName = "test_doctype"
test3Dir = baseDir / test3PrjDir
test3DocsDir = "htmldocs"
test3Switches = NimSwitches(doc: @["$1/$2.nim" % [test3Dir, test3PrjName]])
testNimDoc(test3Dir, test3DocsDir, test3Switches, fixup)
if failures > 0:
quit "$# failures occurred; see note in nimdoc/tester.nim regarding -d:nimTestsNimdocFixup" % $failures