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

Add ability to call generate commands on asset units #1185

Merged
merged 18 commits into from
Aug 23, 2024

Conversation

panglesd
Copy link
Collaborator

@panglesd panglesd commented Aug 1, 2024

The pipeline for asset was missing the generate command. This PR simply adds that!

The driver will need to be updated to follow the convention for installed asset described in #1113 (section: "Assets for installed packages").

@panglesd
Copy link
Collaborator Author

panglesd commented Aug 1, 2024

(I'm not very proud of the name of the CLI option: --asset-path)

let source = source_of_args source_root source_file in
let file = Fs.File.of_string input_file in
Rendering.generate_odoc ~renderer:R.renderer ~warnings_options ~syntax
~output:output_dir ~extra_suffix ~source ~sidebar extra file
~output:output_dir ~extra_suffix ~source ~sidebar ~asset_path extra file
Copy link
Collaborator

@Julow Julow Aug 2, 2024

Choose a reason for hiding this comment

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

I'm not a fan of adding more arguments to this command. This argument makes no sense in most cases and needs to be checked. Similarly, Document.Asset seems a bit out of place, as it interacts with nothing else, it could be out of the document thing entirely.

What about adding a different command for generating assets ? html-generate-asset, latex-generate-asset, etc..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The same is true for --source and --source-root, but OK, I'll do that!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(the Document.Asset will be inconvenient to remove in my opinion, unless we remove the old way of attaching assets, which would be a good thing I think)

@panglesd
Copy link
Collaborator Author

I have added support in the driver for the asset pipeline, following the convention.

This means, we now have images working for packages following the odig convention!

image

Copy link
Collaborator

@Julow Julow 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 :)

src/driver/dune_style.ml Outdated Show resolved Hide resolved
@@ -135,6 +135,10 @@ let pkg_to_dir_map () =
| "doc" :: _pkg :: "odoc-pages" :: _ ->
Logs.debug (fun m -> m "Found odoc page: %a" Fpath.pp fpath);

(Fpath.Set.add Fpath.(v prefix // fpath) odoc_pages, others)
| "doc" :: _pkg :: "odoc-assets" :: _ ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated to this PR but pages and assets are taken from the list of installed files for a package. I find that unnecessary and potentially buggy. A package could install doc in an other package or this file could be outdated (dune install), which might crash the driver.
I think the doc/pkgname folder should be scanned independently of pkg_contents. I think the same for libraries but there might be cases that require this?

@Julow
Copy link
Collaborator

Julow commented Aug 21, 2024

There's a broken asset in vg.lib.vg.Vg.P because it's using an hardcoded path but I couldn't make the reference syntax work. Asset references from libraries might not work.

@panglesd
Copy link
Collaborator Author

This has been rebased on top of #1188. html-generate and html-generate-asset have been split. The old asset pipeline has been removed: --child asset-... for compile and --asset for html-generate.

@@ -24,7 +24,6 @@ type input =
type 'a t = {
name : string;
render : 'a -> Types.Block.t option -> Types.Document.t -> page list;
extra_documents : 'a -> input -> Types.Document.t list;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome !

Comment on lines 123 to 124
let doc = Renderer.document_of_asset asset_file unit in
render_document renderer ~output ~sidebar:None ~extra_suffix ~extra doc;
Copy link
Collaborator

Choose a reason for hiding this comment

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

There was a lot of simplification in this PR, why not continue and remove assets from the document and the renderer ?
document_of_asset seems very orthogonal to the rest of the document (it's just the Asset constructor which shares nothing with the other document types) and because of render_document and the renderer type, the content of the asset file has to go through a Format buffer, which seems totally unnecessary.
I think all of this could be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True! (I started that and decided to stop, thinking you would not see it, so I stashed everything. Time to stash pop!)

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

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

I think the driver is broken on main as it calls odoc html-generate-impl but I could test this a bit.

src/odoc/fs.ml Outdated Show resolved Hide resolved
src/driver/odoc.ml Outdated Show resolved Hide resolved
@panglesd
Copy link
Collaborator Author

I think the driver is broken on main as it calls odoc html-generate-impl but I could test this a bit.

I'm being pragmatic and fixing this in this PR.

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

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

It's perfect now, let's merge !

@panglesd panglesd merged commit d6fea07 into ocaml:master Aug 23, 2024
12 checks passed
@panglesd panglesd mentioned this pull request Aug 23, 2024
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