Skip to content
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
2 changes: 1 addition & 1 deletion lib/rdoc/discover.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
begin
gem 'rdoc', '~> 3'
gem 'rdoc', '~> 4.0.0.rc'
require File.join(File.dirname(__FILE__), '/../sdoc')
rescue Gem::LoadError
end
4 changes: 2 additions & 2 deletions lib/sdoc.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$:.unshift File.dirname(__FILE__)
require "rubygems"
gem 'rdoc', '~> 3'
gem 'rdoc', '~> 4.0.0.rc'

module SDoc end

require 'sdoc/generator'
16 changes: 11 additions & 5 deletions lib/sdoc/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class RDoc::Generator::SDoc

attr_reader :options

##
# The RDoc::Store that is the source of the generated content

attr_reader :store

def self.setup_options(options)
@github = false
options.se_index = true
Expand Down Expand Up @@ -148,7 +153,8 @@ def self.setup_options(options)

end

def initialize(options)
def initialize(store, options)
@store = store
@options = options
if @options.respond_to?('diagram=')
@options.diagram = false
Expand All @@ -161,15 +167,15 @@ def initialize(options)
@json_index = RDoc::Generator::JsonIndex.new self, options
end

def generate(top_levels)
def generate
@outputdir = Pathname.new(@options.op_dir).expand_path(@base_dir)
@files = top_levels.sort
@classes = RDoc::TopLevel.all_classes_and_modules.sort
@files = @store.all_files.sort
@classes = @store.all_classes_and_modules.sort

# Now actually write the output
copy_resources
generate_class_tree
@json_index.generate top_levels
@json_index.generate
generate_file_files
generate_class_files
generate_index_file
Expand Down
8 changes: 4 additions & 4 deletions lib/sdoc/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module SDoc::GitHub
def github_url(path)
unless @github_url_cache.has_key? path
@github_url_cache[path] = false
file = RDoc::TopLevel.find_file_named(path)
file = @store.find_file_named(path)
if file
base_url = repository_url(path)
if base_url
Expand All @@ -16,7 +16,7 @@ def github_url(path)
end
@github_url_cache[path]
end

protected

def have_git?
Expand All @@ -33,7 +33,7 @@ def commit_sha1(path)
m = s.match(/commit\s+(\S+)/)
m ? m[1] : false
end

def repository_url(path)
return false unless have_git?
s = Dir.chdir(File.join(base_dir, File.dirname(path))) do
Expand All @@ -51,7 +51,7 @@ def path_relative_to_repository(path)

def path_to_git_dir(path)
while !path.empty? && path != '.'
if (File.exists? File.join(path, '.git'))
if (File.exists? File.join(path, '.git'))
return path
end
path = File.dirname(path)
Expand Down
14 changes: 7 additions & 7 deletions lib/sdoc/templatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ def eval_template(templatefile, context)
], err.backtrace
end
end

### Load and render the erb template with the given +template_name+ within
### current context. Adds all +local_assigns+ to context
def include_template(template_name, local_assigns = {})
source = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join
templatefile = @template_dir + template_name
eval("#{source};eval_template(templatefile, binding)")
end

### Load and render the erb template in the given +templatefile+ within the
### specified +context+ (a Binding object) and write it out to +outfile+.
### Both +templatefile+ and +outfile+ should be Pathname-like objects.
def render_template( templatefile, context, outfile )
output = eval_template(templatefile, context)

# TODO delete this dirty hack when documentation for example for GeneratorMethods will not be cutted off by <script> tag
begin
if output.respond_to? :force_encoding
Expand All @@ -44,9 +44,9 @@ def render_template( templatefile, context, outfile )
output = output.gsub('<script>', '&lt;script&gt;')
end
rescue Exception => e

end

unless $dryrun
outfile.dirname.mkpath
outfile.open( 'w', 0644 ) do |file|
Expand All @@ -56,5 +56,5 @@ def render_template( templatefile, context, outfile )
debug_msg " would have written %d bytes to %s" %
[ output.length, outfile ]
end
end
end
end
end
6 changes: 3 additions & 3 deletions sdoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Gem::Specification.new do |s|
s.name = "sdoc"
s.version = "0.3.20"
s.version = "0.4.0"

s.authors = ["Vladimir Kolesnikov", "Nathan Broadbent"]
s.authors = ["Vladimir Kolesnikov", "Nathan Broadbent", "Jean Mertz"]
s.description = %q{rdoc generator html with javascript search index.}
s.summary = %q{rdoc html with javascript search index.}
s.homepage = %q{http://github.com/voloko/sdoc}
Expand All @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = ["README.md"]

s.add_runtime_dependency('rdoc', "~> 3.10")
s.add_runtime_dependency('rdoc', "~> 4.0.0.rc")
if defined?(JRUBY_VERSION)
s.platform = Gem::Platform.new(['universal', 'java', nil])
s.add_runtime_dependency("json_pure", ">= 1.1.3")
Expand Down