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

Render Swift declarations for Objective-C declarations #530

Merged
merged 4 commits into from
Apr 20, 2016
Merged
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: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Master

##### Breaking

* None.

##### Enhancements

* Objective-C documentation now also includes Swift declarations.
[JP Simard](https://github.com/jpsim)
[#136](https://github.com/realm/jazzy/issues/136)

##### Bug Fixes

* Uses GitHub-Flavored Markdown syntax for anchors when rendering README pages.
Expand Down
2 changes: 1 addition & 1 deletion SourceKitten
Binary file not shown.
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>15E65</string>
<string>15F18b</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.2</string>
<string>0.9.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
Expand Down
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>15E65</string>
<string>15F18b</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
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>15E65</string>
<string>15F18b</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
Binary file not shown.
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>15E65</string>
<string>15F18b</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
Binary file not shown.
Binary file modified lib/jazzy/SourceKitten/bin/sourcekitten
Binary file not shown.
27 changes: 14 additions & 13 deletions lib/jazzy/doc_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,20 @@ def self.render_item(item, source_module)
# Combine abstract and discussion into abstract
abstract = (item.abstract || '') + (item.discussion || '')
item_render = {
name: item.name,
abstract: render_markdown(abstract),
declaration: item.declaration,
usr: item.usr,
dash_type: item.type.dash_type,
github_token_url: gh_token_url(item, source_module),
default_impl_abstract: render_markdown(item.default_impl_abstract),
from_protocol_extension: item.from_protocol_extension,
return: render_markdown(item.return),
parameters: (item.parameters if item.parameters.any?),
url: (item.url if item.children.any?),
start_line: item.start_line,
end_line: item.end_line,
name: item.name,
abstract: render_markdown(abstract),
declaration: item.declaration,
other_language_declaration: item.other_language_declaration,
Copy link
Collaborator

Choose a reason for hiding this comment

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

to be generic, this should probably be a hash, languages to their ddeclarations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

happy to do that when we get there. for now, this is a bit simpler.

usr: item.usr,
dash_type: item.type.dash_type,
github_token_url: gh_token_url(item, source_module),
default_impl_abstract: render_markdown(item.default_impl_abstract),
from_protocol_extension: item.from_protocol_extension,
return: render_markdown(item.return),
parameters: (item.parameters if item.parameters.any?),
url: (item.url if item.children.any?),
start_line: item.start_line,
end_line: item.end_line,
}
item_render.reject { |_, v| v.nil? }
end
Expand Down
1 change: 1 addition & 0 deletions lib/jazzy/source_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def objc_category_name
attr_accessor :usr
attr_accessor :name
attr_accessor :declaration
attr_accessor :other_language_declaration
attr_accessor :abstract
attr_accessor :default_impl_abstract
attr_accessor :from_protocol_extension
Expand Down
9 changes: 9 additions & 0 deletions lib/jazzy/sourcekitten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def self.parameters(doc)
end
end

# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def self.make_doc_info(doc, declaration)
return unless should_document?(doc)
unless doc['key.doc.full_as_xml']
Expand All @@ -225,6 +227,11 @@ def self.make_doc_info(doc, declaration)
doc['key.parsed_declaration'] || doc['key.doc.declaration'],
Config.instance.objc_mode ? 'objc' : 'swift',
)
if Config.instance.objc_mode && doc['key.swift_declaration']
declaration.other_language_declaration = Highlighter.highlight(
doc['key.swift_declaration'], 'swift'
)
end
declaration.abstract = Jazzy.markdown.render(doc['key.doc.comment'] || '')
declaration.discussion = ''
declaration.return = make_paragraphs(doc, 'key.doc.result_discussion')
Expand All @@ -233,6 +240,8 @@ def self.make_doc_info(doc, declaration)

@documented_count += 1
end
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/PerceivedComplexity

def self.make_substructure(doc, declaration)
if doc['key.substructure']
Expand Down
6 changes: 6 additions & 0 deletions lib/jazzy/themes/apple/templates/task.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<p class="aside-title">{{language}}</p>
{{{declaration}}}
</div>
{{#other_language_declaration}}
<div class="language">
<p class="aside-title">Swift</p>
{{{other_language_declaration}}}
</div>
{{/other_language_declaration}}
</div>
{{/declaration}}
{{#parameters.count}}
Expand Down
6 changes: 6 additions & 0 deletions lib/jazzy/themes/fullwidth/templates/task.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<p class="aside-title">{{language}}</p>
{{{declaration}}}
</div>
{{#other_language_declaration}}
<div class="language">
<p class="aside-title">Swift</p>
{{{other_language_declaration}}}
</div>
{{/other_language_declaration}}
</div>
{{/declaration}}
{{#parameters.count}}
Expand Down
2 changes: 1 addition & 1 deletion spec/integration_specs
Submodule integration_specs updated 42 files
+55 −0 document_realm_objc/after/docs/Classes.html
+105 −0 document_realm_objc/after/docs/Classes/RLMArray.html
+30 −0 document_realm_objc/after/docs/Classes/RLMMigration.html
+5 −0 document_realm_objc/after/docs/Classes/RLMNotificationToken.html
+100 −0 document_realm_objc/after/docs/Classes/RLMObject.html
+20 −0 document_realm_objc/after/docs/Classes/RLMObjectSchema.html
+30 −0 document_realm_objc/after/docs/Classes/RLMProperty.html
+160 −0 document_realm_objc/after/docs/Classes/RLMRealm.html
+40 −0 document_realm_objc/after/docs/Classes/RLMRealmConfiguration.html
+60 −0 document_realm_objc/after/docs/Classes/RLMResults.html
+15 −0 document_realm_objc/after/docs/Classes/RLMSchema.html
+20 −0 document_realm_objc/after/docs/Classes/RLMSortDescriptor.html
+40 −0 document_realm_objc/after/docs/Constants.html
+10 −0 document_realm_objc/after/docs/Enums.html
+35 −0 document_realm_objc/after/docs/Enums/RLMError.html
+50 −0 document_realm_objc/after/docs/Enums/RLMPropertyType.html
+5 −0 document_realm_objc/after/docs/Protocols.html
+65 −0 document_realm_objc/after/docs/Protocols/RLMCollection.html
+5 −0 document_realm_objc/after/docs/Type Definitions.html
+55 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes.html
+105 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMArray.html
+30 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMMigration.html
+5 −0 ...t_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMNotificationToken.html
+100 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMObject.html
+20 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMObjectSchema.html
+30 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMProperty.html
+160 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMRealm.html
+40 −0 ..._realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMRealmConfiguration.html
+60 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMResults.html
+15 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMSchema.html
+20 −0 ...ment_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Classes/RLMSortDescriptor.html
+40 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Constants.html
+10 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Enums.html
+35 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Enums/RLMError.html
+50 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Enums/RLMPropertyType.html
+5 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Protocols.html
+65 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Protocols/RLMCollection.html
+5 −0 document_realm_objc/after/docs/docsets/Realm.docset/Contents/Resources/Documents/Type Definitions.html
+15 −0 misc_jazzy_objc_features/after/docs/Classes/ObjCTopLevelClass.html
+5 −0 misc_jazzy_objc_features/after/docs/Ying.html
+15 −0 ...bjc_features/after/docs/docsets/JazzyKit.docset/Contents/Resources/Documents/Classes/ObjCTopLevelClass.html
+5 −0 misc_jazzy_objc_features/after/docs/docsets/JazzyKit.docset/Contents/Resources/Documents/Ying.html