jfmengels / elm-review-documentation

Provides elm-review rules to help with the quality and correctness of your Elm project's documentation
https://package.elm-lang.org/packages/jfmengels/elm-review-documentation/latest/
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Don't report links in code blocks #20

Open lue-bird opened 7 months ago

lue-bird commented 7 months ago

Applies to

If you include a link to a code example:
```elm
module A exposing (A)
{-| Helpers for [`B.B`](B#B)
-}
import B
it triggers both rules

Docs.ReviewLinksAndSections: Link points to non-existing module Expression

202| module A exposing (A) 203| {-| Helpers for B.B ^^^ 204| -}

This is a dead link.

Docs.UpToDateReadmeLinks: Found relative link to a module in README

202| module A exposing (A) 203| {-| Helpers for B.B ^^^ 204| -}

Relative links to other modules from the README don't work when looking at the docs from GitHub or the likes.

I suggest to run elm-review --fix to change the link to an absolute link.


which is not correct because these are not real links that are rendered as such, they are code.

Treat this as a very low prio as checking for it is a bit of work and should only be quite rare in practice.

For implementation we could for example remove all sections from starting-spaced ```` ``` ```` until the next spaced ```` ``` ```` before checking.
jfmengels commented 7 months ago

Good find 👍

For implementation we could for example remove all sections from starting-spaced until the next spaced before checking.

We also need to check for indentation blocks. If you have lines that are indented by 4 (maybe with an empty line above?) then it gets considered as an Elm code block (you'll seen elm-format try to update it). In which case we also need to ignore it.