-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rst parser respect
:start-after:
and :end-before:
in include
di…
…rective (#12972) * [FEATURE] rst parser respect :start-after: in include Rst parser now respects `:start-after:` and `:end-before:` attributes for `include` directive. * [DOC] include directive parsing proc update * [TEST] Added unit tests for include rst directive in `rst` module
- Loading branch information
1 parent
ae68ff9
commit 9a5aaad
Showing
2 changed files
with
118 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# tests for rst module | ||
|
||
import ../../lib/packages/docutils/rstgen | ||
import ../../lib/packages/docutils/rst | ||
import unittest | ||
import os | ||
|
||
suite "RST include directive": | ||
test "Include whole": | ||
"other.rst".writeFile("**test1**") | ||
let input = ".. include:: other.rst" | ||
assert "<strong>test1</strong>" == rstTohtml(input, {}, defaultConfig()) | ||
removeFile("other.rst") | ||
|
||
test "Include starting from": | ||
"other.rst".writeFile(""" | ||
And this should **NOT** be visible in `docs.html` | ||
OtherStart | ||
*Visible* | ||
""") | ||
|
||
let input = """ | ||
.. include:: other.rst | ||
:start-after: OtherStart | ||
""" | ||
assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig()) | ||
removeFile("other.rst") | ||
|
||
test "Include everything before": | ||
"other.rst".writeFile(""" | ||
*Visible* | ||
OtherEnd | ||
And this should **NOT** be visible in `docs.html` | ||
""") | ||
|
||
let input = """ | ||
.. include:: other.rst | ||
:end-before: OtherEnd | ||
""" | ||
assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig()) | ||
removeFile("other.rst") | ||
|
||
|
||
test "Include everything between": | ||
"other.rst".writeFile(""" | ||
And this should **NOT** be visible in `docs.html` | ||
OtherStart | ||
*Visible* | ||
OtherEnd | ||
And this should **NOT** be visible in `docs.html` | ||
""") | ||
|
||
let input = """ | ||
.. include:: other.rst | ||
:start-after: OtherStart | ||
:end-before: OtherEnd | ||
""" | ||
assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig()) | ||
removeFile("other.rst") | ||
|
||
|
||
test "Ignore premature ending string": | ||
"other.rst".writeFile(""" | ||
OtherEnd | ||
And this should **NOT** be visible in `docs.html` | ||
OtherStart | ||
*Visible* | ||
OtherEnd | ||
And this should **NOT** be visible in `docs.html` | ||
""") | ||
|
||
let input = """ | ||
.. include:: other.rst | ||
:start-after: OtherStart | ||
:end-before: OtherEnd | ||
""" | ||
assert "<em>Visible</em>" == rstTohtml(input, {}, defaultConfig()) | ||
removeFile("other.rst") |