trst.nim 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. discard """
  2. output: '''
  3. [Suite] RST include directive
  4. '''
  5. """
  6. # tests for rst module
  7. import ../../lib/packages/docutils/rstgen
  8. import ../../lib/packages/docutils/rst
  9. import unittest
  10. import os
  11. suite "RST include directive":
  12. test "Include whole":
  13. "other.rst".writeFile("**test1**")
  14. let input = ".. include:: other.rst"
  15. assert "<strong>test1</strong>" == rstTohtml(input, {}, defaultConfig())
  16. removeFile("other.rst")
  17. test "Include starting from":
  18. "other.rst".writeFile("""
  19. And this should **NOT** be visible in `docs.html`
  20. OtherStart
  21. *Visible*
  22. """)
  23. let input = """
  24. .. include:: other.rst
  25. :start-after: OtherStart
  26. """
  27. assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig())
  28. removeFile("other.rst")
  29. test "Include everything before":
  30. "other.rst".writeFile("""
  31. *Visible*
  32. OtherEnd
  33. And this should **NOT** be visible in `docs.html`
  34. """)
  35. let input = """
  36. .. include:: other.rst
  37. :end-before: OtherEnd
  38. """
  39. assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig())
  40. removeFile("other.rst")
  41. test "Include everything between":
  42. "other.rst".writeFile("""
  43. And this should **NOT** be visible in `docs.html`
  44. OtherStart
  45. *Visible*
  46. OtherEnd
  47. And this should **NOT** be visible in `docs.html`
  48. """)
  49. let input = """
  50. .. include:: other.rst
  51. :start-after: OtherStart
  52. :end-before: OtherEnd
  53. """
  54. assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig())
  55. removeFile("other.rst")
  56. test "Ignore premature ending string":
  57. "other.rst".writeFile("""
  58. OtherEnd
  59. And this should **NOT** be visible in `docs.html`
  60. OtherStart
  61. *Visible*
  62. OtherEnd
  63. And this should **NOT** be visible in `docs.html`
  64. """)
  65. let input = """
  66. .. include:: other.rst
  67. :start-after: OtherStart
  68. :end-before: OtherEnd
  69. """
  70. assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig())
  71. removeFile("other.rst")