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

Allow more hierarchy to be compatible with -L and -P. #1233

Merged
merged 11 commits into from
Nov 8, 2024

Conversation

panglesd
Copy link
Collaborator

@panglesd panglesd commented Nov 4, 2024

In the initial implementation of -L and -P we added too many constraints: the trees below the roots (both -L and -P) had to all be disjoint.

This prevented some hierarchy, such as the one where pages are put in pkgname/ and libraries in pkgname/libname/: indeed, -L pkgname/libname would not be disjoint from -P pkgname/.

This PR relax the constraint, -L roots have to be disjoints, and -P roots have to be disjoint, but there is no constraint between a -P and a -L root.

It also relaxes the constraint the when linking modules, the module has to be below a -L.

Tests are updated to use the simpler hierarchy.

I'll update the driver in another PR!

@panglesd panglesd added the no changelog This pull request does not need a changelog entry label Nov 4, 2024
@panglesd panglesd force-pushed the allow-more-hierarchies branch from 40727d1 to f5f0687 Compare November 4, 2024 10:35
else Ok ())
>>= fun () ->
(if not (Antichain.check (lib_roots |> List.map ~f:snd)) then
Error (`Msg "Paths given to all -L options must be disjoint")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really relevant to this PR, but wouldn't it be cleaner if Antichain.check would return (unit, some_error) result instead of a boolean? The error message can be customized with map_error or as a parameter to the check 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, that was not very readable, hopefully I've improved it in the last commit.

@panglesd panglesd force-pushed the allow-more-hierarchies branch 2 times, most recently from e3b10bf to b32814b Compare November 4, 2024 18:17

Specified current package is wrong:
$ odoc link -P pkg:h/pkg -L otherlib:h/otherpkg h/pkg/libname/test.odoc
Copy link
Member

Choose a reason for hiding this comment

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

nit: do you want -L otherlib:h/otherpkg/otherlib here instead?

Copy link
Collaborator Author

@panglesd panglesd Nov 5, 2024

Choose a reason for hiding this comment

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

Yes. I've cleaned up the test a bit (some options were not really necessary for the test and made it less readable). Hopefully it is better now!

@panglesd panglesd force-pushed the allow-more-hierarchies branch from 5431307 to 6f36972 Compare November 5, 2024 08:58
| [] -> None
| _ ->
find_map
~f:(fun (pkg, path) ->
Copy link
Member

Choose a reason for hiding this comment

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

These names are slightly misleading as pkg might actually be a lib. I know that was also the case before, but we might as well fix that now.

@panglesd
Copy link
Collaborator Author

panglesd commented Nov 5, 2024

I have made more tests with the new (doc-lib)less hierarchy, and there is a small issue.
When we have -P pkgname/ -L pkgname/libname, we don't want the content of pkgname/libname to be added to the accessible pages for pkgname (at least, not in the sidebar: the libraries are already included in the sidebar).
(The problem is shown in this commit)

An image is worth a thousand words

The sidebar for odoc, suffering from this:

image

I have solved this by excluding -L subdirectories from -P roots (a5f767c). Another option would have to add a metadata tag @sidebar omit which tells odoc to omit this subhierarchy from the sidebar. I think this second option is better, otherwise the name clashes are more likely.

@jonludlam
Copy link
Member

That @sidebar omit is a little odd as it's only omitting it as a subdirectory of another 'sidebar root'. It doesn't seem odd to me that things that are configured as 'sidebar roots' are never permitted to be subdirs of another 'sidebar root' so I think your current fix isn't unreasonable at all.

`-P` is now allowed to contain `-L` options, and modules do not need to be below
a `-L`.

This gives less contraints to the hierarchy decided by the driver. In
particular, this allows the hierarchy without `doc/` and `lib/` folders: pages
are put directly in `pkgname/` and modules in `pkgname/libname/`.

The original hierarchy is still possible.
By canonical I mean the one without doc and lib intermediate folders.
When a -L is a subfolder of -P (eg -P pkgname/ -L pkgname/libname), we don't
want the content of the -L root to be included in the -P root.
@panglesd panglesd force-pushed the allow-more-hierarchies branch from 746a58f to 7eedbc8 Compare November 6, 2024 08:27
@panglesd panglesd mentioned this pull request Nov 6, 2024
@@ -601,81 +601,49 @@ end = struct
match f x with Some _ as result -> result | None -> find_map ~f l)
Copy link
Collaborator

Choose a reason for hiding this comment

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

By the way find_map is in Odoc_utils.List

@gpetiot
Copy link
Collaborator

gpetiot commented Nov 7, 2024

I have made more tests with the new (doc-lib)less hierarchy, and there is a small issue. When we have -P pkgname/ -L pkgname/libname, we don't want the content of pkgname/libname to be added to the accessible pages for pkgname (at least, not in the sidebar: the libraries are already included in the sidebar). (The problem is shown in this commit)

Is there a previous discussion about this? I'm interested in having more context before forming an opinion, because naively it looks to me that it's something that should be handled in the driver (meaning that redundancies in the arguments would be intentional and should be preserved in the sidebar). But I don't have all the context :)

@panglesd
Copy link
Collaborator Author

panglesd commented Nov 8, 2024

I think some context can be understood by reading the discussion starting from this comment.

We can also do a quick call if you'd like.

@jonludlam
Copy link
Member

The alternate suggestions for how to create the perfect sidebar can happen in a later PR - this one is pretty foundational for some other work so let's get this in to unblock the other PRs.

@jonludlam jonludlam merged commit 6bb7627 into ocaml:master Nov 8, 2024
12 checks passed
panglesd added a commit to panglesd/sherlodoc that referenced this pull request Dec 9, 2024
Several changes:
- Entries are now defined in the `odoc_index` library,
- Entries can have new kinds (pages, source, ...)
- Indexes have the form of "skeletons of entries", that can be folded.
- Indexes can be created by odoc with the `odoc compile-index` command, and
  then consumed by sherlodoc.

These changes come from:
- ocaml/odoc#1228
- ocaml/odoc#1232
- ocaml/odoc#1233
- ocaml/odoc#1244
- ocaml/odoc#1250
- ocaml/odoc#1251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This pull request does not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants