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

[DocBuilder] "Show on GitHub" links now link to line-ranges #208

Merged
merged 6 commits into from
Apr 9, 2015
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
[JP Simard](https://github.com/jpsim)
[#95](https://github.com/realm/jazzy/issues/95)

* "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

* Fixed issue where docset would contain duplicate files.
Expand Down Expand Up @@ -42,6 +46,10 @@
resolved.
[JP Simard](https://github.com/jpsim)

* Allow using a version of Xcode that is symlinked to
`/Applications/Xcode.app`.
[Samuel Giddins](https://github.com/segiddins)


## 0.1.4

Expand Down
8 changes: 8 additions & 0 deletions lib/jazzy/assets/css/jazzy.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ header {
padding-top: 8px;
width: 100%;
list-style-type: none;
a[name] {
&:before {
content: "";
display: block;
padding-top: $content_top_offset;
margin: -$content_top_offset 0 0;
}
}
code {
background-color: transparent;
padding: 0;
Expand Down
14 changes: 10 additions & 4 deletions lib/jazzy/doc_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ module Jazzy
# This module handles HTML generation, file writing, asset copying,
# and generally building docs given sourcekitten output
module DocBuilder
DEVELOPER_DIR = `xcode-select -p`.chomp

# mkdir -p output directory and clean if option is set
def self.prepare_output_dir(output_dir, clean)
FileUtils.rm_r output_dir if clean && output_dir.directory?
Expand Down Expand Up @@ -195,7 +193,9 @@ def self.document_index(source_module, path_to_root)
end

def self.should_link_to_github(file)
!file.start_with?(DEVELOPER_DIR) if file
developer_directory = SourceKitten.xcode_developer_directory
return unless developer_directory && file
!file.start_with?(developer_directory.realpath.to_s)
end

# Construct Github token URL
Expand All @@ -204,7 +204,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 @@ -227,6 +231,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
4 changes: 3 additions & 1 deletion lib/jazzy/sourcekitten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.assert_xcode_location

def self.xcode_developer_directory
dir = Pathname(`xcode-select -p`.chomp)
dir.directory? ? dir.realpath : nil
dir.directory? ? dir.expand_path : nil
end

def self.assert_swift_version
Expand Down Expand Up @@ -215,6 +215,8 @@ def self.make_source_declarations(docs)
doc['key.annotated_decl'],
)
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
2 changes: 1 addition & 1 deletion spec/integration_specs
Submodule integration_specs updated 25 files
+2 −2 document_alamofire/after/docs/Classes.html
+4 −4 document_alamofire/after/docs/Classes/Manager.html
+9 −9 document_alamofire/after/docs/Classes/Request.html
+2 −2 document_alamofire/after/docs/Enums.html
+1 −1 document_alamofire/after/docs/Enums/ParameterEncoding.html
+5 −5 document_alamofire/after/docs/Extensions/Manager.html
+17 −17 document_alamofire/after/docs/Extensions/Request.html
+11 −11 document_alamofire/after/docs/Functions.html
+2 −2 document_alamofire/after/docs/Protocols.html
+5 −0 document_alamofire/after/docs/css/jazzy.css
+2 −2 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Classes.html
+4 −4 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Classes/Manager.html
+9 −9 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Classes/Request.html
+2 −2 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Enums.html
+1 −1 ...ent_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Enums/ParameterEncoding.html
+5 −5 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Extensions/Manager.html
+17 −17 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Extensions/Request.html
+11 −11 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Functions.html
+2 −2 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/Protocols.html
+5 −0 document_alamofire/after/docs/docsets/Alamofire.docset/Contents/Resources/Documents/css/jazzy.css
+5 −0 document_moya_podspec/after/docs/css/jazzy.css
+5 −0 document_moya_podspec/after/docs/docsets/Moya.docset/Contents/Resources/Documents/css/jazzy.css
+1 −1 document_moya_podspec/after/execution_output.txt
+5 −0 misc_jazzy_features/after/docs/css/jazzy.css
+5 −0 misc_jazzy_features/after/docs/docsets/MiscJazzyFeatures.docset/Contents/Resources/Documents/css/jazzy.css