Skip to content
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

Merged
merged 8 commits into from
Jul 22, 2024
Merged

Conversation

Julow
Copy link
Collaborator

@Julow Julow commented Jul 18, 2024

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 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.
Copy link
Collaborator

@panglesd panglesd left a 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
Copy link
Collaborator

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!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, done!

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. *)
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@panglesd panglesd merged commit 904b601 into ocaml:master Jul 22, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants