Comments (4)
Comments are entirely up to the user, sometimes the user prefers to put one space and sometimes two spaces in the same file.
So in my opinion we should not control it.
from swift-format.
@HassanTaleb90 @allevato, in some situations for structured comments (DocC) format does affect how they would parse and get processed. Wrong formatting of a doc comment might result in broken documentation.
That would be a different rule from the one @ErciliaR suggests here. There must've been another discussion on this that I missed — feel free to "well actually" and link me to it!
I wonder, how do we make decisions about adding rules? They're optional, so in theory, we can provide a rule that enforces one and only one space between //
and the comment text. How do we decide whether we add it or not? Any way we can survey our users, see what people use in the wild?
from swift-format.
I assumed that this issue is presumably about non-documentation comments, so at the risk of digressing...
For documentation comments, users should be authoring valid Markdown. Period. If the comment is structurally valid, then rewrapping it using the Markdown
module should not result in broken documentation, even if we change its indentation or where the lines wrap. In my opinion, if someone writes documentation comments that aren't valid Markdown/DocC, they shouldn't expect them to be handled correctly by the formatter, because they're already not handled correctly by other tools (the compiler itself parses them to generate .swiftdoc files, SourceKit uses them to show help in the IDE, DocC uses them to generate documentation).
However, I'm not sure how opinionated we want to be about documentation comments. We already use the Markdown
APIs to extract comments and analyze them, but I haven't sat down with those APIs long enough to determine how much it preserves or doesn't preserve markup choices if you take Markdown text, parse it, and then rerender it as Markdown. For example, when you have multiple choices like _foo_
and *foo*
, does it preserve those or does it always render one or the other? What about bulleted lists? Indented code blocks vs. fenced code blocks?
It all depends on how prescriptive we want to be with the markup choices and how flexible those APIs are.
from swift-format.
Tracked in Apple’s issue tracker as rdar://126948292
from swift-format.
Related Issues (20)
- Request for official `.pre-commit-hooks.yaml` HOT 1
- [FR]: Support Apple Privacy Manifest HOT 2
- Misleading formatting when closure signature is placed on its own line HOT 5
- Find config from CWD when formatting from stdin HOT 2
- Whitespace removed around standalone macro with attribute HOT 3
- Cannot install swift-format via ci_post_clone.sh in Xcode cloud HOT 5
- Running swift-format in a build phase does not seem to do anything. HOT 8
- Bundle swift-format in swift's official docker image HOT 2
- Formatting not working on Windows HOT 1
- Convert `@MainActor` `XCTestCase` subclasses to have `@MainActor` on each test method? HOT 1
- Will 510.0.0 be released? HOT 8
- tag 510.0.0: "swift-format --version" prints "508.0.0" HOT 1
- OrderedImports should create separate groups for different access levels HOT 1
- Incorrect formatting for arguments following postfix `#if` HOT 1
- swift-format version 510.1.0, will it be flag as release? HOT 1
- Leading whitespace on newlines HOT 2
- `NoAccessLevelOnExtensionDeclaration` should move `@_spi` attribute with access level attribute HOT 1
- Add a rule to disallow `public` extensions while allowing `private` and `fileprivate` ones HOT 3
- Missing option to allow trailing whitespaces on blank lines HOT 1
- Whitespace removed on Macro #Preview in SwiftUI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-format.