-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix href for aliased modules in search results #1108
Conversation
Sounds to me like there is some confusion internally about the difference between a module identifier and a signature identifier. A module identifier for Since |
Probably the simplest fix is to say 'stop_before=true' - this should cause links to everything that might have an expansion to go to the definition point instead of into the expansion. The current change definitely doesn't look right. |
The main problem is that standalone comments do not have an ID, and thus use the ID of their parent module/page. If we use
I opened #1109 which also stems from this issue. Indeed fixing both #1109 and #1106 at the same time would be much better.
That would turn all references of modules into links to the definition of the module. Currently those references link to the expansion. That can make sens but I'm always cautious when changing the current behaviour... |
In particular, it would make every |
Looking back on my comment I missed the vital bit of info: I meant just use |
I implemented your suggestion @jonludlam. Instead of using |
Signed-off-by: Paul-Elliot <[email protected]>
Signed-off-by: Paul-Elliot <[email protected]>
Otherwise, we can end up with 404 links. See ocaml#1106. Signed-off-by: Paul-Elliot <[email protected]>
Signed-off-by: Paul-Elliot <[email protected]>
The "module alias" test uses syntax introduced after 4.06 Signed-off-by: Paul-Elliot <[email protected]>
src/search/html.ml
Outdated
with | ||
let url { Entry.id; kind; doc = _ } = | ||
let open Entry in | ||
let stop_before = match kind with Doc _ -> false | _ -> true in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please put a comment in the code here explaining why you're matching Doc
? It's not very obvious!
(* Docstring do not have an ID, so we use the ID from the parent signature | ||
in search entries. Links to signature need [stop_before] to be false | ||
(otherwise the link may point to the definition point of the module). *) | ||
match kind with Doc _ -> false | _ -> true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.
I think my point was that the intent of this line of code is to prevent a link potentially going to a module/module type/class/etc that doesn't have an expansion. I was mostly expecting to see something more like match kind with | Module _ -> true | ModuleType _ -> true ... | _ -> false
- where the wildcard is matching the things like Exception
and so on. I don't think it's terribly obvious that stop_before
has no impact on those things, so instead we can just match Doc
and let stop_before
do nothing for the other things.
8aa0a48
to
6dc65a9
Compare
Signed-off-by: Paul-Elliot <[email protected]>
That's much better, thanks! |
Signed-off-by: Paul-Elliot <[email protected]>
Fix #1106
It is not ideal that calls to
Url.from_identifier
can result in 404 pages on aliased modules. This never happened before the introduction of search. This PR fixes this in an ad-hoc way for search.I think it would be better to fix it in the identifier themselves: the ID of an aliased module would include the ID of its alias if it exists. Otherwise, generated URL can point to the definition point: the parent page with the appropriate anchor.
Before this is implemented, I think this fix is good enough. What do you think?
Ping @EmileTrotignon for the change in API of the search library.