Skip to content
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

[WIP] Swift 1.2 #187

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
language: objective-c
osx_image: xcode61
osx_image: xcode611
cache: bundler
rvm:
- system

before_install:
- sudo gem install bundler
- git submodule update --init --recursive

script:
- bundle exec rake spec
notifications:
email: false
slack: realmio:vPdpsG9NLDo2DNlbqtcMAQuE
branches:
except:
- swift1p2
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
[segiddins](https://github.com/segiddins)
[#196](https://github.com/realm/jazzy/issues/196)

* "Show on GitHub" links now link to line-ranges for multi-line definitions.
[JP Simard](https://github.com/jpsim)
[#198](https://github.com/realm/jazzy/issues/198)

##### Bug Fixes

* None.
Expand All @@ -36,12 +40,20 @@

##### Breaking

* None.
* Jazzy now only supports projects using Swift 1.2.
[JP Simard](https://github.com/jpsim)
[#170](https://github.com/realm/jazzy/issues/170)
* Increase default minimum ACL to public.
[JP Simard](https://github.com/jpsim)
[#186](https://github.com/realm/jazzy/issues/186)

##### Enhancements

* Improve the styling of `dl` elements (parsed key-value pairs).
[segiddins](https://github.com/segiddins)
* Use key.accessibility to determine ACL.
[JP Simard](https://github.com/jpsim)
[#185](https://github.com/realm/jazzy/issues/185)

* Raise exceptions if Xcode requirements aren't met.
[JP Simard](https://github.com/jpsim)
Expand Down
2 changes: 1 addition & 1 deletion SourceKitten
Submodule SourceKitten updated 53 files
+1 −0 .gitattributes
+1 −7 .gitmodules
+25 −0 CHANGELOG.md
+1 −3 Cartfile
+2 −1 Cartfile.private
+4 −6 Cartfile.resolved
+1 −1 Carthage/Checkouts/Commandant
+1 −1 Carthage/Checkouts/LlamaKit
+0 −1 Carthage/Checkouts/Nimble
+0 −1 Carthage/Checkouts/Quick
+1 −1 Carthage/Checkouts/SwiftXPC
+1 −1 Carthage/Checkouts/xcconfigs
+6 −3 README.md
+0 −22 Source/SourceKittenFramework/Array+Compact.swift
+4 −13 Source/SourceKittenFramework/ClangTranslationUnit.swift
+1 −1 Source/SourceKittenFramework/Dictionary+Merge.swift
+84 −76 Source/SourceKittenFramework/File.swift
+22 −10 Source/SourceKittenFramework/Language.swift
+11 −7 Source/SourceKittenFramework/Module.swift
+0 −100 Source/SourceKittenFramework/NSString+SourceKitten.swift
+7 −6 Source/SourceKittenFramework/OffsetMap.swift
+8 −13 Source/SourceKittenFramework/Request.swift
+0 −27 Source/SourceKittenFramework/SequenceType+IndexBefore.swift
+22 −0 Source/SourceKittenFramework/SequenceType+SourceKitten.swift
+1 −0 Source/SourceKittenFramework/SourceKittenFramework.h
+116 −0 Source/SourceKittenFramework/String+SourceKitten.swift
+3 −3 Source/SourceKittenFramework/Structure.swift
+63 −52 Source/SourceKittenFramework/SwiftDeclarationKind.swift
+42 −16 Source/SourceKittenFramework/SwiftDocKey.swift
+1 −1 Source/SourceKittenFramework/SwiftDocs.swift
+5 −4 Source/SourceKittenFramework/SwiftXPC+JSON.swift
+30 −19 Source/SourceKittenFramework/SyntaxKind.swift
+10 −8 Source/SourceKittenFramework/SyntaxMap.swift
+10 −10 Source/SourceKittenFramework/sourcekitd.swift
+76 −48 Source/SourceKittenFrameworkTests/Fixtures/Bicycle.json
+1 −1 Source/SourceKittenFrameworkTests/Fixtures/Bicycle.swift
+2,077 −0 Source/SourceKittenFrameworkTests/Fixtures/Commandant.json
+21 −11 Source/SourceKittenFrameworkTests/ModuleTests.swift
+3 −3 Source/SourceKittenFrameworkTests/OffsetMapTests.swift
+11 −40 Source/SourceKittenFrameworkTests/StringTests.swift
+35 −2 Source/SourceKittenFrameworkTests/StructureTests.swift
+3 −3 Source/SourceKittenFrameworkTests/SwiftDocsTests.swift
+10 −7 Source/SourceKittenFrameworkTests/SyntaxTests.swift
+19 −25 Source/sourcekitten/Doc.swift
+11 −31 Source/sourcekitten/Errors.swift
+0 −63 Source/sourcekitten/Module+MultiProcess.swift
+14 −15 Source/sourcekitten/Structure.swift
+14 −15 Source/sourcekitten/Syntax.swift
+3 −4 Source/sourcekitten/Version.swift
+1 −2 Source/sourcekitten/main.swift
+45 −17 sourcekitten.xcodeproj/project.pbxproj
+1 −1 sourcekitten.xcodeproj/xcshareddata/xcschemes/SourceKittenFramework.xcscheme
+5 −3 sourcekitten.xcodeproj/xcshareddata/xcschemes/sourcekitten.xcscheme
8 changes: 4 additions & 4 deletions lib/jazzy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initialize
self.clean = false
self.docset_platform = 'jazzy'
self.version = '1.0'
self.min_acl = SourceDeclaration::AccessControlLevel.internal
self.min_acl = SourceDeclaration::AccessControlLevel.public
self.skip_undocumented = false
self.source_directory = Pathname.pwd
end
Expand Down Expand Up @@ -126,11 +126,11 @@ def self.parse!

opt.on('--min-acl [private | internal | public]',
'minimum access control level to document \
(default is internal)') do |acl|
(default is public)') do |acl|
if acl == 'private'
config.min_acl = SourceDeclaration::AccessControlLevel.private
elsif acl == 'public'
config.min_acl = SourceDeclaration::AccessControlLevel.public
elsif acl == 'internal'
config.min_acl = SourceDeclaration::AccessControlLevel.internal
end
end

Expand Down
14 changes: 9 additions & 5 deletions lib/jazzy/doc_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ def self.prepare_output_dir(output_dir, clean)
# @return [Array] doc structure comprised of
# section names & child names & URLs
def self.doc_structure_for_docs(docs)
structure = []
docs.each do |doc|
structure << {
docs.map do |doc|
{
section: doc.name,
children: doc.children.sort_by(&:name).map do |child|
{ name: child.name, url: child.url }
end,
}
end
structure
end

# Build documentation from the given options
Expand Down Expand Up @@ -205,7 +203,11 @@ def self.should_link_to_github(file)
def self.gh_token_url(item, source_module)
if source_module.github_file_prefix && should_link_to_github(item.file)
relative_file_path = item.file.gsub(`pwd`.strip, '')
gh_line = "#L#{item.line}"
if item.start_line && (item.start_line != item.end_line)
gh_line = "#L#{item.start_line}-L#{item.end_line}"
else
gh_line = "#L#{item.line}"
end
source_module.github_file_prefix + relative_file_path + gh_line
end
end
Expand All @@ -228,6 +230,8 @@ def self.render_item(item, source_module)
item_render[:return] = Jazzy.markdown.render(item.return) if item.return
item_render[:parameters] = item.parameters if item.parameters.any?
item_render[:url] = item.url if item.children.any?
item_render[:start_line] = item.start_line
item_render[:end_line] = item.end_line
item_render.reject { |_, v| v.nil? }
end

Expand Down
2 changes: 2 additions & 0 deletions lib/jazzy/source_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SourceDeclaration
attr_accessor :url
attr_accessor :mark
attr_accessor :access_control_level
attr_accessor :start_line
attr_accessor :end_line

def overview
"#{abstract}\n\n#{discussion}".strip
Expand Down
42 changes: 34 additions & 8 deletions lib/jazzy/source_declaration/access_control_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,52 @@ class AccessControlLevel

attr_reader :level

def initialize(declaration_string)
if declaration_string =~ /private\ /
ACCESSIBILITY_PRIVATE = 'source.lang.swift.accessibility.private'
ACCESSIBILITY_INTERNAL = 'source.lang.swift.accessibility.internal'
ACCESSIBILITY_PUBLIC = 'source.lang.swift.accessibility.public'

def initialize(accessibility)
if accessibility == ACCESSIBILITY_PRIVATE
@level = :private
elsif declaration_string =~ /public\ /
@level = :public
else
elsif accessibility == ACCESSIBILITY_INTERNAL
@level = :internal
elsif accessibility == ACCESSIBILITY_PUBLIC
@level = :public
end
end

def self.from_doc(doc)
accessibility = doc['key.accessibility']
if accessibility
acl = new(accessibility)
if acl
return acl
end
end
acl = from_explicit_declaration(doc['key.parsed_declaration'])
acl || AccessControlLevel.public # fallback on public ACL
end

def self.from_explicit_declaration(declaration_string)
if declaration_string =~ /private\ /
return AccessControlLevel.private
elsif declaration_string =~ /public\ /
return AccessControlLevel.public
elsif declaration_string =~ /internal\ /
return AccessControlLevel.internal
end
end

def self.private
AccessControlLevel.new('private ')
new(ACCESSIBILITY_PRIVATE)
end

def self.internal
AccessControlLevel.new('internal ')
new(ACCESSIBILITY_INTERNAL)
end

def self.public
AccessControlLevel.new('public ')
new(ACCESSIBILITY_PUBLIC)
end

LEVELS = {
Expand Down
16 changes: 7 additions & 9 deletions lib/jazzy/sourcekitten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def self.make_doc_urls(docs, parents)

def self.assert_xcode_location
expected_xcode_select_path =
Pathname('/Applications/Xcode.app/Contents/Developer')
Pathname('/Applications/Xcode-6p3-Beta4.app/Contents/Developer')
return if xcode_developer_directory == expected_xcode_select_path
raise 'Please install or symlink Xcode 6.1 or 6.2 in ' \
raise 'Please install or symlink Xcode 6.3 in ' \
"#{expected_xcode_select_path} and set as active developer " \
'directory by running `sudo xcode-select -s ' \
"#{expected_xcode_select_path}`"
Expand All @@ -71,7 +71,7 @@ def self.xcode_developer_directory
def self.assert_swift_version
swift_version = `xcrun swift --version` =~ /Swift version ([\d\.]+)/ &&
Regexp.last_match[1]
expected_swift_version = '1.1'
expected_swift_version = '1.2'
return if swift_version == expected_swift_version
raise "Jazzy only works with Swift #{expected_swift_version}."
end
Expand Down Expand Up @@ -103,11 +103,7 @@ def self.documented_child?(doc)
end

def self.should_document?(doc)
# Always document extensions, since we can't tell what ACL they are
return true if doc['key.kind'] == 'source.lang.swift.decl.extension'

SourceDeclaration::AccessControlLevel.new(doc['key.annotated_decl']) >=
@min_acl
SourceDeclaration::AccessControlLevel.from_doc(doc) >= @min_acl
end

def self.process_undocumented_token(doc, declaration)
Expand Down Expand Up @@ -193,9 +189,11 @@ def self.make_source_declarations(docs)
declaration.name = doc['key.name']
declaration.mark = current_mark
acl = SourceDeclaration::AccessControlLevel.new(
doc['key.annotated_decl'],
doc['key.accessibility'],
)
declaration.access_control_level = acl
declaration.start_line = doc['key.parsed_scope.start']
declaration.end_line = doc['key.parsed_scope.end']

next unless make_doc_info(doc, declaration)
make_substructure(doc, declaration)
Expand Down
1 change: 0 additions & 1 deletion lib/jazzy/sourcekitten/Commandant.framework/Modules

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>14B25</string>
<string>14C1514</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -25,17 +25,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14A382</string>
<string>14D98g</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0611</string>
<string>0630</string>
<key>DTXcodeBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Carthage. All rights reserved.</string>
</dict>
Expand Down
1 change: 0 additions & 1 deletion lib/jazzy/sourcekitten/LlamaKit.framework/Modules

This file was deleted.

Binary file modified lib/jazzy/sourcekitten/LlamaKit.framework/Versions/A/LlamaKit
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>14B25</string>
<string>14C1514</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -25,17 +25,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14A382</string>
<string>14D98g</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0611</string>
<string>0630</string>
<key>DTXcodeBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Rob Napier. All rights reserved.</string>
<key>UIDeviceFamily</key>
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>14B25</string>
<string>14C1514</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -25,17 +25,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14A382</string>
<string>14D98g</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0611</string>
<string>0630</string>
<key>DTXcodeBuild</key>
<string>6A2008a</string>
<string>6D554n</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 JP Simard. All rights reserved.</string>
</dict>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading