Skip to content
This repository was archived by the owner on Aug 13, 2023. It is now read-only.

Add documentation for -ppx#5

Closed
whitequark wants to merge 8 commits intoocaml:trunkfrom
whitequark:trunk
Closed

Add documentation for -ppx#5
whitequark wants to merge 8 commits intoocaml:trunkfrom
whitequark:trunk

Conversation

@whitequark
Copy link
Copy Markdown
Member

One thing that I'm not sure of is whether to include documentation for Ast_helper and most of its siblings in the pdf (also text &c) manual. Ast_helper alone takes twenty pages. This is not a problem for HTML manual.

I frequently look up signatures in the HTML manual, so it's useful even if it's not documented. However I'm not sure if that is the case with linear manuals.

This style is missing even from Debian's texlive-latex-extra.
This commit properly runs local ocamldoc via an explicit ocamlrun
invocation, as already done in manual/library/Makefile.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder to which extent it wouldn't be better to just show the ocamlfind way directly. Or, to respect the manual tradition to be self-contained and teach us the hard way, at least follow it with the ocamlfind commands people will actually use (and adapt in their build systems).

(This also has technical advantages: the widely-documented habit to use +camlp4 has become problematic now that camlp4 is split outside the distribution, so de-emphasizing the +foo feature seems reasonable to avoid such issues in the future.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I will show ocamlfind commands before the hard way ones.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Documenting more modules is a mildly controversial change. I personally think it's a good idea, but maybe we should be modest in the amount of modules we document. Here is my understanding of the space, in decreasing order of (sujective) importance:

  1. Ast_{helper,mapper} should clearly go in
  2. Parsetree would be a natural choice given the excellent documentation work Alain has done (why is parsetree.mli seemingly missing here?)
  3. Asttypes, Longident and Location are currently necessary to be construct ASTs
  4. Parse and Pprintast are not necessary for all uses of -ppx, but could be mildly useful for some hackish purposes
  5. I think we don't need Lexer and Printast

I think it would be reasonable to have (1,2,3) in, and maybe leave (4) aside for the moment -- we can always add more later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The problem with Ast_helper is that it's basically ~20 pages of undocumented function signatures. I'm not sure how I feel about adding it to the manual.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then maybe we could start slow and recommend that the interested people go read the .mli files directly. We could here just briefly describe the various files and their purpose, without including any generated HTML documentation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, I disagree completely. Generated HTML documentation would be incredibly useful; you don't see these things unless you go through the link and it is immeasurably better than browsing .mli file in every way. I strongly prefer as much .mli files going into HTML as possible.

I'm only worried about pdf/text manuals here. So, I think it is a good idea to only include the better-documented parts into the pdf/text manual--with your points 1-3, it would be everything except Ast_helper.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll ask around for opinions on this, but for now I'm fine with going with what you think is best.

I still don't see the point of exposing Lexer, which is ugly as hell.

There would be some (minor) work to do to improve pprintast.mli if/when it is exposed, putting the printer class at the end (most users don't need it) and briefly describing the purpose in a top comment. (Not saying you personally should do this.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't have many problems hiding Lexer (it is ugly as hell) and Printast (a better Printast is one made with [@@deriving show] :p) for now.

Pprintast is very useful for printing error messages, I have used it several times in my ppx extensions. Parse is useful for things like interactive toplevels and such. I think it should be present for completeness.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we agree (I looked at Printast and its interface is so simple and clean that I have no issue with including it; I expect most people to use -dparsetree directly, though).

@gasche
Copy link
Copy Markdown
Member

gasche commented Oct 4, 2014

Maybe compilerlibs.etex should be renamed compilerlibs-frontend.etex: there are more things in compilerlibs than what's needed for -ppx, and we could think of documenting them in some ideal future world where the OCaml compiler exposes a conveniently designed API. It would then be natural to use the compilerlibs.etex for this purpose. I don't really care about the name of the source files, but we should make sure that there is a forward-compatibility plan for the generated HTML anchors in the manual (I mean make it such that the URL using to describe just the syntax/ part today still work in ten years and points to the same section).

@whitequark
Copy link
Copy Markdown
Member Author

The HTML file is currently called parsing.html and it is independent from the name of the tex file. The filename is derived from the explicit specification in the tex source.

@agarwal
Copy link
Copy Markdown
Member

agarwal commented Oct 4, 2014

Regarding the inclusion of large HTML documents, why not add them to ocaml.org. Since these are part of official releases, we could put them under URLs like http://ocaml.org/releases/4.02.0/docs. That way you don't have to worry about size. Include hundreds of pages if you want and refer to the URLs from the manual.

@whitequark
Copy link
Copy Markdown
Member Author

@agarwal HTML document size is not an issue at all. I was only concerned that the PDF was growing by ~20 pages in size without much benefit.

@whitequark
Copy link
Copy Markdown
Member Author

@gasche I've updated the PR according to your feedback.

@agarwal
Copy link
Copy Markdown
Member

agarwal commented Oct 4, 2014

@whitequark Right, I also meant size in the sense of bloating the manual. The manual should have the same contents whether in HTML or PDF format. Thus, if you don't want to bloat the PDF version, which I agree you shouldn't, then I don't think the extra pages should be in the HTML version either. Then the question is where to put the pages, and I thought ocaml.org would be a good choice. Anyway, just my 2 cents.

@whitequark
Copy link
Copy Markdown
Member Author

@agarwal I expect that PDF and HTML versions will be used differently. If you insist that the versions should be kept coherent, then I think we should bite the bullet and include Ast_helper in PDF manual. Putting the documentation in several separate places is too fragile, not to mention it will then not be available offline, potential link breakage, and so on.

@agarwal
Copy link
Copy Markdown
Member

agarwal commented Oct 4, 2014

If you insist that the versions should be kept coherent

I don't insist, but it does seem odd to me.

@whitequark
Copy link
Copy Markdown
Member Author

@agarwal I just can't easily imagine someone using the PDF manual to look up function signatures. Howver this is something I do with HTML manual often. If you think this would be something the readers want, we should include Ast_helper.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I feel like you should give a sort of "reading order" (Ast_mapper first, for ppxs basic blocs, then Parsetree to see what the AST look like, then Ast_helper, to actually build pieces of asts).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This section is not solely about -ppx rewriters, and the documentation for -ppx option refers to Ast_mapper directly.

@gasche
Copy link
Copy Markdown
Member

gasche commented Oct 4, 2014

I'm rather satisfied with the result.

@agarwal
Copy link
Copy Markdown
Member

agarwal commented Oct 4, 2014

If you think this would be something the readers want, we should include Ast_helper.

I doubt they would.

@gasche
Copy link
Copy Markdown
Member

gasche commented Oct 7, 2014

Merged in the manual. There is a dangling reference problem in cmds.etex (HTML rendering only) that is still to be fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants