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

Build latex files with the @doc alias #5366

Closed
wants to merge 3 commits into from
Closed

Conversation

giltho
Copy link

@giltho giltho commented Jan 21, 2022

Hi!

This PR aims at adding a _latex target to the @doc standard alias. There is no open issue containing the word latex so I thought I might just as well write a PR to get the discussion going.

It's still a work in progress for several reasons:

  • I'm not very familiar with the inner workings of Dune, so there's probably a lot to improve
  • The latex macros are hardcoded in the toplevel file, and extracted from the main ocaml repo. It would be nice to be able to generate a sty file the same way highlight.pack.js and odoc.css are generated, using some odoc support-files command
  • For a package name some-thing, odoc generates a file called some_thing, I use Re to replace every - into an _ but I'm not sure that's the best thing to do
  • Importantly, files that are produced by mld files are correctly generated, but they won't appear in any pdf document, because they're not \input in any latex file accessible from the toplevel file.
  • Various classic latex issues like cross-referencing bugs.

I tried to factor out as much as the common logic between html and latex as possible, but I'm not sure if of how well I did that. One thing is that I'm really not satisfied with the following functor names Generator_setup, Generator_helper, Html_setup, Latex_setup, Html_generator and Latex_generator.

Additionally, here, or in a subsequent PR, it would be nice to have a stanza in the dune-project file that explains how to call some kind of latex command to build the latex manual as an option

Any early feedback would be helpful :)
In parallel I'll try to improve the latex story on odoc's side, in particular, trying to make progress on ocaml/odoc#123

PS: as a bonus, there's a tiny "fix". The usage of List.filter_map was unnecessary. Looks like the legacy of some previous version where there was something to filter

@giltho giltho force-pushed the latex-doc branch 2 times, most recently from c522f15 to f91c21f Compare January 21, 2022 01:02
@nojb
Copy link
Collaborator

nojb commented Jan 21, 2022

This PR aims at adding a _latex target to the @doc standard alias. There is no open issue containing the word latex so I thought I might just as well write a PR to get the discussion going.

Apologies, could you explain a bit more what you are proposing on this PR? Are you adding a new built-in alias to generate LaTeX? Are you modifying the existing @doc alias to generate LaTeX in addition to the HTML? Or something else? What is the _latex target you mention?

In general it seems sensible to support other output formats support by odoc apart from HTML.

@giltho
Copy link
Author

giltho commented Jan 21, 2022

Yes, sorry the wording was unclear
I am modifying the @doc alias to also generate LaTeX in addition to the HTML, it will be built in a _latex folder next to the_html folder.

@bobot
Copy link
Collaborator

bobot commented Jan 26, 2022

Note from meeting:

  • can't be be for dune 3.0 -> so 3.1 at least
  • restrict the feature to 3.1 and above
  • don't change the @doc alias @doc_latex
  • use directory target

@rgrinberg rgrinberg added this to the 3.1.0 milestone Feb 7, 2022
@rgrinberg rgrinberg added the accepted accepted proposals label Feb 7, 2022
@mndrix
Copy link
Contributor

mndrix commented Feb 11, 2022

Once this solidifies a bit, I'd like to submit a separate pull request to add a @doc_man alias to generate man pages.

@giltho
Copy link
Author

giltho commented Feb 17, 2022

I'm not really sure where to restrict the feature to dune > 3.1, where should I be adding a guard? In the gen_rules function?

@giltho
Copy link
Author

giltho commented Feb 18, 2022

Additionally, I'm trying to get things to work using directory targets, but I get

File "_doc/_html/scope1/_unknown_", line 1, characters 0-0:
Error: Rules with directory targets must be sandboxed.

Is there something specific I should be doing with directory targets?

@bobot
Copy link
Collaborator

bobot commented Feb 18, 2022

In the gen_rules function?

It is the easiest place. Features that have a specific stanza are restricted at parsing time, it is more static. But here since there is only an alias; gen_rules it is. Usually I like to have nice message for < 3.1 but I'm afraid to break people that already uses an @doc_latex alias., so you just have to bind the alias only for >= 3.1.

Is there something specific I should be doing with directory targets?

You should specify that the action with the directory target is sandoxed.

@giltho
Copy link
Author

giltho commented Apr 12, 2022

Update: I had a very intense deadline the past week and was not able to work on that for a while, I apologise
I did make some progress locally although I'm a bit stuck on some things, but I'm setting some time this week to finish this PR properly.

@giltho
Copy link
Author

giltho commented Apr 13, 2022

I've made some progress but I'm stuck with mainly one thing
at the moment, odoc doesn't handle html and latex generation the same way:

  • For html, it generates folders for each lib in a package, i.e. you'll get pkg/Lib/index.html for each lib. That means, for a given lib, I can consider pkg/Lib to be a directory target.
  • For latex, it generates a bunch of file called pkg/Lib.Module.texin the package folder.
    Because one package may have several libs, I can't consider that entire folder pkg is a target, and I don't know in advance the list of files it's going to create. There is only 1 file that I know will get created, which is pkg/Lib.tex for a give lib. I can choose this as a hidden target, but if I do, activating sandboxing will break the build, because that's the only file that will be kept.

Should I just choose use no_sandboxing or is there a better solution?

@rgrinberg rgrinberg modified the milestones: 3.1.0, 3.2.0 Apr 15, 2022
@rgrinberg rgrinberg modified the milestones: 3.2.0, 3.3.0 May 4, 2022
@Alizter Alizter mentioned this pull request May 11, 2022
@Alizter
Copy link
Collaborator

Alizter commented May 29, 2022

If it's any consolation, we went with @doc-latex for the analogous feature for Coq using coqdoc implemented in #3760.

@emillon emillon modified the milestones: 3.3.0, 3.4.0 Jun 14, 2022
@emillon emillon removed this from the 3.4.0 milestone Jul 19, 2022
@Alizter
Copy link
Collaborator

Alizter commented Dec 26, 2022

I have #6778 if you want to use that alias.

@Alizter
Copy link
Collaborator

Alizter commented Mar 11, 2023

Marking as draft since it is still in progress.

@Alizter Alizter marked this pull request as draft March 11, 2023 00:59
@rgrinberg
Copy link
Member

Please re-open if this is still relevant

@rgrinberg rgrinberg closed this Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted accepted proposals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants