mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
tidy: Fix rustdoc warnings and add a tidy check for a common URL issue (#33366)
This change fixes all rustdoc errors and also adds a tidy check for a very common rustdoc URL issue. Eventually rustdoc warnings should likely cause the build to fail, but this catches those issues sooner in order to not waste so much developer time. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
f6ae050077
commit
e70507ca40
19 changed files with 107 additions and 36 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
from typing import Iterable, Tuple
|
||||
import unittest
|
||||
|
||||
from . import tidy
|
||||
|
@ -241,6 +242,41 @@ class CheckTidiness(unittest.TestCase):
|
|||
errors = tidy.collect_errors_for_files(iterFile('multiline_string.rs'), [], [tidy.check_rust], print_text=False)
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_raw_url_in_rustdoc(self):
|
||||
def assert_has_a_single_rustdoc_error(errors: Iterable[Tuple[int, str]]):
|
||||
self.assertEqual(tidy.ERROR_RAW_URL_IN_RUSTDOC, next(errors)[1])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
errors = tidy.check_for_raw_urls_in_rustdoc(
|
||||
"file.rs", 3,
|
||||
b"/// https://google.com"
|
||||
)
|
||||
assert_has_a_single_rustdoc_error(errors)
|
||||
|
||||
errors = tidy.check_for_raw_urls_in_rustdoc(
|
||||
"file.rs", 3,
|
||||
b"//! (https://google.com)"
|
||||
)
|
||||
assert_has_a_single_rustdoc_error(errors)
|
||||
|
||||
errors = tidy.check_for_raw_urls_in_rustdoc(
|
||||
"file.rs", 3,
|
||||
b"/// <https://google.com>"
|
||||
)
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
errors = tidy.check_for_raw_urls_in_rustdoc(
|
||||
"file.rs", 3,
|
||||
b"/// [hi]: https://google.com"
|
||||
)
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
errors = tidy.check_for_raw_urls_in_rustdoc(
|
||||
"file.rs", 3,
|
||||
b"/// [hi](https://google.com)"
|
||||
)
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
|
||||
def run_tests():
|
||||
verbosity = 1 if logging.getLogger().level >= logging.WARN else 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue