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
38 changes: 25 additions & 13 deletions checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Tests should be made as Python scripts to allow flexibility of use. Currently th
- [GitHub Actions](https://docs.github.com/en/actions) as defined in [workflows](../.github/workflows/),
- [VSCode Problem Matchers](https://code.visualstudio.com/docs/editor/tasks#_processing-task-output-with-problem-matchers) as defined in [tasks.json](../.vscode/tasks.json).

## Spellcheck
## Check Types

### Spellcheck

*This linter is defined in [run_spell_check.py](run_spell_check.py) script.*

Expand All @@ -16,41 +18,51 @@ Spellcheck pipeline settings can be modified in [.spellcheck.yml](../.spellcheck
List of custom words can be found in [dictionary.txt](../docs/assets/glossary/dictionary.txt),
however you **should not edit this manually**, see [adding-words-to-dictionary](../docs/CONTRIBUTING.md#adding-words-to-dictionary).

### Limitations
#### Limitations

Spellchecker does not provide output lineumber / column.
In order to get this a regex match is done on the markdown.
This means that you might occassionally see a word highlighted inside a context where it should be ignored (e.g. code block),
the typo is probably occuring elsewhere in the text in a valid context, fix it here and the first error will resolve.

## Prose Lint
### Prose Lint

*This linter is defined in [run_proselint.py](run_proselint.py) script.*

Checks text follows best practice for English language.

Individual rules can be disabled/enabled in [.proselint.json](../.proselint.json).

## Markdown Lint
### Markdown Lint

Checks markdown for complience against general [best practice rules](https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md).
Checks markdown for compliance against general [best practice rules](https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md).

Individual rules can be disabled/enabled in [.markdownlint.json](../.markdownlint.json)

## Meta Checks
### Meta Checks

*This linter is defined in [run_meta_check.py](run_meta_check.py) script.*

Catch-all for custom checks.
Currently defined checks are:

- title_redundant,
- title_length,
- meta_missing_description,
- meta_unexpected_key,
- minimum_tags,
- walk_toc.
- title_redundant
- title_length
- meta_missing_description
- meta_unexpected_key
- minimum_tags
- walk_toc
- click_here
- dynamic_slurm_link

## Test Build
### Test Build

Does a 'strict' build of the site, capturing any errors emmited by mkdocs.

### Debugging Checks

Each type of test has a debug job in VSCode.

Most will run on the [fail_checks](fail_checks.md) page

![alt text](../docs/assets/images/debug_menu.png)
4 changes: 4 additions & 0 deletions checks/fail_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Typos should [be ignored](https://www.docs.nesi.org.nz)
Typos should [be ignored](../docs/General/FAQs/How_do_I_request_memory.md)


links shouldn't be called [here](../docs/General/FAQs/How_do_I_request_memory.md)
but can be called [where](../docs/General/FAQs/How_do_I_request_memory.md)



Bad formatting for markdownlint

Expand Down
51 changes: 51 additions & 0 deletions checks/run_aria_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Check built HTML for broken ARIA id references."""

from html.parser import HTMLParser
from pathlib import Path
import sys


class AriaParser(HTMLParser):
def __init__(self):
super().__init__()
self.ids = set()
self.refs = []

def handle_starttag(self, tag, attrs):
d = dict(attrs)
if "id" in d:
self.ids.add(d["id"])
for key in ["aria-labelledby", "aria-describedby", "aria-controls"]:
if key in d:
for ref in d[key].split():
self.refs.append((key, ref, tag))


def main():
base = Path("public")
if not base.exists():
print("::error file=checks/run_aria_check.py,title=missing_public_dir::public folder not found. Run mkdocs build first.")
return 1

broken = []
for path in sorted(base.rglob("*.html")):
text = path.read_text(encoding="utf-8", errors="ignore")
parser = AriaParser()
parser.feed(text)
for key, ref, tag in parser.refs:
if ref not in parser.ids:
broken.append((path, key, ref, tag))

if broken:
for path, key, ref, tag in broken:
print(f"::error file={path},title=broken_aria_reference,col=0,endColumn=0,line=0::{key} reference '{ref}' missing id in tag <{tag}>")
print(f"Found {len(broken)} broken aria references.")
return 1

print("ARIA reference check passed.")
return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading
Loading