-
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
Resolve path references to modules #1164
Conversation
The code for resolving path-references is factorized into the 'lookup_path' function. The 'Named_roots' for libraries is used to locate modules. Env's API is changed to make the Ref_tools part easier to write. Unprefixed references are resolved both as pages and modules concurrently and a warning is generated if the reference is ambiguous.
The printed warnings are not removed when loading a module by name.
The 'hierarchy_root' that ensures that relative references can't escape into other packages or libraries is different for modules and pages. This means that relative references can't be resolved from 'impl' units and from the 'html-url' command. The "current package dir" computation is changed to be more robust.
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.
Looks good to me!
It is a bit disappointing that the error reporting is all merged into a `Not_found
error but I agree this can be done in another PR. Hopefully this will be done and not forgotten.
| Error `Escape_hierarchy -> None (* TODO: propagate more information *) | ||
in | ||
match tag with | ||
| `TCurrentPackage -> | ||
(* [path] is within the current package root. *) | ||
page_path_to_path path >>= find_page |> option_to_page_result | ||
ref_path_to_file_path path | ||
|> List.find_map find_in_named_roots |
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.
Odoc_utils.List
needs this function!
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.
Yes, done!
src/odoc/resolver.ml
Outdated
match load_unit_from_file file with Some u -> u :: acc | None -> acc | ||
in | ||
List.fold_right safe_read paths [] | ||
(** Returns [None] if the file is not found or failed to load for any reason. *) |
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.
I think this docstring has to be updated. This function returns a result.
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.
Fixed.
The code for resolving path-references is factorized into the
lookup_path
function. TheNamed_roots
for libraries is used to locate modules.Env
's API is changed to make theRef_tools
part easier to write.Unprefixed references are resolved both as pages and modules concurrently and a warning is generated if the reference is ambiguous.