Skip to content

Commit

Permalink
Add ability to customize the text of the "view source code" anchor. M…
Browse files Browse the repository at this point in the history
…ove the anchor to below the name of the object.
  • Loading branch information
savetheclocktower committed Nov 4, 2010
1 parent 5152ce5 commit b92409f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/pdoc/models.rb
Expand Up @@ -23,6 +23,7 @@ module PDoc
module Models module Models
class << Models class << Models
attr_accessor :src_code_href attr_accessor :src_code_href
attr_accessor :src_code_text
attr_accessor :doc_href attr_accessor :doc_href
end end


Expand Down
4 changes: 4 additions & 0 deletions lib/pdoc/models/entity.rb
Expand Up @@ -15,6 +15,10 @@ def src_code_href
proc = Models.src_code_href proc = Models.src_code_href
@src_code_href ||= proc ? proc.call(self) : nil @src_code_href ||= proc ? proc.call(self) : nil
end end

def src_code_text
@src_code_text ||= Models.src_code_text
end


def signatures? def signatures?
@signatures && !@signatures.empty? @signatures && !@signatures.empty?
Expand Down
1 change: 1 addition & 0 deletions lib/pdoc/runner.rb
Expand Up @@ -11,6 +11,7 @@ def initialize(*source_files)
@serializer = Serializer @serializer = Serializer
@bust_cache = options.delete(:bust_cache) || false @bust_cache = options.delete(:bust_cache) || false
Models.src_code_href = options.delete(:src_code_href) Models.src_code_href = options.delete(:src_code_href)
Models.src_code_text = options.delete(:src_code_text)
Models.doc_href = options.delete(:doc_href) Models.doc_href = options.delete(:doc_href)
@generator_options = options @generator_options = options
end end
Expand Down
6 changes: 5 additions & 1 deletion templates/html/assets/stylesheets/pdoc/api.css
Expand Up @@ -622,6 +622,9 @@ p.related-to {
border-right: 1px solid #636363; border-right: 1px solid #636363;
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden; overflow-x: hidden;

/* Fixes jagged text in Safari 5. */
-webkit-font-smoothing: antialiased;
} }


#search_pane { #search_pane {
Expand Down Expand Up @@ -673,5 +676,6 @@ input.ghosted {
} }


#src_code_href { #src_code_href {
float: right; font-size: 11px;
margin: -15px 0 15px 120px;
} }
10 changes: 6 additions & 4 deletions templates/html/partials/title.erb
Expand Up @@ -11,12 +11,14 @@
<% end %> <% end %>
</ul> </ul>


<% if object.respond_to?(:src_code_href) && object.src_code_href %>
<p id="src_code_href"><a href="<%= object.src_code_href %>">src code</a></p>
<% end %>

<h2 class="page-title"> <h2 class="page-title">
<span class="type"><%= object.type %></span> <%= object.full_name %> <span class="type"><%= object.type %></span> <%= object.full_name %>
</h2> </h2>


<% if object.respond_to?(:src_code_href) && object.src_code_href %>
<% anchor_text = object.respond_to?(:src_code_text) ? object.src_code_text : "View source code &rarr;" %>
<p id="src_code_href"><a href="<%= object.src_code_href %>"><%= anchor_text %></a></p>
<% end %>




0 comments on commit b92409f

Please sign in to comment.