Skip to content

[Do Not Merge] Update DocC documentation in the PackageDescription library. #4247

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

Closed
wants to merge 5 commits into from

Conversation

zkiraly
Copy link
Contributor

@zkiraly zkiraly commented Mar 22, 2022

Update
This PR has been split into two. Please continue reviewing in those replacement PRs
Part 1 #4276
Part 2 #4277

Update DocC documentation in the PackageDescription library.

Motivation:

The DocC documentation in PackageDescription was not complete, and was out of sync with Apple's documentation at developer.apple.com.

Modifications:

Many DocC documentation comments were added or changed inside Sources/PackageDescription.

Result:

There was no code change. Only source code comments were changed in Sources/PackageDescription, and DocC extension files were added in the documentation catalog in that directory.

@available(_PackageDescription, introduced: 5.4)
case gnu17

/// ISO C 2017 with GNU extensions.
/// The identifier for the GNU18 language standard.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the change in wording based on the identifier name? I think the thought was that the identifier name should be brief but the help text should explain the nuance about it being extensions on top of a standard. Same comment applies to the others in this enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean. This is difficult, because GNU says that both gnu17 and gnu18 are "GNU dialect of ISO C17."

Anyway, I was following the pattern of the currently published documentation, which was reviewed and approved.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting, because #3079 changed the documentation from what's shown on Apple's documentation page. So, the documentation page is at least outdated by about 16 months.

///
/// [1]: <https://clang.llvm.org/cxx_status.html>
/// The supported C++ language standard to use for compiling C++ sources in the
/// package.
Copy link
Contributor

Choose a reason for hiding this comment

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

These settings can be confusing so it might be beneficial to keep the middle paragraph and reference to the Clang documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. I'll put that back.

Comment on lines 99 to 125

/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`, `a ==
/// b` implies that `a != b` is `false`.
///
/// This is the default implementation of the equal-to operator (`==`) for
/// any type that conforms to `Equatable`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
@inlinable
public static func == (lhs: Version, rhs: Version) -> Bool {
!(lhs < rhs) && !(lhs > rhs)
}


/// Returns a Boolean value indicating whether the value of the first
/// argument is less than that of the second argument.
///
/// This function is the only requirement of the `Comparable` protocol. The
/// remainder of the relational operator functions are implemented by the
/// standard library for any type that conforms to `Comparable`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
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 these are unnecessary, since the documentation should automatically inherit from Equatable's and Comparable's. However, it might be beneficial to replace the generic explanations of == and < with ones specific to semantic versions, with notes on things that users should watch for (e.g. build metadata identifiers, numeric vs. alphanumeric identifier precedence, pre-release precedence, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, definitely for the < function, I agree, because it's completely adapted for the purpose. I'll describe that in more detail. The others are more generic. I'll think about the Equatable conformance documentation, but for now, I am inclined to leave as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Some of the description in =='s documentation doesn't make sense. For example, this line: "This is the default implementation of the equal-to operator (==) for any type that conforms to Equatable.", since Version is not using the default implementation of ==.

In general, I suggest that it's better to write the documentation for each function (not just these 2, but all functions in this PR) from scratch, instead of using the protocol's default implementation's, for the following reason:

  1. If the conforming type is not using the default implementation, then the documentation for the default implementation likely is incorrect for the custom implementation.

  2. If the conforming type is using the default implementation, then there is really no need to reuse the same documentation, because the same documentation should be automatically inherited.

Comment on lines 15 to 17
/// - Parameter version: A string literal to use for creating a new version struct.
///
/// - Parameters:
/// - version: A string literal to use for creating a new version struct.
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 the current style where single paramenter uses - Parameter parameter: description is better, because its compactness reduces visual clatter around the code. However, it's only a matter of preference.

@@ -14,10 +14,12 @@ import Foundation

/// A target, the basic building block of a Swift package.
///
/// Each target contains a set of source files that are compiled into a module or test suite.
/// You can vend targets to other packages by defining products that include the targets.
/// Each target contains a set of source files that Swift Package Manager compiles into a module
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand it, SwiftPM does not compile any code. Instead, it tells the driver and compiler what to compile and how to compile them.

Copy link
Contributor

@abertelrud abertelrud Mar 25, 2022

Choose a reason for hiding this comment

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

My view is that that distinction is probably unnecessary to make for users of SwiftPM (as opposed to contributors to it such as ourselves).

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 fair, and perhaps SwiftPM can be considered as the compiler frontend's frontend.

Anyway, I think the current wording is better than the proposed change, since the passive voice hides the distinction, so it's both correct and friendly to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This documentation is aimed at developers who use SwiftPM, and not at developers working on SwiftPM.

Comment on lines 13 to 14
/// A platform that usually corresponds to an operating system such as
/// iOS, macOS, or Linux.
/// A platform that corresponds to an operating system such as iOS,
/// macOS, or Linux.
Copy link
Contributor

Choose a reason for hiding this comment

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

A platform is not always an OS, non-OS examples listed in the type include .driverKit and .wasi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this:

A platform supported by Swift Package Manager.

Comment on lines 98 to 103
/// Configures the minimum deployment target version for the macOS platform.
/// Configure the minimum deployment target version for the macOS platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

The existing convention is using third-person present tense for a function's description. E.g. https://developer.apple.com/documentation/swift/array/1641390-remove

Comment on lines 241 to 246
/// Returns a requirement for a version range, starting at the given minimum
/// version and going up to but not including the next major version. This is the recommended
/// version requirement.
///
/// - Parameters:
/// - version: The minimum version for the version range.
Copy link
Contributor

@WowbaggersLiquidLunch WowbaggersLiquidLunch Mar 25, 2022

Choose a reason for hiding this comment

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

It's recommended to begin with a summary consisting only of a single sentence fragment. I would suggest something like this:

/// Returns a source control requirement bounded to the given version's major version number.
///
/// Additional description and explanation here.
/// - Parameter version: The given version to bound the source control requirement to.
/// - Returns: A source control requirement bounded to `version`'s major version number.

Comment on lines 195 to 208
/// visit [semver.org](https://semver.org).
/// visit the [Semantic Versioning 2.0.0](https://semver.org) website.
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 it's better to either leave it as it currently is, or update the URL to https://semver.org/spec/v2.0.0.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with the second option, and I changed it in other places in PackageDescription also.

@available(_PackageDescription, introduced: 999)
public enum RegistryRequirement {
/// A version based requirement.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the other case is also a version-based requirement, perhaps it's more accurate to highlight the exact-ness of this case.

Comment on lines +500 to +501
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this description is correct.

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 this whole file is also an internal implementation details, i.e. manifests aren't expected to serialize anything. If this is documented, the impression is that manifests should do that. It's just that I don't think there is a way to hide the public codability conformance from the API.

Comment on lines -54 to +58
/// The package manifest must begin with the string `// swift-tools-version:`,
/// followed by a version number such as `// swift-tools-version:5.3`.
/// The package manifest must begin with the string `// swift-tools-version:`
/// followed by a version number specifier. The following code listing shows a
/// few examples of valid declarations of the Swift tools version:
Copy link
Contributor

@WowbaggersLiquidLunch WowbaggersLiquidLunch Mar 25, 2022

Choose a reason for hiding this comment

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

This rule has been relaxed since Swift 5.4. Manifest files for Swift ≥ 5.4 no long must begin with "// swift-tools-version:" followed immediately by the version string. They can contain any combination of whitespace before and after "//" and after ":".

Also the "swift-tools-version" part has always been case-insensitive, but the convention is all-lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds too loosy-goosey to me. I'd rather not see people do

//
     swift-tool-version:
       5.6

and the like. I understand that there may have been some benefit from the tooling point-of-view, but I don't know if it's beneficial to teach this.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can mention the relaxation around whitespace without having to go to the extreme in recommending the format as shown in your example. One of the benefits is for the user to have more control with comments' alignment and format in their entire project. For example, I can imagine some users might prefer to have all their comments indented by some whitespace, starting with an uppercase letter, or aligned with doc comments by using 1 more spaces or a tab after "//". Providing them with this information allows them to treat the Swift version specification as a regular comment in their source code, and format it as they prefer.

/// Pass configuration options as parameters to your package's initializer
/// Pass configuration options as parameters to your packages initializer
Copy link
Contributor

@WowbaggersLiquidLunch WowbaggersLiquidLunch Mar 25, 2022

Choose a reason for hiding this comment

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

Although it's correct to use U+2019 instead of U+0027 for punctuation, it can be more difficult to edit it using many IDE and keyboard combinations. (see page 270 of Unicode 13.0 spec which sort of outlines the dilemma)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was due to my internal process, and I thank you for calling it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are other locations where U+0027 is changed to U+2019. If the changes are not intended, then they should be changed back, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed all of them to the straight apostrophe under PackageDescription.

@WowbaggersLiquidLunch
Copy link
Contributor

I wonder if it might be better to divide this PR into multiple smaller PRs, each focusing on just 1 or a few related files? There are a lot of lines changed in this PR. Smaller PRs can be easier (and perhaps faster) to review and prevent things from being overlooked.

@zkiraly zkiraly changed the title Update DocC documentation in the PackageDescription library. [Do Not Merge] Update DocC documentation in the PackageDescription library. Mar 31, 2022
@zkiraly
Copy link
Contributor Author

zkiraly commented Mar 31, 2022

@WowbaggersLiquidLunch I split this PR into two: a PR dealing with Target, Product, and everything under those two (Part 2), and another PR (Part 1) dealing with everything else. I think then the two PRs might be just about equal in size.
Part 1 #4276
Part 2 #4277

@zkiraly
Copy link
Contributor Author

zkiraly commented Apr 23, 2022

The content was merged from the two split PRs. No further work on this PR. Closing.

@zkiraly zkiraly closed this Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants