doc/starlight: fix edit link for generated documents#21987
doc/starlight: fix edit link for generated documents#21987miri64 merged 1 commit intoRIOT-OS:masterfrom
Conversation
doc/starlight/src/routeData.ts
Outdated
|
|
||
| if (starlightRoute.editUrl) { | ||
| let editUrl = starlightRoute.editUrl.toString(); | ||
|
|
There was a problem hiding this comment.
(somehow, Github renders this suggestion weirdly. I mean: remove trailing whitespaces, please, i.e., keep the line empty)
doc/starlight/src/routeData.ts
Outdated
| const filename = editUrl.split(generatedPath)[1]; | ||
| editUrl = editUrl.split(generatedPath)[0] + '/' + filename; | ||
| } | ||
|
|
doc/starlight/src/routeData.ts
Outdated
| const filename = editUrl.split(generatedPath)[1]; | ||
| editUrl = editUrl.split(generatedPath)[0] + '/' + filename; |
There was a problem hiding this comment.
As far as I understand this (very weird; why not just use '/' as a token and use the first and last element of the string) parsing step, this basically assumes that all files were generated from root. This invites potential footguns IMHO and also might lead to maybe unrelated files (something about boards/ e.g.) hogging the already quite crowded root path. I'd rather have a mapping somewhere, where the name of the generated file is mapped to the original source. It can be in this file, but maybe it makes sense to hook this directly into the generation somehow. This way, we would avoid risks of the generation and the edit links going potentially out of sync.
There was a problem hiding this comment.
"tech debt", the code was different before and I only later realized one issue with it
There was a problem hiding this comment.
I looked into different solutions for this and if I'm being honest all of them felt really weird. Currently the only reason we'd ever have documentation on that exact /doc/guides/generated path is when they are root files and I don't foresee new files outside of root being added to that path
There was a problem hiding this comment.
As I said: I see it feasible to have some guide on a specific module or test, e.g., in a markdown file with that. But fine. I don't want to block the PR just because of that if you disagree.
There was a problem hiding this comment.
Nah I get what you mean, however, any good solution would probably require moving away from the current setup for generated sites we have (because it grew a bit too big for the initial "hacky" solution already) so all my attempts of adressing the feedback ended up with unsatisfactory solutions
miri64
left a comment
There was a problem hiding this comment.
ACK. Tested with make doc-starlight.
Contribution description
@miri64 noticed that the edit link was broken when the site was generated using one of the root markdown files, this should fix that.
Testing procedure
make doc-starlightand then click on the edit page link on e.g. SecurityIssues/PRs references