* Add git-runic script based on git-clang-format.
* Add some docs about git-runic integration.
---------
Co-authored-by: Tim Besard <tim.besard@gmail.com>
This patch adds a quick start section to the README with copy-pasteable
setup commands. Closes#80. Also removes some discussion about shell
alias and the `-m` flag and instead recommend using the shell script
wrapper.
This patch implements a new command line argument `--verbose` which
enables verbose ouutput. Runic is now silent by default so `--verbose`
re-enables the verbose file printing from previous releases.
This patch also adds a progress prefix to each file of the form
`[file/nfiles]` to verbose output.
This patch make some changes to the README:
- Use name instead of URL for installation instructions
- Create a new section on adopting Runic for a code base
- Add a suggested README badge (closes#108).
Behavior of `..` is more tricky than `:`. Sometimes the space is
required like in e.g. `a .. -b` which, formatted as `a..-b`, would give
`ParseError: invalid operator ..-`.
This reverts commit 7d26dcf268.
This patch relaxes the toggle comments `# runic: (off|on)` such that the
comment may contain more than just the toggle comment. This is useful
when combining with other "pragmas" such as e.g. Literate.jl line
filters. For example, the following now also toggles formatting:
```julia
\# runic: off #src
not = formatted #src
\# runic: on #src
```
This patch make sure that function and macro definitions, as well as
do-blocks, end with an explicit `return` statement before the last
expression in the body. The following exceptions are made:
- If the last expression is a `for` or `while` loop (which both always
evaluate to `nothing`) `return` is added *after* the loop.
- If the last expression is a `if` or `try` block the `return` is only
added in case there is no `return` inside any of the branches.
- If the last expression is a `let` or `begin` block the `return` is
only added in case there is no `return` inside the block.
- If the last expression is a macro call the `return` is only added in
case there is no `return` inside the macro.
- If the last expression is a function call, and the function name is
`throw`, `rethrow`, or `error`, no `return` is added. This is because
it is pretty obvious that these calls terminate the function without
the explicit `return`.
Since adding `return` changes the expression that a macro will see, this
rule is disabled for function definitions inside of macros with the
exception of some known ones from Base (e.g. `@inline`, `@generated`,
...).
Closes#43.
This patch adds trimming of trailing whitespace inside of comments in
addition to the trimming of trailing whitespace in code. Note that
trailing whitespace inside of multiline is not trimmed since doing so
would change the content of the string.
Closes#50.
This patch implements `# runic: on` and `# runic: off` toggle comments
that can be included in the source to toggle formatting on/off.
The two comments i) must be placed on their own lines, ii) must be on
the same level in the expression tree, and iii) must come in pairs. An
exception to condition iii) is made for top level toggle comments so
that formatting for a whole file can be disabled by a `# runic: off`
comment at the top without having to add one also at the end of the
file.
For compatibility with JuliaFormatter, `#! format: (on|off)` is also
supported but it is not possible to pair e.g. a `# runic: off` comment
with a `#! format: on` comment.
Closes#12, closes#41.
Octal formatting isn't as useful as hex formatting and it is also value
dependent (not just string-length dependent) which makes it a bit odd.
Octals are also very rare. One of the more common ones are filemodes and
for that case e.g. 0o755 looks better than 0o000755. Closes#40.