Permalink
Browse files

Replace the :repository_url option by :src_code_href option which tak…

…es a proc rather than a string.
  • Loading branch information...
1 parent e69c25e commit 4d1ab30b80056d562991e02d17fc32f2ecf78983 @tobie committed May 7, 2010
Showing with 9 additions and 8 deletions.
  1. +4 −2 Rakefile
  2. +3 −2 lib/pdoc/models/entity.rb
  3. +1 −3 lib/pdoc/runner.rb
  4. +1 −1 templates/html/partials/title.erb
View
@@ -4,11 +4,13 @@ require 'lib/pdoc'
desc "Builds the documentation"
task :build_doc do
PDoc.run({
- :source_files => [File.expand_path(File.join(File.dirname(__FILE__), "test", "fixtures", "ajax.js"))],
+ :source_files => [File.join(File.dirname(__FILE__), "test", "fixtures", "ajax.js")],
:destination => OUTPUT_DIR,
:syntax_highlighter => :pygments,
:markdown_parser => :bluecloth,
- :repository_url => "http://github.com/example/ex/",
+ :src_code_href => proc { |file, line|
+ "http://github.com/example/ex/#{file}##{line}"
+ },
:pretty_urls => false,
:bust_cache => true,
:name => 'Example JavaScript Framework',
@@ -2,7 +2,7 @@ module PDoc
module Models
class Entity < Base
class << Entity
- attr_accessor :repository_url
+ attr_accessor :src_code_href
end
def signatures
@@ -14,7 +14,8 @@ def <=>(other)
end
def src_code_href
- @src_code_href ||= "#{Entity.repository_url}#{@file}#LID#{@line_number}"
+ proc = Entity.src_code_href
+ @src_code_href ||= proc ? proc.call(@file, @line_number) : nil
end
def signatures?
View
@@ -10,9 +10,8 @@ def initialize(*source_files)
@parser = Parser
@serializer = Serializer
@bust_cache = options.delete(:bust_cache) || false
- Models::Entity.repository_url = options.delete(:repository_url)
+ Models::Entity.src_code_href = options.delete(:src_code_href)
@generator_options = options
-
end
def serialize(files)
@@ -46,7 +45,6 @@ def run
puts " Markdown parser: #{@generator_options[:markdown_parser]}"
puts " Syntax highlighter: #{@generator_options[:syntax_highlighter]}"
puts " Pretty urls: #{@generator_options[:pretty_urls]}"
- puts " Repository url: #{Models::Entity.repository_url}"
puts " Index page: #{@generator_options[:index_page]}"
puts " Output directory: #{@output_directory}\n\n"
@@ -11,7 +11,7 @@
<% end %>
</ul>
-<% if object.respond_to?(:src_code_href) %>
+<% 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 %>

0 comments on commit 4d1ab30

Please sign in to comment.