renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.59k stars 2.32k forks source link

Validate relative links with docs tests #28561

Closed HonkingGoose closed 6 months ago

HonkingGoose commented 6 months ago

Describe the proposed change(s).

Creating this issue as asked by @viceice in this comment:

We should check if all relative links in our Markdown files (*.md) are correct, this makes sure that the published docs has working links. This check should be automated, via tests or configuration of existing tools.

The mkdocs dependency in our renovatebot/renovatebot.github.io repository already warns us about some bad link types, here's the relevant snippet: [^1]

# Build settings

# Halt processing when a warning is raised when building the docs.
# https://www.mkdocs.org/user-guide/configuration/#strict
strict: true

# Use MkDocs maintainer's recommended strictness settings for link validation.
# https://www.mkdocs.org/user-guide/configuration/#validation

validation:
  omitted_files: warn
  absolute_links: warn
  unrecognized_links: warn

mkdocs already warns about bad relative links, but we only see that warning output when we (or Renovate) create a new docs build in the docs repo... So that warning can't help you decide if a PR is good to merge. :upside_down_face:

We have a documentation.spec.ts file that has some docs specific tests. I don't see code that tests for relative links?

[^1]: mkdocs.yml config file on renovatebot.github.io repository

HonkingGoose commented 6 months ago

I don't know enough to work on this issue.

@viceice if you want to work on this, please assign yourself to the issue. 😉

viceice commented 6 months ago

will start working on it today

WARNING -  Doc file 'modules/manager/devcontainer/index.md' contains a relative link '../dockerfile/readme.md', but the target 'modules/manager/dockerfile/readme.md' is not found among documentation files.
WARNING -  Doc file 'modules/manager/devcontainer/index.md' contains a relative link '../docker-compose/readme.md', but the target 'modules/manager/docker-compose/readme.md' is not found among documentation files.
viceice commented 6 months ago

We also need to validate anchors, see

viceice commented 6 months ago
INFO    -  Doc file 'configuration-options.md' contains a link './self-hosted-configuration.md#allowedEnv', but the doc 'self-hosted-configuration.md' does not contain an anchor '#allowedEnv'.
INFO    -  Doc file 'configuration-options.md' contains a link './self-hosted-configuration.md#allowedHeaders', but the doc 'self-hosted-configuration.md' does not contain an anchor '#allowedHeaders'.
INFO    -  Doc file 'configuration-options.md' contains a link './getting-started/running.md#githubcom-token-for-release-notes', but the doc 'getting-started/running.md' does not contain an anchor '#githubcom-token-for-release-notes'.
INFO    -  Doc file 'self-hosted-configuration.md' contains a link './self-hosted-experimental.md#renovatexs3endpoint', but the doc 'self-hosted-experimental.md' does not contain an anchor '#renovatexs3endpoint'.
INFO    -  Doc file 'self-hosted-configuration.md' contains a link './self-hosted-experimental.md#renovatexs3pathstyle', but the doc 'self-hosted-experimental.md' does not contain an anchor '#renovatexs3pathstyle'.
INFO    -  Doc file 'getting-started/private-packages.md' contains a link '../self-hosted-configuration.md#detectHostRulesFromEnv', but the doc 'self-hosted-configuration.md' does not contain an anchor '#detectHostRulesFromEnv'.
renovate-release commented 6 months ago

:tada: This issue has been resolved in version 37.330.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: