From eed9b8128486b3325ba20e2bc86523e2b1422a52 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 9 Oct 2024 08:16:16 +0700 Subject: [PATCH] chore(common): address review comments --- resources/tools/check-markdown/README.md | 20 +++++++++++++++++++ .../tools/check-markdown/src/check-link.ts | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 resources/tools/check-markdown/README.md diff --git a/resources/tools/check-markdown/README.md b/resources/tools/check-markdown/README.md new file mode 100644 index 00000000000..0f01787c105 --- /dev/null +++ b/resources/tools/check-markdown/README.md @@ -0,0 +1,20 @@ +# check-markdown + +This tool is used to test the validity of internal links within product +documentation, e.g. `/android/docs/help/**/*.md`. + +It currently tests that: + +1. Markdown can be parsed +2. Links to other files in the same section exist (with or without .md extension) +3. Images exist + +It will also optionally report on: + +1. External absolute links (starting with http/https) +2. Relative links outside the root of the help documentation +3. Unnecessary use of .md extension in links + +We could extend it to include: + +1. Checks for anchor validity diff --git a/resources/tools/check-markdown/src/check-link.ts b/resources/tools/check-markdown/src/check-link.ts index 9a99c33a7db..08df0b001d2 100644 --- a/resources/tools/check-markdown/src/check-link.ts +++ b/resources/tools/check-markdown/src/check-link.ts @@ -24,8 +24,8 @@ function checkLink(root: string, file: string, token: Tokens.Link | Tokens.Image if(href.startsWith('https:') || href.startsWith('http:')) { messages.push({token, type:'info', message: 'External link'}); return true; - } + if(href.startsWith('/')) { messages.push({token, type:'info', message: 'Absolute path'}); return true;