Permalink
Browse files

Allow --main to contain class names

  • Loading branch information...
1 parent 3359687 commit b5ca84f80462344cf043cd3cc108c20b13fc43fc @Nerdmaster Nerdmaster committed Sep 3, 2011
Showing with 15 additions and 6 deletions.
  1. +15 −6 lib/sdoc/generator.rb
View
@@ -355,20 +355,29 @@ def generate_file_files
end
end
- def index_file
- if @options.main_page && file = @files.find { |f| f.full_name == @options.main_page }
- file
- else
- @files.first
+ ### Determines index path based on @options.main_page (or lack thereof)
+ def index_path
+ # Break early to avoid a big if block when no main page is specified
+ default = @files.first.path
+ return default unless @options.main_page
+
+ # Handle attempts to hit class docs directly
+ if @options.main_page.include?("::")
+ return "%s/%s.html" % [class_dir, @options.main_page.gsub("::", "/")]
+ end
+ if file = @files.find { |f| f.full_name == @options.main_page }
+ return file.path
end
+
+ # Nothing else worked, so stick with the default
+ return default
end
### Create index.html with frameset
def generate_index_file
debug_msg "Generating index file in #@outputdir"
templatefile = @template_dir + 'index.rhtml'
outfile = @outputdir + 'index.html'
- index_path = index_file.path
self.render_template( templatefile, binding(), outfile )
end

0 comments on commit b5ca84f

Please sign in to comment.