-
Notifications
You must be signed in to change notification settings - Fork 97
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
Rudimentary support for assets #975
Conversation
src/document/url.ml
Outdated
| { iv = `AssetFile (p, _name); _ } -> | ||
let page = Path.from_identifier p in | ||
Ok { page; kind = `File; anchor = "" } |
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 copied what was done for `SourcePage
here, but honestly it looks weird.
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.
Is it the anchor = ""
which is bothering you?
For some reason, "no anchor" is represented as "empty anchor". The type Url.t
is even defined as Anchor.t
. See any identifier which is a page, and thus has no anchor (Page
, LeafPage
, Root
, ...)
So that's correct, but I agree it would look better if the anchor
field was an option.
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.
Is it the
anchor = ""
which is bothering you?
No, it's that we're getting a url to the parent of the asset, not the asset itself.
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.
Indeed, that's a bug, thanks for spotting it! It was not harmful because we only call Path.from_identifier
on the `SourcePage
variant, never Anchor.from_identifier
.
| { iv = `AssetFile (p, _name); _ } -> | |
let page = Path.from_identifier p in | |
Ok { page; kind = `File; anchor = "" } | |
| { iv = `AssetFile _; _ } as p -> | |
let page = Path.from_identifier p in | |
Ok { page; kind = `File; anchor = "" } |
Could you correct SourcePage
and SourceDir
as well?
File "img.jpg": | ||
Warning: asset is missing. |
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 wondered if this should have been a fatal error, since I didn't know how to make it be one I managed to convince myself that it shouldn't be.
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 odoc
tries to avoid failing too badly in case of errors.
So I don't think it should be a hard failure, but that should not stop processing the other assets (see above)
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.
Nice!
I'm not sure why assets could not be children of compilation unit. But that should not be a too restrictive restriction, so I'm happy with it!
The only thing I would like to see changed is the non-handling of other assets in case of a missing asset.
src/document/url.ml
Outdated
| { iv = `AssetFile (p, _name); _ } -> | ||
let page = Path.from_identifier p in | ||
Ok { page; kind = `File; anchor = "" } |
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.
Is it the anchor = ""
which is bothering you?
For some reason, "no anchor" is represented as "empty anchor". The type Url.t
is even defined as Anchor.t
. See any identifier which is a page, and thus has no anchor (Page
, LeafPage
, Root
, ...)
So that's correct, but I agree it would look better if the anchor
field was an option.
File "img.jpg": | ||
Warning: asset is missing. |
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 odoc
tries to avoid failing too badly in case of errors.
So I don't think it should be a hard failure, but that should not stop processing the other assets (see above)
Also, there are compatibility issues that would need to be taken care of... |
What's the story from a user and driver (say |
I guess that's still open? I do hope we can add references to assets in the not too distant future to make this question disappear, in the meantime my intuition is that right now the easiest is probably to use the "package root" as parent of the assets. Does that somewhat answer your question, or did I totally miss your point? |
And yet that's what we need. It was already decided to not prescribe anything for the parent/child relationship and as I suggested at that the time that's not a good idea. We could have had perfectly self-described documents but are moving away from that more and more. Look at what happend with upstream not prescribing anything for libraries: eco-system mess. Now |
I get your point. However, after years of being away from odoc and having not been involved in this decision, I just came back for this "small" PR. That being said:
|
I agree that the decision to make The code looks good, let's merge, thanks @trefis! |
This has been written for ages here and it's mentioned in #59. Interacting with this project remains as frustrating as ever I have to say. |
Context: #59 , #972
No support for referring to assets yet.
This only provides a way to get odoc to place them "in the right place" in the directory structure; so it's only marginally useful.
Current interface:
odoc compile
can now be of the formasset-filename
html-generate
andhtml-targets
commands now accept--asset FILE
arguments, which are paired (based on filename) with the relevant child asset. Warnings are emitted for unknown and missing assets.html-generate
through--asset
are copied in the directory of their parent; would it be better to put them in an_assets
subdirectory?This is illustrated in
test/pages/assets.t/run.t