From f678a90bdb8401902407b4be9dea90bae8cedc9b Mon Sep 17 00:00:00 2001 From: Rob Gleeson Date: Sun, 22 May 2011 22:24:24 +0100 Subject: [PATCH 1/3] Expand path to '.yardoc' for daemon mode. This commit should solve any problems encountered with yard server and the -d switch. --- lib/yard/cli/server.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/yard/cli/server.rb b/lib/yard/cli/server.rb index 1f5d6a951..7c0252418 100644 --- a/lib/yard/cli/server.rb +++ b/lib/yard/cli/server.rb @@ -67,7 +67,7 @@ def select_adapter def add_libraries(args) (0...args.size).step(2) do |index| library, yardoc = args[index], args[index + 1] - yardoc ||= '.yardoc' + yardoc ||= File.expand_path('.yardoc') if File.exist?(yardoc) libraries[library] ||= [] libraries[library] << YARD::Server::LibraryVersion.new(library, nil, yardoc) @@ -148,7 +148,7 @@ def optparse(*args) end Yardoc.run('-n') end - add_libraries([File.basename(Dir.pwd), '.yardoc']) + add_libraries([File.basename(Dir.pwd), File.expand_path('.yardoc')]) else add_libraries(args) options[:single_library] = false if libraries.size > 1 @@ -156,4 +156,4 @@ def optparse(*args) end end end -end \ No newline at end of file +end From c22c9acc671f855d2b82023ee30bb38c5cddab77 Mon Sep 17 00:00:00 2001 From: Rob Gleeson Date: Sun, 22 May 2011 22:44:04 +0100 Subject: [PATCH 2/3] Resolve relative links in daemon mode. --- lib/yard/cli/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yard/cli/server.rb b/lib/yard/cli/server.rb index 7c0252418..3642fca75 100644 --- a/lib/yard/cli/server.rb +++ b/lib/yard/cli/server.rb @@ -67,7 +67,7 @@ def select_adapter def add_libraries(args) (0...args.size).step(2) do |index| library, yardoc = args[index], args[index + 1] - yardoc ||= File.expand_path('.yardoc') + yardoc = yardoc.nil? ? File.expand_path('.yardoc') : File.expand_path(yardoc) if File.exist?(yardoc) libraries[library] ||= [] libraries[library] << YARD::Server::LibraryVersion.new(library, nil, yardoc) From fb73589fb4eac371f0dc252faebb72f6f7cab012 Mon Sep 17 00:00:00 2001 From: Rob Gleeson Date: Mon, 23 May 2011 00:16:34 +0100 Subject: [PATCH 3/3] Fix failing specs. --- lib/yard/cli/server.rb | 2 +- spec/cli/server_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/yard/cli/server.rb b/lib/yard/cli/server.rb index 3642fca75..ab93f59ac 100644 --- a/lib/yard/cli/server.rb +++ b/lib/yard/cli/server.rb @@ -142,7 +142,7 @@ def optparse(*args) parse_options(opts, args) if args.empty? && libraries.empty? - if !File.exist?('.yardoc') + if !File.exist? File.expand_path('.yardoc') log.enter_level(Logger::INFO) do log.info "No .yardoc file found in current directory, parsing source before starting server..." end diff --git a/spec/cli/server_spec.rb b/spec/cli/server_spec.rb index 5b0c579bf..592d72df3 100644 --- a/spec/cli/server_spec.rb +++ b/spec/cli/server_spec.rb @@ -24,11 +24,11 @@ def unstub_adapter def run(*args) if @libraries.empty? - library = Server::LibraryVersion.new(File.basename(Dir.pwd), nil, '.yardoc') + library = Server::LibraryVersion.new(File.basename(Dir.pwd), nil, File.expand_path('.yardoc')) @libraries = {library.name => [library]} end unless @no_verify_libraries - @libraries.values.each {|libs| libs.each {|lib| File.should_receive(:exist?).at_least(1).times.with(lib.yardoc_file).and_return(true) } } + @libraries.values.each {|libs| libs.each {|lib| File.should_receive(:exist?).at_least(1).times.with(File.expand_path(lib.yardoc_file)).and_return(true) } } end unless @no_adapter_mock @cli.stub!(:adapter).and_return(@adapter) @@ -40,19 +40,19 @@ def run(*args) it "should default to current dir if no library is specified" do Dir.should_receive(:pwd).and_return('/path/to/foo') - @libraries['foo'] = [Server::LibraryVersion.new('foo', nil, '.yardoc')] + @libraries['foo'] = [Server::LibraryVersion.new('foo', nil, File.expand_path('.yardoc'))] run end it "should use .yardoc as yardoc file is library list is odd" do - @libraries['a'] = [Server::LibraryVersion.new('a', nil,'.yardoc')] + @libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('.yardoc'))] run 'a' end it "should force multi library if more than one library is listed" do @options[:single_library] = false - @libraries['a'] = [Server::LibraryVersion.new('a', nil, 'b')] - @libraries['c'] = [Server::LibraryVersion.new('c', nil, '.yardoc')] + @libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('b'))] + @libraries['c'] = [Server::LibraryVersion.new('c', nil, File.expand_path('.yardoc'))] run %w(a b c) end @@ -167,4 +167,4 @@ def run(*args) end end end -end \ No newline at end of file +end