Skip to content

[stdlib] Various documentation improvements #9574

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

Merged
merged 6 commits into from
May 13, 2017

Conversation

natecook1000
Copy link
Member

  • string documentation revisions
  • revise examples throughout to use range expressions instead of e.g. prefix(upTo: _)
  • partial ranges and operators
  • documented swap(_:_:) and MutableCollection.swapAt(_:_:)
  • removing .characters from examples
  • improvements to the String Foundation overlay docs
  • integer type documentation revisions
  • fixed discussions for floating-point operators
  • minor revisions elsewhere

natecook1000 and others added 5 commits May 13, 2017 10:06
* abstracts for integer types
* fixed discussions for floating-point operators
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
* documented swap(_:_:) and MutableCollection.swapAt(_:_:)
* clarifications and fixes elsewhere
* finish string documentation revisions
* revise examples throughout to use range expressions instead of e.g.
  prefix(upTo: _)
@natecook1000
Copy link
Member Author

@swift-ci Please smoke test

@@ -151,7 +151,7 @@ if True:
/// Here's an implementation of those steps:
///
/// if let i = absences.index(where: { $0 > 0 }) { // 1
/// let absencesAfterFirst = absences.suffix(from: i + 1) // 2
/// let absencesAfterFirst = absences[(i + 1)...] // 2
Copy link
Contributor

@dabrahams dabrahams May 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absences[i+1...] will work without the extra parens. I personally think cases like this read better without spaces around the +, but you can always do absences[i + 1...] or absences[i + 1 ...] if you must have them. The middle one is actually quite good too; I might switch to doing that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of those syntaxes work for me; the parens seem to be necessary. We could add a + overload for a CountablePartialRangeFrom<Bound> and Bound.Stride okay I'll see myself out…

Copy link
Contributor

@dabrahams dabrahams May 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, rats. Yes, they are necessary because only binary operators have precedence, and unary operators bind more tightly. That rots:

i+1...j-1 // OK
i+1...    // Error :(

“Someone” should file a Jira.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -170,7 +170,7 @@ if True:
"""
elif Self == 'Array':
SelfDocComment = '''\
/// An ordered, random-access collection.
/// An ordered, random-access collection of elements of a single type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not accurate, is it? They have a single static type, but of course you can have [Any] and then the types can be as diverse as you like. I don't think it helps unless we're really trying to hide the fact that things like [Any] exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to take that back out until I think of a clearer way to express it that doesn't pretend [Any] doesn't exist.

///
/// let greeting = "Hello! 🐥"
/// print("Character count: \(greeting.characters.count)")
/// print("Character count: \(greeting.count)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "Length: ..."?

/// // Prints "Buffalo"
///
/// You can retrieve the same slice using other methods, such as finding the
/// terminating index, and then using the `prefix(upTo:)` method, which takes
/// an index as its parameter, or by using the view's ranged subscript.
/// terminating index, and the using the string's ranged subscript, or by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the: typo?

IMO "ranged subscript" is not as good a term as "slicing operation"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I like "slicing operation," too—going to wait and handle that one on a more holistic basis, though.

/// terminating index, and then using the `prefix(upTo:)` method, which takes
/// an index as its parameter, or by using the view's ranged subscript.
/// terminating index, and the using the string's ranged subscript, or by
/// using the `prefix(upTo:)` method, which takes an index as its parameter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should drop mention of that; IMO we'll probably obsolete (or at least deprecate) it for Swift 4

@natecook1000
Copy link
Member Author

@swift-ci Please smoke test

@natecook1000 natecook1000 merged commit 1b6511a into swiftlang:master May 13, 2017
natecook1000 added a commit to natecook1000/swift that referenced this pull request May 13, 2017
[stdlib] Various documentation improvements
@natecook1000 natecook1000 deleted the nc-fixes-75-1 branch October 4, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants