Rustdoc should validate headings

I notice this might be difficult as the headings are only generated at a later point. But it would be helpful if rustdoc could validate links to headings.

A usecase would be having a long description on some module containing a heading:

# Some Heading

And linking to it in some other place

[see heading](module#some-heading)

This will work, but if someone should change the heading this link will break without any warning. Therefor I'm proposing that rustdoc could add a function to validate this.

4 Likes

seems pretty simple if you just run the lint after the html has been generated

this is just a subset of the problem of making sure documentation doesn't contain dead links.

the only slightly tricky parts are extracting the id attribute of all the elements, and handling links to sections in seperate files.