Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[style] Maximum line length #1785

Merged
merged 8 commits into from
Apr 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 2 additions & 41 deletions docs/src/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,11 @@ Therefore, aim to keep line lengths under 80 characters by breaking lines
for maximum readability (examples are given in the [Line breaks](@ref) section),
but don't treat this as a hard rule.

We make exceptions for

- URLs
- path names
- long string constants not containing whitespace
- lines for which breaking over multiple lines worsens readability

#### Line breaks

The "readability" of a line is subjective. In this section we give suggestions
of good and bad style of how to break a line.
of good and bad style of how to break a line. These suggestions are inspired by
Google's [Python style guide](https://google.github.io/styleguide/pyguide.html).

When defining functions, align arguments vertically after the opening
parenthesis, or list all arguments on a new (indented) line.
Expand Down Expand Up @@ -210,24 +204,6 @@ a_very_long_variable_name = a_long_variable_name_with_arguments(
first_argument, second_argument)
```

Only use vertical alignment for function arguments. Don't use it in any other
situation.

Bad:
```julia
# Vertical alignment used in a non-function context. Also, indent is not a
# multiple of 4 spaces.
comprehension = [(first, second) for (first, second) in list_of_things
if isodd(first)]
```

Better
```julia
comprehension = [
(first, second) for (first, second) in list_of_things if isodd(first)
]
```

Don't use vertical alignment if it would be more readable to place all arguments
on a new indented line.

Expand Down Expand Up @@ -272,21 +248,6 @@ Better:
f(x) = 1 + x + x^2 + x^3 + x^3
```

Drop trailing parentheses onto a new line if it improves readability.

Good:
```julia
con_index = MOI.add_constraint(
backend(owner_model(variable)), MOI.SingleVariable(index(variable)), set)
```

Also good:
```julia
con_index = MOI.add_constraint(
backend(owner_model(variable)), MOI.SingleVariable(index(variable)), set
)
```

### Syntax

Julia sometimes provides equivalent syntax to express the same basic
Expand Down