An analysis of Swift Evolution proposals
Swift
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
proposal-page-generator.xcodeproj auto-update proposals Jan 8, 2017
swift-evolution @ 128b02e update Jan 8, 2017
swift-proposal-analyzer.playground
.gitignore add initial page generator Sep 11, 2016
.gitmodules setup submodule Sep 11, 2016
LICENSE Initial commit Sep 11, 2016
README.md
main.swift update markdown Sep 11, 2016
update_proposals.sh fix the script bug (#7) Dec 5, 2016

README.md

swift-proposal-analyzer

An analysis of Swift Evolution proposals

About

All of the swift-evolution proposals are publicly available on GitHub, however they are just markdown files — plain text. There's no way to query or filter the proposals. For example, you can't search for "all proposals written by Chris Lattner" or "all rejected proposals" or "all proposals that mention Objective-C".

This project contains tools to analyze, query, and filter the Swift Evolution proposals based on any criteria you like.

This project accompanies my talk from FrenchKit.

Requirements

  • macOS 10.11+
  • Xcode 8
  • Swift 3.0

Setup

This repo contains a number of different components:

  • The swift-evolution repo is a git submodule. This is how proposals are synced to stay updated.
  • main.swift is a swift script that generates playground pages for all of the proposals. You can open proposal-page-generator.xcodeproj to modify the script.
  • swift-proposal-analyzer.playground is the main playground that contains:
    • All of the proposals as playground pages
    • All of the proposals as raw Resources/
    • The analyzer code
  • update_proposals.sh is a bash script that does the following:
    1. Updates the swift-evolution submodule
    2. Copies the proposals from the submodule directory, into the playground Resources/ directory
    3. Runs main.swift to generate the playground pages

Cloning this repo

$ git clone https://github.com/jessesquires/swift-proposal-analyzer.git
$ cd swift-proposal-analyzer/
$ git submodule init
$ git submodule update --remote
$ ./update_proposals.sh

Usage

Open and run swift-proposal-analyzer.playground.

After parsing completes, you'll have an array of Proposal types:

public final class Proposal {
    public let title: String
    public let seNumber: String

    public let authors: [Author]
    public let status: Status

    public let fileName: String
    public let fileContents: String
    public let wordCount: Int
}

Most proposal metadata is available, as well as the raw file contents. You can now perform different queries or apply filters to the proposal data.

Examples

// Find proposals implemented in Swift 3.0
let implementedInSwift3 = analyzer.proposalsWith(status: .implemented(.v3_0))
// Find proposals authored or co-authored by Chris Lattner
let proposalsByLattner = analyzer.proposals.filter { p -> Bool in
    p.writtenBy("Chris Lattner")
}
// Find total mentions of "Objective-C" across all proposals
let count = analyzer.occurrences(of: "Objective-C")

Caveats

Some of the code here is pretty "quicky and dirty", but it works! So ¯\_(ツ)_/¯ 😆 If there's a better way to do something, please submit a pull request!

This is a small dataset, so any conclusions should be taken with a grain of salt. 😄

Credits

Created and maintained by @jesse_squires.

License

Released under an MIT License. See LICENSE for details.

Copyright © 2016-present Jesse Squires.