Skip to content

Releases: ocaml-ppx/ocamlformat

0.15.0

06 Aug 16:26
Compare
Choose a tag to compare

CHANGES:

Changes

  • Do not break inline elements such as {i blah} in docstrings (#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 (#1376, @gpetiot)

  • Type constraint on return type of functions is now always printed before the function body (#1381, #1397, @gpetiot)

Bug fixes

  • Restore previous functionality for pre-post extension points (#1342, @jberdine)

  • Fix extra break before function body of a fun (#1343, @jberdine)
    Indent further args of anonymous functions (#1440, @gpetiot)

  • Do not clear the emacs *compilation* buffer on successful reformat (#1350, @jberdine)

  • Fix disabling with attributes on OCaml < 4.08 (#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. (#1352, @gpetiot)

  • Break long literal strings at the margin (#1367, @gpetiot)

  • Break after a multiline argument in an argument list (#1360, @gpetiot)

  • Remove unnecessary parens around object (#1379, @gpetiot)

  • Fix placement of comments on constants (#1383, @gpetiot)

  • Do not escape arguments of some Odoc tags (#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 (#1372, @jberdine)

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

  • Do not add a space to minimal comments (* *), (** *) and (*$ *) (#1407, @gpetiot)

  • Fix attributes position in labelled arguments type (#1434, @gpetiot)

  • Add missing parens around type annotation in anonymous function (#1433, @gpetiot)

  • Fix alignment of 'then' keyword in parenthesised expression (#1421, @gpetiot)

New features

0.14.3

22 Jul 12:59
Compare
Choose a tag to compare

CHANGES:

Changes

  • No functional changes from 0.14.2. The goal of this release is to be
    compatible with base and stdio v0.14.0.

  • Backport the following PRs:

    • #1386 - Update opam metadata
    • #1396 - Add compatibility with base.v0.14.0
    • #1399 - Allow stdio.v0.14

0.14.2

11 May 12:05
f0f9606
Compare
Choose a tag to compare

CHANGES:

Changes

  • Merge doc-comments-val option with doc-comments. The placement of documentation comments on val and external items is now controled by doc-comments.

    • doc-comments=after becomes doc-comments=after-when-possible to take into account the technical limitations of ocamlformat;
    • doc-comments=before is unchanged;
    • doc-comments-val is now replaced with doc-comments
      To reproduce the former behaviors
      • doc-comments=before + doc-comments-val=before: now use doc-comments=before;
      • doc-comments=before + doc-comments-val=after: now use doc-comments=before-except-val;
      • doc-comments=after + doc-comments-val=before: this behavior did not make much sense and is not available anymore;
      • doc-comments=after + doc-comments-val=after: now use doc-comments=after-when-possible.

(#1358) (Josh Berdine, Jules Aguillon, Guillaume Petiot)

This reverts changes introduced in 0.14.1 (#1335) and 0.14.0 (#1012).

0.14.1

14 Apr 15:39
Compare
Choose a tag to compare

CHANGES:

Changes

  • The default for doc-comments is changed to after (#1335) (Jules Aguillon)
    This reverts a change introduced in 0.14.0 (#1012).

  • Revert deprecation of the doc-comments option (#1331) (Jules Aguillon)
    This reverts a change introduced in 0.14.0 (#1293).

0.14.0

02 Apr 14:56
Compare
Choose a tag to compare

CHANGES:

New features

  • Add an option --format-invalid-files to print unparsable parts of the input as verbatim text. This feature is still experimental. (#1026) (Guillaume Petiot)

  • Support multi-indices extended indexing operators (#1279, #1277) (Jules Aguillon, Guillaume Petiot)
    This feature has been added in OCaml 4.10.0

  • Handle OCaml 4.10.0 AST (#1276) (Guillaume Petiot)

  • Preserve functor syntax for consistency (#1312) (Guillaume Petiot)
    Previously both functor syntax: module M = functor (K : S) -> struct end and module M (K : S) = struct end would be formatted as the latter, the original syntax is now preserved.

Changes

  • Add the option doc-comments-val=before|after (#1012) (Jules Aguillon)
    This option set the placement of documentation comment on val and external only.
    It is set to after by default.

  • The default for doc-comments is changed from after to before (#1012, #1325) (Jules Aguillon)
    This affects both conventional (default) and ocamlformat profiles.

  • Some options are now deprecated:

    • doc-comments (#1293, #1012)
      This option depends on a flawed heuristic.
      It is replaced by doc-comments-val for val and external declarations.
      There is no equivalent to this option in the general case.
    • escape-chars, escape-strings and extension-sugar (#1293)
      These options are rarely used and their default behavior is considered to be the right behavior.
  • Add space between row_field attributes and the label or arguments, to be
    consistent with the non-polymorphic case. (#1299) (Craig Ferguson)

Bug fixes

  • Fix missing parentheses around let open (#1229) (Jules Aguillon)
    eg. M.f (M.(x) [@attr]) would be formatted to M.f M.(x) [@attr], which would crash OCamlformat

  • Remove unecessary parentheses with attributes in some structure items:

    • extensions and eval items (#1230) (Jules Aguillon)
      eg. the expression [%ext (() [@attr])] or the structure item (() [@attr]) ;;
    • let _ = ... constructs (#1244) (Etienne Millon)
  • Fix some bugs related to comments:

    • after a function on the rhs of an infix (#1231) (Jules Aguillon)
      eg. the comment in (x >>= fun y -> y (* A *)) would be dropped
    • in module unpack (#1309) (Jules Aguillon)
      eg. in the module expression module M = (val x : S (* A *))
  • Fix formatting of empty signature payload [%a:] (#1236) (Etienne Millon)

  • Fix parenthesizing when accessing field of construct application (#1247) (Guillaume Petiot)

  • Fix formatting of attributes on object overrides {< >} (#1238) (Etienne
    Millon)

  • Fix attributes on coercion (#1239) (Etienne Millon)

  • Fix formatting of attributes on packed modules (#1243) (Etienne Millon)

  • Fix parens around binop operations with attributes (#1252, #1306) (Guillaume Petiot, Craig Ferguson)

  • Remove unecessary parentheses in the argument of indexing operators (#1280) (Jules Aguillon)

  • Retain attributes on various AST nodes:

    • field set expressions, e.g. (a.x <- b) [@a] (#1284) (Craig Ferguson)
    • instance variable set expressions, e.g. (a <- b) [@a] (#1288) (Craig Ferguson)
    • indexing operators, e.g. (a.(b)) [@a] (#1300) (Craig Ferguson)
    • sequences, e.g. (a; b) [@a] (#1291) (Craig Ferguson)
  • Avoid unnecessary spacing after object types inside records and polymorphic variants,
    e.g. {foo : < .. > [@a]} and { foo : < .. > } (#1296) (Craig Ferguson)

  • Fix missing parentheses around tuples with attributes. (#1301) (Craig Ferguson)
    Previously, f ((0, 0) [@a]) would be formatted to f (0, 0) [@a], crashing OCamlformat.

  • Avoid emitting >] when an object type is contained in an extension point
    or attribute payload (#1298) (Craig Ferguson)

  • Fix crash on the expression (0).*(0) (#1304) (Jules Aguillon)
    It was formatting to 0.*(0) which parses as an other expression.

  • Preserve empty doc-comments syntax. (#1311) (Guillaume Petiot)
    Previously (**) would be formatted to (***).

  • Do not crash when a comment contains just a newline (#1290) (Etienne Millon)

  • Handle lazy patterns as arguments to class (#1289) (Etienne Millon)

  • Preserve cinaps comments containing unparsable code (#1303) (Jules Aguillon)
    Previously, OCamlformat would fallback to the "wrapping" logic, making the comment
    unreadable and crashing in some cases.

  • Fix normalization of attributes, fixing the docstrings in attributes (#1314) (Guillaume Petiot)

  • Add missing parentheses around OR-patterns with attributes (#1317) (Guillaume Petiot)

  • Fix spacing inside parens for symbols when the spacing was handled by the englobing exp (#1316) (Guillaume Petiot)

  • Fix invalid (unparsable) docstrings (#1315) (Guillaume Petiot)
    When parsing a comment raises an error in odoc, it is printed as-is.

  • Fix parenthesizing of optional arguments rebound to non-variables, e.g. let f ?a:(A) = () rather than the unparsable let f ?a:A = () (#1305) (Craig Ferguson)

0.13.0

30 Jan 10:36
7b58536
Compare
Choose a tag to compare

CHANGES:

New features

  • Add an option --margin-check to emit a warning if the formatted output exceeds the margin (#1110) (Guillaume Petiot)
  • Preserve comment indentation when wrap-comments is unset (#1138, #1159) (Jules Aguillon)
  • Improve error messages (#1147) (Jules Aguillon)
  • Display standard output in the emacs plugin even when ocamlformat does not fail (#1189) (Guillaume Petiot)

Removed

  • Remove ocamlformat_reason (#254, #1185) (Etienne Millon).
    This tool has never been released to opam, has no known users, and overlaps
    with what refmt can do.
  • Remove ocamlformat-diff (#1205) (Guillaume Petiot)
    This tool has never been released to opam, has no known users, and overlaps
    with what merge-fmt can do.

Packaging

  • Work with base v0.13.0 (#1163) (Jules Aguillon)

Bug fixes

  • Fix placement of comments just before a '|' (#1203) (Jules Aguillon)
  • Fix build version detection when building in the absence of a git root (#1198) (Anil Madhavapeddy)
  • Fix wrapping of or-patterns in presence of comments with break-cases=fit (#1167) (Jules Aguillon)
    This also fixes an unstable comment bug in or-patterns
  • Fix an unstable comment bug in variant declarations (#1108) (Jules Aguillon)
  • Fix: break multiline comments (#1122) (Guillaume Petiot)
  • Fix: types on named arguments were wrapped incorrectly when preceding comments (#1124) (Guillaume Petiot)
  • Fix the indentation produced by max-indent (#1118) (Guillaume Petiot)
  • Fix break after Psig_include depending on presence of docstring (#1125) (Guillaume Petiot)
  • Remove some calls to if_newline and break_unless_newline and fix break before closing brackets (#1168) (Guillaume Petiot)
  • Fix unstable cmt in or-pattern (#1173) (Guillaume Petiot)
  • Fix location of comment attached to the underscore of an open record (#1208) (Guillaume Petiot)
  • Fix parentheses around optional module parameter (#1212) (Christian Barcenas)
  • Fix grouping of horizontally aligned comments (#1209) (Guillaume Petiot)
  • Fix dropped comments around module pack expressions (#1214) (Jules Aguillon)
  • Fix regression of comment position in list patterns (#1141) (Josh Berdine)
  • Fix: adjust definition of Location.is_single_line to reflect margin (#1102) (Josh Berdine)

Documentation

  • Fix documentation of option version-check (#1135) (Wilfred Hughes)
  • Fix hint when using break-separators=after-and-docked (#1130) (Greta Yorsh)

0.12

04 Nov 17:12
80709d9
Compare
Choose a tag to compare

CHANGES:

Changes

  • Set "conventional" as the default profile (#1060) (Guillaume Petiot)
    This new profile is made to better match the most used style and is encouraged.
    To continue using the previous default, use profile = ocamlformat in your .ocamlformat.
  • CLI: Allow both values of boolean options (#1062) (Jules Aguillon)
    Now, both --opt and --no-opt` are available on the CLI for any boolean option "opt".
    Previously, only one of them were available depending on the default value.
  • Auto mode for break-string-literals (#1057) (Guillaume Petiot)
    wrap, newlines and newlines-and-wrap values of break-string-literals are removed.
    auto replaces them, it is equivalent to newlines-and-wrap.
  • Dock collection brackets (#1014) (Guillaume Petiot)
    after-and-docked value of break-separators is removed and is replaced by a new dock-collection-brackets option.
  • Preserve begin and end keywords in if-then-else (#978) (Jules Aguillon)
    Previously, begin/end keywords around if-then-else branches were turned into parentheses.

New features

  • Give a hint when warning 50 is raised (#1111) (Guillaume Petiot)
  • Add a message when a config value is removed (#1089) (Etienne Millon)
    Explain what replaces removed options and avoid printing a parsing error.
  • Implement sequence-blank-line=preserve-one for let bindings (#1077) (Jules Aguillon)
    Preserve a blank line after let .. in when sequence-blank-line set to preserve-one.
    Previously, only blank lines after ; could be preserved.
  • Parse toplevel directives (#1020) (Jules Aguillon)
    Allow #directives in .ml files.
    Previously, files containing a directive needed to be parsed as "use file".
    The "use file" mode is removed and --use-file is now the same as --impl.
  • Don't require --name, require kind, forbid --inplace, allow --check, make --enable-outside-detected-project implicit when reading from stdin (#1018) (Guillaume Petiot)
  • Parse code in docstrings (#941) (Guillaume Petiot)
    Format OCaml code in cinaps-style comments (*$ code *) and code blocks in documentation comments (** {[ code ]} *).
  • Parse documentation comments with Odoc (#721) (Jules Aguillon)
    Formatting of documentation comments is more robust and support newer Odoc syntaxes.
    Internally, Odoc replaces Octavius as the documentation parser.

Bug fixes

  • Fix unstabilizing comments on assignments (#1093) (Guillaume Petiot)
  • Fix the default value documentation for max-indent (#1105) (Guillaume Petiot)
  • Fix closing parenthesis exceeding the margin in function application (#1098) (Jules Aguillon)
  • Missing break before attributes of Pmty_with (#1103) (Josh Berdine)
  • Fix closing quote exceeding the margin (#1096) (Jules Aguillon)
  • Fix break before the closing bracket of collections (exceeding the margin) (#1073) (Guillaume Petiot)
  • Fix precedence of Dot wrt Hash (#1058) (Guillaume Petiot)
  • Fix break in variant type definition to not exceed the margin (#1064) (Guillaume Petiot)
  • Fix newlines and indentation in toplevel extension points (#1054) (Guillaume Petiot)
  • Fix placement of doc comments around extensions (#1052) (Jules Aguillon)
  • Inline extensions that do not break (#1050) (Guillaume Petiot)
  • Add missing cut before attributes in type declarations (#1051) (Guillaume Petiot)
  • Fix alignment of cases (#1046) (Guillaume Petiot)
  • Fix blank line after comments at the end of lists (#1045) (Guillaume Petiot)
  • Fix indexing operators precedence (#1039) (Jules Aguillon)
  • Fix dropped comment after infix op (#1030) (Guillaume Petiot)
  • No newline if the input is empty (#1031) (Guillaume Petiot)
  • Fix unstable comments around attributes (#1029) (Guillaume Petiot)
  • Fix extra blank line in sequence (#1021) (Jules Aguillon)
  • Check functor arguments when computing placement of doc comments (#1013) (Jules Aguillon)
  • Fix indentation of labelled args (#1006) (Guillaume Petiot)
  • Fix linebreak between or-cases with comments when break-cases=all (#1002) (Guillaume Petiot)
  • Fix unstable unattached doc comment in records (#998) (Jules Aguillon)
  • Fix string literal changed (#995) (Jules Aguillon)
  • Fix type variable (#996) (Jules Aguillon)
  • Fix crash on extension sequence (#992) (Guillaume Petiot)
  • Fix position of expressions regarding of comments in infix-op expressions (#986) (Guillaume Petiot)
  • Escape special characters in external declaration (#988) (Jules Aguillon)
  • Fix parens around constrained expr with attrs (#987) (Guillaume Petiot)
  • Fix the margin, and correctly breaks comments (#957) (Guillaume Petiot)
  • Fix formatting of custom indexing operators (#975) (Guillaume Petiot)
  • Fix position of comments of labelled arrow types (#976) (Guillaume Petiot)
  • No box around inline odoc styles (#971) (Guillaume Petiot)
  • Fix boxing of collection expressions/patterns (#960) (Guillaume Petiot)
  • Fix crash on record expr with pack fields (#963) (Jules Aguillon)
  • Fix letop in subexpr (#956) (hhugo)

Internal

  • Take file kind from --name when formatting stdin (#1119) (Jules Aguillon)
  • Make Fmt.t abstract (#1109) (Jules Aguillon)
  • Future-proof Fmt API in case Fmt.t goes abstract (#1106) (Etienne Millon)
  • Future-proof Fmt API in case Fmt.t goes abstract (#1106) (Etienne Millon)
  • Optional names for formatting boxes in debug output (#1083) (Guillaume Petiot)
  • Check ocamlformat error codes in the testsuite (#1084) (Etienne Millon)
  • Clean Translation_unit (#1078) (Guillaume Petiot)
  • Use dune file generation in test/passing/dune (#1082) (Etienne Millon)
  • CI: factorize tests and check reason build (#1079) (Guillaume Petiot)
  • Use short form for action in src/dune (#1076) (Etienne Millon)
  • Cleanup sequence_blank_line (#1075) (Jules Aguillon)
  • CI: use a script travis-ci.sh to simplify .travis.yml (#1063) (Guillaume Petiot)
  • Remove utility functions from Fmt_ast (#1059) (Guillaume Petiot)
  • CI: use opam-2.0.5 in Travis (#1044) (Anton Kochkov)
  • CI: check the build with OCaml 4.07.1 and 4.08.0 (#1036) (Jules Aguillon)
  • Use the same sets of options for both branches by default in test_branch.sh (#1033) (Guillaume Petiot)
  • Fix test_branch.sh and CI checking of CHANGES.md (#1032, #1034) (Jules Aguillon)
  • Fix flag of git-worktree in test_branch.sh and bisect.sh (#1027) (Guillaume Petiot)
  • Remove the bisect_ppx dependency and clean the Makefile (#1005) (Jules Aguillon)
  • Use a CHANGES.md log file again (#1023) (Guillaume Petiot)
  • Support OCaml 4.09.0 (add the odoc.1.4.2 dependency) (#1024) (Guillaume Petiot)
  • Update labels of issue templates (#1017) (Guillaume Petiot)
  • Update labels in CONTRIBUTING.md (#1007) (Guillaume Petiot)
  • Allow to ignore invalid options (#984) (hhugo)
    The --ignore-invalid-option flag is added to ignore invalid options in .ocamlformat files.
  • Improve the documentation of --doc-comments (#982) (Jules Aguillon)
  • Remove symbolic links and change naming convention of tests (#980) (Guillaume Petiot)
  • Change the type of fmt_code (#974) (Guillaume Petiot)
  • Simplify Makefile (#973) (hhugo)
  • Dune should not be flagged as a build dep anymore (#954) (Guillaume Petiot)