Implement doc-comments and doc-comments-tag-only for every items#746
Implement doc-comments and doc-comments-tag-only for every items#746gpetiot merged 17 commits intoocaml-ppx:masterfrom
Conversation
|
Note that it is intentional that code items that are often longer than their docstrings, such as type declarations, structures, signatures, etc. are placed after their docstrings while code items that are commonly shorter than their docstrings are placed before their docstrings. This possibility should be preserved. I don't know if only 3 choices (current, all before, all after) are sufficient, or if finer granularity is better. |
b485d9d to
50c0301
Compare
|
I rebased this PR, after Guillaume's tidying. |
gpetiot
left a comment
There was a problem hiding this comment.
Some regressions to fix before merging (and don't forget to make fmt), but I agree with the idea.
src/Ast.ml
Outdated
| | _ -> false | ||
| end | ||
| (** Operations determining precedence and necessary parenthesization of | ||
| terms based on their super-terms. *) |
There was a problem hiding this comment.
module_expr_is_simple should not return true for this kind of module, we need to recursively call this function for Pmod_apply and Pmod_constraint (maybe other cases too if it makes sense, I didn't try it)
There was a problem hiding this comment.
I improved this. I added some arbitrary rules (eg. 2 or more with-constraints is not simple, extensions are not simple, etc..). What do you think ?
| end | ||
|
|
||
| module type A = B (** @open *) | ||
| module type A = B (** @open *) |
There was a problem hiding this comment.
Yes. This is the doc_comments_padding option. It was only used on type declarations until now.
@jberdine What do you think of this behavior ?
933dc52 to
0e1d621
Compare
gpetiot
left a comment
There was a problem hiding this comment.
I rebased it on master, minor comments about the simplicity of some items but otherwise looks good (no bug with test_branch).
| -> Normalize.docstring_error list | ||
| ; normalize: Conf.t -> 'a with_comments -> 'a | ||
| ; printast: Caml.Format.formatter -> 'a -> unit } | ||
| (** Operations on translation units. *) |
There was a problem hiding this comment.
Maybe we need to add a Ast.type_is_simple for cases like this?
|
I implemented |
The output looks better. We can merge as soon as you took care of:
|
|
I cleaned up the code. This is ready for review. |
Fix #723
This PR implements
doc-comments=before|afteranddoc-comments-tag-only=default|fitfor every structure, signature and class items:Previously,
doc-comments=afterwas only implemented forvalandexternalitemsand
doc-comments-tag-only=fitforinclude,openand one-linemoduleitems.Also silently implement
doc-comments-paddingfor tag-only comments.Docstring are always placed before in some cases:
letbindings