Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def manifest_schema(manifest: Manifest) -> Dict[str, Any]:
return manifest.model_json_schema()


def _test_markdown(markdown_input: str):
def _test_raw(input: str, lang: str = ".md"):
vale_bin = shutil.which("vale")
if not vale_bin:
pytest.skip("'vale' binary not found on PATH; skipping test.")
Expand All @@ -304,16 +304,16 @@ def _test_markdown(markdown_input: str):
"--config",
VALE_CONFIG,
"--ext",
".md",
lang,
]
subprocess.run(
vale_cmd,
input=markdown_input,
input=input,
text=True,
check=True,
)


@pytest.fixture
def test_markdown():
return _test_markdown
def test_raw():
return _test_raw
129 changes: 90 additions & 39 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,98 @@
import textwrap


def test_colon_fence_arbitrary(test_markdown):
def test_md_colon_fence_arbitrary(test_raw):
"""Case with starting fence with arbitrary directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{lorem} ipsum
"""
)
),
".md",
)


def test_colon_fence_code(test_markdown):
def test_md_colon_fence_code(test_raw):
"""Case with colon-fenced `code` directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_code_block(test_markdown):
def test_md_colon_fence_code_block(test_raw):
"""Case with colon-fenced `code-block` directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code-block}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_sourcecode(test_markdown):
def test_md_colon_fence_sourcecode(test_raw):
"""Case with colon-fenced `sourcecode` directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{sourcecode}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_terminal(test_markdown):
def test_md_colon_fence_terminal(test_raw):
"""Case with colon-fenced `terminal` directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{terminal}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_toctree(test_markdown):
def test_md_colon_fence_toctree(test_raw):
"""Case with colon-fenced `toctree` directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{toctree}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_parameter_options(test_markdown):
def test_md_colon_fence_parameter_options(test_raw):
"""Case with a colon-fenced literal containing space and a parameter."""

test_markdown(
test_raw(
textwrap.dedent(
"""
::: {code} python
Expand All @@ -97,14 +103,15 @@ def test_colon_fence_parameter_options(test_markdown):
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_serial(test_markdown):
def test_md_colon_fence_serial(test_raw):
"""Case with two colon-fenced literal directives separated by another block."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code}
Expand All @@ -117,29 +124,31 @@ def test_colon_fence_serial(test_markdown):
ipsum
:::
"""
)
),
".md",
)


def test_colon_fence_final_spaces(test_markdown):
def test_md_colon_fence_final_spaces(test_raw):
"""Case with a colon-fenced literal directive with spaces after the closing
fence."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code}
lorem
:::
"""
)
),
".md",
)


def test_colon_fence_special_chars(test_markdown):
def test_md_colon_fence_special_chars(test_raw):
"""Case with a colon-fenced literal containing all special characters."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code}
Expand Down Expand Up @@ -177,14 +186,15 @@ def test_colon_fence_special_chars(test_markdown):
?
:::
"""
)
),
".md",
)


def test_colon_fence_colons(test_markdown):
def test_md_colon_fence_colons(test_raw):
"""Case with a colon-fenced literal directive containing unescaped colons."""

test_markdown(
test_raw(
textwrap.dedent(
"""
:::{code}
Expand All @@ -197,31 +207,33 @@ def test_colon_fence_colons(test_markdown):

:::
"""
)
),
".md",
)


def test_colon_fence_multiple(test_markdown):
def test_md_colon_fence_multiple(test_raw):
"""Case with a literal directive fenced with more than three colons."""

test_markdown(
test_raw(
textwrap.dedent(
"""
::::{code}
lorem
::::
"""
)
),
".md",
)


def test_colon_fence_nested(test_markdown):
def test_md_colon_fence_nested(test_raw):
"""Case with a colon-fenced non-literal directive containing:

- A child that is a colon-fenced literal directive.
- A child that is a colon-fenced non-literal directive."""

test_markdown(
test_raw(
textwrap.dedent(
"""
::::{admonition} Level 1
Expand All @@ -236,5 +248,44 @@ def test_colon_fence_nested(test_markdown):

::::
"""
)
),
".md",
)


def test_md_role_intersphinx_links(test_raw):
Comment thread
medubelko marked this conversation as resolved.
"""Case with links to Intersphinx project:

- An external Intersphinx ref.
- An external Intersphinx doc."""

test_raw(
textwrap.dedent(
"""
{external:ref}`test`
{external:py:class}`test`
{external+launchpad:ref}`test`
{external+launchpad:doc}`test`
"""
),
".md",
)


def test_rst_role_intersphinx_links(test_raw):
Comment thread
medubelko marked this conversation as resolved.
"""Case with links to Intersphinx project:

- An external Intersphinx ref.
- An external Intersphinx doc."""

test_raw(
textwrap.dedent(
"""
:external:ref:`test`
:external:py:class:`test`
:external+launchpad:ref:`test`
:external+launchpad:doc:`test`
"""
),
".rst",
)
4 changes: 3 additions & 1 deletion vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ BasedOnStyles = Canonical

# Ignore custom spelling role
TokenIgnores = ({(vale-ignore|woke-ignore)}`.+?`)
# Ignore technical roles
TokenIgnores = (\{external[\w+:]+?\}`.+?`)

# Ignore opening colon-fenced (:::) lines and colon-fenced literal directives
# The listed directives must be in sync with the [*.rst] `BlockIgnores`
Expand All @@ -53,7 +55,7 @@ BasedOnStyles = Canonical
TokenIgnores = (:(vale-ignore|woke-ignore):`.+?`)
# Ignore technical roles
TokenIgnores = (:relatedlinks:)
TokenIgnores = (:(command|envvar|file|kbd|literal|literalref|math|option|program|regexp|samp|token)?:`.+?`)
TokenIgnores = (:(command|envvar|file|kbd|literal|literalref|math|option|program|regexp|samp|token|external[\w+:]+?):`.+?`)
# Ignore directives
TokenIgnores = (.. \w+::)
# Ignore options
Expand Down