Skip to content

Do not escape @raise argument in docstrings#1391

Merged
gpetiot merged 4 commits intoocaml-ppx:masterfrom
gpetiot:fix-docstring-escape
Jun 23, 2020
Merged

Do not escape @raise argument in docstrings#1391
gpetiot merged 4 commits intoocaml-ppx:masterfrom
gpetiot:fix-docstring-escape

Conversation

@gpetiot
Copy link
Copy Markdown
Collaborator

@gpetiot gpetiot commented Jun 15, 2020

Fix #1390 (not satisfied with the function name though)

@gpetiot gpetiot requested review from Julow and jberdine June 15, 2020 17:43
Copy link
Copy Markdown
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 this is not the right fix. For example, it changes this comment:

(** \[abc\] *)

Odoc parses the argument of @raise in an adhoc way: https://github.com/ocaml/odoc/blob/b6704fb3a3868a93fe7996235105d750ecefae07/src/parser/lexer.mll#L368
Escaping can't work, we should just not call ensure_escape here.
It might be the case for @param and most other tags too.

@gpetiot gpetiot changed the title Fix docstring escape, only escape the contents and not the delimiters Do not escape @raise argument in docstrings Jun 22, 2020
@gpetiot
Copy link
Copy Markdown
Collaborator Author

gpetiot commented Jun 22, 2020

Good catch, I removed the escaping for this tag. I didn't change the way the other tags are formatted for now, is there a documentation more precise than http://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#ss:ocamldoc-tags ? (besides the code) Should we understand that text should be escaped, but nothing else? (string, id, exc, etc.)

Copy link
Copy Markdown
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.
I'm not aware of a better documentation.

Should we understand that text should be escaped, but nothing else? (string, id, exc, etc.)

I think this is correct. I'll do some testing and submit a PR

@gpetiot gpetiot merged commit 8764f2f into ocaml-ppx:master Jun 23, 2020
@gpetiot gpetiot deleted the fix-docstring-escape branch June 23, 2020 16:57
Julow added a commit to Julow/ocamlformat that referenced this pull request Jun 23, 2020
Follow-up of ocaml-ppx#1391

The first arguments of some tags are parsed verbatim and must not be escaped.
Julow added a commit that referenced this pull request Jul 8, 2020
* Fix escaping of other Odoc tags

Follow-up of #1391

The first arguments of some tags are parsed verbatim and must not be escaped.
emillon added a commit to emillon/opam-repository that referenced this pull request Aug 6, 2020
CHANGES:

#### Changes

  + Do not break inline elements such as `{i blah}` in docstrings (ocaml-ppx/ocamlformat#1346, @jberdine)

  + Distinguish hash-getter from hash-comparison infix operators. Operators of the form `#**#` or `#**.` where `**` can be 0 or more operator chars are considered getter operators and are not surrounded by spaces, as opposed to regular infix operators (ocaml-ppx/ocamlformat#1376, @gpetiot)

  + Type constraint on return type of functions is now always printed before the function body (ocaml-ppx/ocamlformat#1381, ocaml-ppx/ocamlformat#1397, @gpetiot)

#### Bug fixes

  + Restore previous functionality for pre-post extension points (ocaml-ppx/ocamlformat#1342, @jberdine)

  + Fix extra break before `function` body of a `fun` (ocaml-ppx/ocamlformat#1343, @jberdine)
    Indent further args of anonymous functions (ocaml-ppx/ocamlformat#1440, @gpetiot)

  + Do not clear the emacs `*compilation*` buffer on successful reformat (ocaml-ppx/ocamlformat#1350, @jberdine)

  + Fix disabling with attributes on OCaml < 4.08 (ocaml-ppx/ocamlformat#1322, @emillon)

  + Preserve unwrapped comments by not adding artificial breaks when `wrap-comments=false` and `ocp-indent-compat=true` are set to avoid interfering with ocp-indent indentation. (ocaml-ppx/ocamlformat#1352, @gpetiot)

  + Break long literal strings at the margin (ocaml-ppx/ocamlformat#1367, @gpetiot)

  + Break after a multiline argument in an argument list (ocaml-ppx/ocamlformat#1360, @gpetiot)

  + Remove unnecessary parens around object (ocaml-ppx/ocamlformat#1379, @gpetiot)

  + Fix placement of comments on constants (ocaml-ppx/ocamlformat#1383, @gpetiot)

  + Do not escape arguments of some Odoc tags (ocaml-ppx/ocamlformat#1391, 1408, @gpetiot, @Julow)
    The characters `[]{}` must not be escaped in the arguments of `@raise`, `@author`, `@version` and others.

  + Fix missing open line between multi-line let-binding with poly-typexpr (ocaml-ppx/ocamlformat#1372, @jberdine)

  + Remove trailing space after expression when followed by an attribute and break before attributes attached to multi-line phrases (ocaml-ppx/ocamlformat#1382, @gpetiot)

  + Do not add a space to minimal comments `(* *)`, `(** *)` and `(*$ *)` (ocaml-ppx/ocamlformat#1407, @gpetiot)

  + Fix attributes position in labelled arguments type (ocaml-ppx/ocamlformat#1434, @gpetiot)

  + Add missing parens around type annotation in anonymous function (ocaml-ppx/ocamlformat#1433, @gpetiot)

  + Fix alignment of 'then' keyword in parenthesised expression (ocaml-ppx/ocamlformat#1421, @gpetiot)

#### New features

  + Support quoted extensions (added in ocaml 4.11) (ocaml-ppx/ocamlformat#1405, @gpetiot)

  + Recognise eliom file extensions (ocaml-ppx/ocamlformat#1430, @jrochel)
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.

Bug: unstable docstring formatting with @raise attribute

3 participants