Check cross-references in repository documents
Go to file
Alyona Antonova ecff1dc342 [#135] Add support of right in-place annotations
Problem: It can be convenient not only specifying
exclusions in the config, but also annotating
the excluded thing right in-place. It is about
adding comment before the link or the paragraph
or even the whole file to ignore this item.

Solution: Support annotation as html comment in
a "<!-- xrefcheck: ignore mode -->" format, where
mode is "link" or "paragraph" or "file". Modify
`nodeExtractInfo` from `Xrefcheck.Scanners.Markdown`
just to skip a node in AST while parsing. Take into
account that "ignore file" can only be at the top
of the file or right after the license. In markdown
terms: either the first node must be HTML_BLOCK
with "<!-- xrefcheck: ignore file -->" content
or the first is HTML_BLOCK comment (smth
between "<!--" and "-->") and the second is
HTML_BLOCK with "ignore file" content.
Also take into account that "ignore link" must be
followed by a link. Strictly speaking, there is
either LINK after "ignore link" or TEXT and LINK
(if there is some text before the link).
2021-03-09 22:18:07 +03:00
.buildkite [OPS-1023] Add '--insecure-policy' to skopeo invocation 2020-08-10 15:14:45 +03:00
.github Add a changelog, require its maintenance 2020-01-14 20:24:01 +03:00
.reuse [INT-128] Make the repository REUSE compliant 2019-12-19 16:19:27 +03:00
docker Add a windows build 2020-07-03 12:08:22 +03:00
exec Disable progress bar in CI automatically 2020-06-26 22:32:03 +03:00
LICENSES [INT-128] Make the repository REUSE compliant 2019-12-19 16:19:27 +03:00
nix CI: bump hackage and stackage 2020-09-28 11:51:08 +03:00
release Add a windows build 2020-07-03 12:08:22 +03:00
src/Xrefcheck [#135] Add support of right in-place annotations 2021-03-09 22:18:07 +03:00
src-files [#135] Add vcIgnoreRefs as regexs to Xrefcheck.Config 2021-03-09 16:42:29 +03:00
tests Rename module names 2020-01-14 19:41:47 +03:00
.gitignore [INT-128] Make the repository REUSE compliant 2019-12-19 16:19:27 +03:00
CHANGES.md Make a release 2020-06-26 22:32:03 +03:00
default.nix Add a windows build 2020-07-03 12:08:22 +03:00
LICENSE Add README and other required meta files 2019-03-14 20:29:36 +03:00
package.yaml [#135] Add support of right in-place annotations 2021-03-09 22:18:07 +03:00
README.md Update README section with comparison 2021-01-08 15:21:25 +03:00
Setup.hs [INT-128] Make the repository REUSE compliant 2019-12-19 16:19:27 +03:00
stack.yaml [OPS-1023] CI: pin hackage.nix and stackage.nix independently 2020-08-10 15:12:21 +03:00
stack.yaml.lock [#36] Switch to lts-15.13 2020-05-23 18:41:11 +03:00
stack.yaml.lock.license [INT-128] Make the repository REUSE compliant 2019-12-19 16:19:27 +03:00
xrefcheck.nix CI: fix pinning hackage and stackage 2020-09-28 11:51:01 +03:00

Xrefcheck

Build status

Xrefcheck is a tool for verifying local and external references in repository documentation that is quick, easy to setup, and suitable to be added to CI.

Output sample

Motivation

As the project evolves, links in documentation have a tendency to get broken. This is usually because of:

  1. File movements;
  2. Markdown header renames;
  3. Outer sites ceasing their existence.

This tool will help you to keep references in order.

Aims

Comparing to alternative solutions, this tool tries to achieve the following points:

  • Quickness - local references are verified instantly even for moderately-sized repositories.
  • Easy setup - no extra actions required, just run the tool in the repository root. Both relative and absolute local links are supported out of the box.
  • Conservative verifier allows using this tool in CI, no false positives (e.g. on sites which require authentication) should be reported.

A comparison with other solutions

  • linky - a well-configurable verifier written in Rust, scans one specified file at a time and works good in pair with system utilities like find. This tool requires some configuring before it can be applied to a repository or added to CI.
  • awesome_bot - a solution written in Ruby that can be easily included in CI or integrated into GitHub. Its features include duplicated URLs detection, specifying allowed HTTP error codes and reporting generation. At the moment of writting, it scans only external references and checking anchors is not possible.
  • remark-validate-links and remark-lint-no-dead-urls - highly configurable Javascript solution for checking local and remote links resp. It is able to check multiple repositores at once if they are gathered in one folder. Being written on JavaScript, it is fairly slow on large repositories.
  • markdown-link-check - another checker written in JavaScript, scans one specific file at a time. Supports mailto: link resolution.
  • url-checker - GitHub action which checks links in specified files.
  • linkcheck - advanced site crawler, checks for HTML files. There are other solutions for this particular task which we don't mention here.

Usage

We provide the following ways for you to use xrefcheck:

If none of those are suitable for you, please open an issue!

To find all broken links in a repository, run from within its folder:

xrefcheck

To also display all found links and anchors:

xrefcheck -v

For description of other options:

xrefcheck --help

Configuring

Configuration template (with all options explained) can be dumped with:

xrefcheck dump-config

Currently supported options include:

  • Timeout for checking external references;
  • List of ignored folders.

Build instructions

Run stack install to build everything and install the executable.

CI and nix

To build only the executables, run nix-build. You can use this line on your CI to use xrefcheck:

nix run -f https://github.com/serokell/xrefcheck/archive/master.tar.gz -c xrefcheck

Our CI uses nix-build xrefcheck.nix to build the whole project, including tests and Haddock. It is based on the haskell.nix project. You can do that too if you wish.

For further work

  • Support for non-Unix systems.
  • Support link detection in different languages, not only Markdown.
    • Haskell Haddock is first in turn.

Issue tracker

We use GitHub issues as our issue tracker. You can login using your GitHub account to leave a comment or create a new issue.

For Contributors

Please see CONTRIBUTING.md for more information.

About Serokell

Xrefcheck is maintained and funded with ❤️ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.

We love open source software! See our other projects or hire us to design, develop and grow your idea!