mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-10 12:28:25 +00:00
Switch from rumdl disable to more general fmt annotations (#8091)
The tool actually doing the formatting of our fenced code regions isn't `rumdl`, but `ruff` which now supports that (nice!). It needs a different, more general marker though. Hopefully other language formatters that grow this support also respect the same annotation. This seems preferable to disabling `rumdl` as we are fine with it moving the fenced code region around as part of formatting, it is only the formatting _within_ the code region that should be preserved.
This commit is contained in:
1 parent
28d15a6e78
commit
45ed77af3b
1 file changed
+12
-6
@@ -83,14 +83,16 @@ In Python, a line is a
|
||||
parentheses are an idiomatic way to create multi-line statements. Semicolons may
|
||||
be used to explicitly separate statements. For example:
|
||||
|
||||
<!-- rumdl-disable -->
|
||||
<!-- fmt:off -->
|
||||
|
||||
```python
|
||||
value = (
|
||||
"text"
|
||||
)
|
||||
a = 1; b = 2; c = 3
|
||||
```
|
||||
<!-- rumdl-enable -->
|
||||
|
||||
<!-- fmt:on -->
|
||||
|
||||
Swift allows some statements to wrap lines, although multiple statements on the
|
||||
same line (`x = 1 x = 1`) require a semicolon. The detailed rules aren't
|
||||
@@ -103,7 +105,8 @@ documents that line-breaks are treated as whitespace. However, there are
|
||||
observable ways the behavior can lead to small mistakes; these may may often be
|
||||
caught by the compiler, but will sometimes be missed. For example:
|
||||
|
||||
<!-- rumdl-disable -->
|
||||
<!-- fmt:off -->
|
||||
|
||||
```swift
|
||||
// One statement in Swift, but two in Python and Kotlin.
|
||||
var x = 1
|
||||
@@ -118,7 +121,8 @@ Make() ()
|
||||
Make()
|
||||
()
|
||||
```
|
||||
<!-- rumdl-enable -->
|
||||
|
||||
<!-- fmt:on -->
|
||||
|
||||
Kotlin permits a newline to be used to terminate statements instead of a
|
||||
semicolon. Kotlin's grammar
|
||||
@@ -126,14 +130,16 @@ semicolon. Kotlin's grammar
|
||||
the places where newlines can appear (see mentions of `NL` in the grammar), and
|
||||
doesn't allow newlines in places where they would introduce ambiguity.
|
||||
|
||||
<!-- rumdl-disable -->
|
||||
<!-- fmt:off -->
|
||||
|
||||
```kotlin
|
||||
// This is unambiguously parsed as two statements, because
|
||||
// a newline is not permitted before a `+` operator.
|
||||
var x = 1
|
||||
+ 1
|
||||
```
|
||||
<!-- rumdl-enable -->
|
||||
|
||||
<!-- fmt:on -->
|
||||
|
||||
In JavaScript and TypeScript, semicolons are part of the formal syntax, and
|
||||
ECMAScript provides
|
||||
|
||||
Reference in new issue
Block a user