diff --git a/styles/Canonical/027-non-descriptive-link-text.yml b/styles/Canonical/027-non-descriptive-link-text.yml new file mode 100644 index 0000000..810d0de --- /dev/null +++ b/styles/Canonical/027-non-descriptive-link-text.yml @@ -0,0 +1,16 @@ +# 027 - Flag non-descriptive link text + +# Copilot assisted. + +extends: existence +message: "Use descriptive link text instead of '%s' to improve accessibility." +link: https://docs.ubuntu.com/styleguide/en +scope: raw +nonword: true +ignorecase: true +level: warning +tokens: + - '\[[^\]]*\b(here|these|this|more|link)\b[^\]]*\]\([^\)]+\)' + - '`[^`<]*\b(here|these|this|more|link)\b[^`<]*<[^>]+>`_' + - ':([^\s\n:]+:)*(doc|ref|any|download|reftype|class|func):`[^`]*\b(here|these|this|more|link)\b[^`]*`' + - '\{([^\}\s\n]+:)*(doc|ref|any|download|reftype|class|func)\}`[^`]*\b(here|these|this|more|link)\b[^`]*`' \ No newline at end of file diff --git a/tests/data/manifest.yml b/tests/data/manifest.yml index 5c7932b..0cc9e6d 100644 --- a/tests/data/manifest.yml +++ b/tests/data/manifest.yml @@ -549,6 +549,176 @@ rules: As shown by Smith and colleagues in their paper. expect: triggers: [] + 026-hints-tips: + cases: + - id: valid + filetypes: [md, rst] + content: | + .. hint:: + This is a reST hint. + .. tip:: + This is a reST tip. + ```{hint} + This is a MyST hint. + ``` + ```{tip} + This is a MyST tip. + ``` + ````{hint} + This is a deeper MyST hint. + ```` + ````{tip} + This is a deeper MyST tip. + ```` + :::{hint} + This is a colon-fenced MyST hint. + ::: + :::{tip} + This is a colon-fenced MyST tip. + ::: + ::::{hint} + This is a deeper colon-fenced MyST hint. + :::: + ::::{tip} + This is a deeper colon-fenced MyST tip. + :::: + expect: + triggers: + - '.. hint::' + - '.. tip::' + - '```{hint}' + - '```{tip}' + - '````{hint}' + - '````{tip}' + - ':::{hint}' + - ':::{tip}' + - '::::{hint}' + - '::::{tip}' + severity: suggestion + 027-non-descriptive-link-text: + cases: + - id: bad-link-text-md + filetypes: [md] + content: | + See [here](https://example.com) for details. + Go to [click here](https://example.com) to learn. + Read [this](https://example.com/doc) for more. + Check [these](https://example.com/list) items. + For details, [read more](https://example.com). + To get started, [learn more](https://example.com). + See [more](https://example.com) about the topic. + Follow this [link](https://example.com). + Visit [this link](https://example.com) for help. + See [this page](https://example.com) for info. + Read [this document](https://example.com) now. + See [this article](https://example.com/blog) too. + See [more information](https://example.com) below. + See [more info](https://example.com/faq) here. + Try [clicking here](https://example.com/try) for setup. + See [the link to docs](https://example.com/docs) now. + See [see more details](https://example.com/info) below. + See {doc}`here ` for details. + See {ref}`this