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

Expose model, html, etc as public libraries #236

Closed
jfeser opened this issue Nov 5, 2018 · 4 comments
Closed

Expose model, html, etc as public libraries #236

jfeser opened this issue Nov 5, 2018 · 4 comments
Milestone

Comments

@jfeser
Copy link
Contributor

jfeser commented Nov 5, 2018

I have a small tool (https://github.com/jfeser/odoc2docset) that depends on odoc. I use code from odoc.model to extract names and odoc.html to handle html generated by odoc. Could these libraries be exposed publicly? Right now I have a fork, but I'd rather just use the released version.

@aantron
Copy link
Contributor

aantron commented Nov 5, 2018

We can expose them with the understanding that their interface is not meant to be stable.

@aantron aantron added this to the 1.3.1 milestone Nov 5, 2018
@jfeser
Copy link
Contributor Author

jfeser commented Nov 5, 2018

That works for me. Thanks!

@aantron
Copy link
Contributor

aantron commented Nov 16, 2018

This seems to require giving the libraries globally unique names, like Odoc__model. The reason for the two underscores is that there are already modules with one. They come with the compiler and are part of ocamldoc.

This would make odoc's own code much uglier.

Still thinking about what to do here.

aantron added a commit that referenced this issue Nov 20, 2018
@aantron
Copy link
Contributor

aantron commented Nov 20, 2018

Ok, the sublibraries are now exposed. All the sublibraries are installed upon opam install odoc.

The library in directory model is installed as ocamlfind package odoc.model, and the module name is Odoc__model. The rest of the sublibraries follow the same pattern.

To do this, I had to, of course, rename module Model to Odoc__model, etc. To avoid ugly names, and changing all our code for this issue, I added an alias module in src/alias/odoc__alias.ml. This allows us to use the renamed modules under their previous, neat names:

module Compat = Odoc__compat
module Html = Odoc__html
module Loader = Odoc__loader
module Model = Odoc__model
module Odoc = Odoc__odoc
module Parser_ = Odoc__parser
module Xref = Odoc__xref

This alias module is -opened in all of odoc's code. It's a little bit dubious, but it's something we can undo quickly, if needed.

As mentioned, the interfaces of these libraries are unstable (including their names and existence), and we won't document them beyond what is needed by odoc. So, be careful :)

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

No branches or pull requests

2 participants