further progress on rst roles & directives (fix #17646) (#17659)

* further progress on rst roles & dir-s (fix #17646)

* fix documents according to the messages

* fix bug 17 from #17340
This commit is contained in:
Andrey Makarov
2021-04-08 20:00:14 +03:00
committed by GitHub
parent 4d3f9d3536
commit 42687457b0
12 changed files with 129 additions and 51 deletions

View File

@@ -136,6 +136,25 @@ suite "YAML syntax highlighting":
<span class="StringLit">not numbers</span><span class="Punctuation">:</span> <span class="Punctuation">[</span> <span class="StringLit">42e</span><span class="Punctuation">,</span> <span class="StringLit">0023</span><span class="Punctuation">,</span> <span class="StringLit">+32.37</span><span class="Punctuation">,</span> <span class="StringLit">8 ball</span><span class="Punctuation">]</span>
<span class="Punctuation">}</span></pre>"""
test "Directives: warnings":
let input = dedent"""
.. non-existant-warning: Paragraph.
.. another.wrong:warning::: Paragraph.
"""
var warnings = new seq[string]
let output = input.toHtml(warnings=warnings)
check output == ""
doAssert warnings[].len == 2
check "(1, 24) Warning: RST style:" in warnings[0]
check "double colon :: may be missing at end of 'non-existant-warning'" in warnings[0]
check "(3, 25) Warning: RST style:" in warnings[1]
check "RST style: too many colons for a directive (should be ::)" in warnings[1]
test "not a directive":
let input = "..warning:: I am not a warning."
check input.toHtml == input
test "Anchors, Aliases, Tags":
let input = """.. code-block:: yaml
--- !!map
@@ -1403,6 +1422,23 @@ Test1
check """`3`:sup:\ He is an isotope of helium.""".toHtml == expected
check """`3`:superscript:\ He is an isotope of helium.""".toHtml == expected
test "Roles: warnings":
let input = dedent"""
See function :py:func:`spam`.
See also `egg`:py:class:.
"""
var warnings = new seq[string]
let output = input.toHtml(warnings=warnings)
doAssert warnings[].len == 2
check "(1, 14) Warning: " in warnings[0]
check "language 'py:func' not supported" in warnings[0]
check "(3, 15) Warning: " in warnings[1]
check "language 'py:class' not supported" in warnings[1]
check("""<p>See function <span class="py:func">spam</span>.</p>""" & "\n" &
"""<p>See also <span class="py:class">egg</span>. </p>""" & "\n" ==
output)
test "(not) Roles: check escaping 1":
let expected = """See :subscript:<tt class="docutils literal">""" &
"""<span class="pre">""" & id"some" & " " & id"text" &