root-dir: allow root-dir that doesn't exist#2127
root-dir: allow root-dir that doesn't exist#2127katrinafyi wants to merge 2 commits intolycheeverse:masterfrom
Conversation
the existence check wasn't super helpful, i think. with an invalid root-dir, links will now fail in the link checking phase, but i think it is fairly obvious and not confusing. removing the check makes some use-cases easier. for example, you can intentionally use a non-existing root-dir to validate that *no* root-relative links are used. maybe we could print a warning if the root-dir is found to be invalid? but i think it's okay without.
|
To be honest, I liked that we validate the root-directory. After all, isn't that the only place where we have a chance to detect typos and invalid paths? Without that, I'm afraid that the number of misconfigurations could go up, which can be frustrating to users. Can you think of use-cases other than #2125, where this can be useful? 🤔 I think it's a clever workaround to specify a non-existent root-dir to exclude root-relative links, but it sounds a bit hacky. The alternative suggested was to add a flag like Printing a warning for invalid root-dirs sounds like a good middle-ground, but it could go unnoticed. |
|
I think that the UX impact of this change is not too big. The link checking error displays the URL with root-dir at the beginning, so users will naturally investigate that URL and see that root-dir is being applied. Having the source line:col also makes this easier, as users can go to that file location and see the root-relative link. $ cargo run rel.md --root-dir /tmp/nowhere
[rel.md]:
[ERROR] file:///tmp/nowhere/root (at 1:1) | File not found. Check if file exists and path is correctTo exclude root-relative links, I think --root-dir + --exclude is not at a hack at all. To me, it seems like a very natural way to do this: you use --root-dir to specify where root-relative links will go, and you combine this with --exclude to exclude links matching a certain pattern. I wouldn't like |
|
All good points, thanks. Let's go ahead with it then. |
50d5257 to
e9f0070
Compare
|
Feel free to merge when ready. 😊 |
the existence check wasn't super helpful, i think. with an invalid root-dir, links will now fail in the link checking phase, but i think it is fairly obvious and not confusing.
removing the check makes some use-cases easier. for example, you can intentionally use a non-existing root-dir to validate that no root-relative links are used. also makes it easier for the use-case of #2125 .
maybe we could print a warning if the root-dir is found to be invalid? but i think it's okay without.
as an alternative to this pr, we could only validate relative root-dirs and allow non-existing absolute root-dirs. but i worried that would be confusing and inconsistent.