Skip to content
Browse files

First pass complete

  • Loading branch information...
1 parent e279270 commit 4aa40d1381fac5bc69bae6bb8e24dfb421997b40 @wycats committed Jun 13, 2010
View
2 Gemfile
@@ -1,7 +1,7 @@
source 'http://rubygems.org'
path "vendor/rails" do
- gem 'rails'
+ # gem 'rails'
gem 'actionpack'
gem 'activesupport'
gem 'actionmailer'
View
91 Gemfile.lock
@@ -1,42 +1,5 @@
-GEM
- remote: http://rubygems.org/
- specs:
- abstract (1.0.0)
- arel (0.3.3)
- activesupport (>= 3.0.0.beta)
- bluecloth (2.0.7)
- builder (2.1.2)
- bundler (0.10.pre)
- coderay (0.9.3)
- compass (0.11.alpha.0.845b790)
- haml (>= 3.0.4)
- erubis (2.6.5)
- abstract (>= 1.0.0)
- haml (3.1.0)
- i18n (0.4.0)
- mail (2.2.1)
- activesupport (>= 2.3.4)
- mime-types
- treetop (>= 1.4.5)
- memcache-client (1.8.3)
- mime-types (1.16)
- polyglot (0.3.1)
- rack (1.1.0)
- rack-mount (0.6.3)
- rack-test (0.5.4)
- rack (>= 1.0)
- rake (0.8.7)
- sqlite3-ruby (1.2.5)
- text-format (1.0.0)
- text-hyphen (~> 1.0.0)
- text-hyphen (1.0.0)
- thor (0.13.6)
- treetop (1.4.7)
- polyglot (>= 0.3.1)
- tzinfo (0.3.22)
-
PATH
- remote: /Users/wycats/Code/rails
+ remote: vendor/rails
specs:
actionmailer (3.0.0.beta3)
actionpack (= 3.0.0.beta3)
@@ -51,10 +14,6 @@ PATH
rack-test (~> 0.5.0)
activemodel (3.0.0.beta3)
activesupport (= 3.0.0.beta3)
- activerecord (3.0.0.beta3)
- activemodel (= 3.0.0.beta3)
- activesupport (= 3.0.0.beta3)
- arel (~> 0.3.3)
activeresource (3.0.0.beta3)
activemodel (= 3.0.0.beta3)
activesupport (= 3.0.0.beta3)
@@ -63,25 +22,54 @@ PATH
i18n (~> 0.4.0)
memcache-client (>= 1.7.5)
tzinfo (~> 0.3.16)
- rails (3.0.0.beta3)
- actionmailer (= 3.0.0.beta3)
- actionpack (= 3.0.0.beta3)
- activerecord (= 3.0.0.beta3)
- activeresource (= 3.0.0.beta3)
- activesupport (= 3.0.0.beta3)
- bundler (>= 0.9.19)
- railties (= 3.0.0.beta3)
railties (3.0.0.beta3)
actionpack (= 3.0.0.beta3)
activesupport (= 3.0.0.beta3)
rake (>= 0.8.3)
thor (~> 0.13.6)
PATH
- remote: /Users/wycats/Code/cool_stuff/yard
+ remote: vendor/yard
specs:
yard (0.5.5.wycats)
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ bluecloth (2.0.7)
+ builder (2.1.2)
+ coderay (0.9.3)
+ compass (0.11.alpha.0.845b790)
+ haml (>= 3.0.4)
+ erubis (2.6.5)
+ abstract (>= 1.0.0)
+ haml (3.1.0)
+ i18n (0.4.1)
+ mail (2.2.3)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ memcache-client (1.8.3)
+ mime-types (1.16)
+ polyglot (0.3.1)
+ rack (1.1.0)
+ rack-mount (0.6.3)
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rake (0.8.7)
+ sqlite3-ruby (1.2.5)
+ text-format (1.0.0)
+ text-hyphen (~> 1.0.0)
+ text-hyphen (1.0.0)
+ thor (0.13.6)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.22)
+
+PLATFORMS
+ ruby
+
DEPENDENCIES
actionmailer!
actionpack!
@@ -92,7 +80,6 @@ DEPENDENCIES
coderay
compass (~> 0.11.alpha)
haml (~> 3.1.0)
- rails!
railties!
sqlite3-ruby
yard (= 0.5.5.wycats)!
View
7 app/controllers/main_controller.rb
@@ -5,8 +5,9 @@ def index
@instance_methods = klass.public_methods(:instance)
if params[:name]
- @method = params[:name]
- name = YARD::Registry.at(params[:name]).parent.path.gsub(/::ClassMethods$/, '')
+ @method = YARD::Registry.at(params[:name])
+
+ name = @method.path.gsub(/::ClassMethods$/, "")
@module = RailsDocs::Namespace.new(YARD::Registry.at(name))
@current_class = current_methods(@class_methods).presence
@current_instance = current_methods(@instance_methods).presence
@@ -17,7 +18,7 @@ def index
def current_methods(list)
methods = if @module
- list.select do |m|
+ list.select do |m|
m.parent.path =~ /#{@module.yard_object}(::ClassMethods)?/
end
else
View
24 app/helpers/main_helper.rb
@@ -10,17 +10,17 @@ def tree_link(text, options = {})
def overview
{"ActionController::Base" =>
{
- "Layouts" => "Layouts",
- "View Helpers" => "Helpers",
- "Basic Authentication" => "HttpAuthentication::Basic",
- "Token Authentication" => "HttpAuthentication::Token",
- "CSRF Mitigation" => "RequestForgeryProtection",
- "respond_to and respond_with" => "MimeResponds",
- "Caching" => "Caching",
- "Action Caching" => "Caching::Actions",
- "Fragment Caching" => "Caching::Fragments",
- "Page Caching" => "Caching::Pages",
- "Cache Sweeping" => "Caching::Sweeping"
+ "Layouts" => "AbstractController::Layouts",
+ "View Helpers" => "ActionController::Helpers",
+ "Basic Authentication" => "ActionController::HttpAuthentication::Basic",
+ "Token Authentication" => "ActionController::HttpAuthentication::Token",
+ "CSRF Mitigation" => "ActionController::RequestForgeryProtection",
+ "respond_to and respond_with" => "ActionController::MimeResponds",
+ "Caching" => "ActionController::Caching",
+ "Action Caching" => "ActionController::Caching::Actions",
+ "Fragment Caching" => "ActionController::Caching::Fragments",
+ "Page Caching" => "ActionController::Caching::Pages",
+ "Cache Sweeping" => "ActionController::Caching::Sweeping"
}
}
end
@@ -32,7 +32,7 @@ def display_method_signature(meth)
default ? "#{name}=#{default}" : name
end.join(", ")
- "## #{meth.name}(#{params})\n\n#{param_meth.docstring}\n".html_safe
+ "<h2 id='#{meth.name}'>#{meth.name}(#{params})</h2>\n\n#{param_meth.docstring}\n".html_safe
end
def class_list
View
2 app/views/main/_method.html.haml
@@ -2,4 +2,4 @@
- if @method == method.path
%strong= method.name
- else
- = link_to(method.name, method)
+ = link_to(method.name, method_path(method) + params[:suffix].to_s + "##{method.name}", "data-name" => method.name)
View
2 app/views/main/index.html.haml
@@ -33,7 +33,7 @@
%h1 Overview
%ul
- overview["ActionController::Base"].each do |title, klass|
- %li= title
+ %li= link_to title, method_path(klass) + params[:suffix].to_s
#class-level.method-list
%h1 Class Level
View
73 lib/tasks/generate.rake
@@ -1,16 +1,75 @@
+require "fileutils"
+require "logger"
+
+ENV["LOG"] = "1"
+
+class StaticGenerator
+ def initialize(location, dest = location)
+ @session = ActionDispatch::Integration::Session.new(Rails.application)
+ @location = location
+ @dest = dest
+ @logger = Logger.new(STDOUT)
+ @logger.level = ENV["LOG"] ? Logger::DEBUG : Logger::FATAL
+ FileUtils.mkdir_p(Pathname.new(Rails.public_path).join(dest[1..-1]).dirname)
+ end
+
+ def generate
+ location = @location.gsub(/#/, "---").gsub(/\[/, "%5B").gsub(/\]/, "%5D")
+ dest = @dest.gsub(/#/, "---").gsub(/\[/, "%5B").gsub(/\]/, "%5D")
+
+ @logger.debug "Getting #{location}"
+
+ @session.get(location, suffix: ".html")
+
+ dest = "#{Rails.public_path}#{dest}"
+
+ File.open("#{dest}.html", "w") do |file|
+ file.puts @session.response.body
+ end
+ end
+end
+
task :generate => :environment do
+ include MainHelper
+
+ Dir["#{Rails.public_path}/{index.html,modules}"].each do |file|
+ FileUtils.rm_rf(file)
+ end
+
klass = RailsDocs::Namespace.new(YARD::Registry.at("ActionController::Base"))
@class_methods = klass.public_methods(:class)
@instance_methods = klass.public_methods(:instance)
- session = ActionDispatch::Integration::Session.new(Rails.application)
+ modules = (@class_methods + @instance_methods).map do |m|
+ m.parent.path.gsub(/::ClassMethods$/, '')
+ end.uniq!
- FileUtils.mkdir_p("#{Rails.public_path}/modules")
+ StaticGenerator.new("/", "/index").generate
- @class_methods.each do |method|
- session.get("/modules/#{method.path}")
- File.open("#{Rails.public_path}/modules/#{method.path}", "w") do |file|
- files.puts session.response.body
- end
+ modules.each do |mod|
+ StaticGenerator.new("/modules/#{mod}").generate
end
+
+ # (@class_methods + @instance_methods).each do |method|
+ # StaticGenerator.new("/modules/#{method.path}").generate
+ # end
+
+ # session = ActionDispatch::Integration::Session.new(Rails.application)
+ #
+ # FileUtils.mkdir_p("#{Rails.public_path}/modules")
+ #
+ # session.get("/", suffix: ".html")
+ #
+ # File.open("#{Rails.public_path}/index.html", "w") do |file|
+ # file.puts session.response.body
+ # end
+ #
+ # (@class_methods + @instance_methods).each do |method|
+ # path = method.path.gsub(/#/, "---")
+ # session.get("/modules/#{Rack::Utils.escape(path)}", suffix: ".html")
+ #
+ # File.open("#{Rails.public_path}/modules/#{path}.html", "w") do |file|
+ # file.puts session.response.body
+ # end
+ # end
end
View
2 lib/yard_ext/code_objects.rb
@@ -23,7 +23,7 @@ def to_model
end
def to_param
- path
+ parent.path.gsub(/::ClassMethods$/, '')
end
end
end
View
51 public/javascripts/application.js
@@ -1,6 +1,3 @@
-// Place your application-specific JavaScript functions and classes here
-// This file is automatically included by javascript_include_tag :defaults
-
jQuery(function() {
function pathFor(link) {
return $(link).parents("li").map(function() {
@@ -9,9 +6,53 @@ jQuery(function() {
}
$("#tree li a").click(function() {
- console.log(pathFor(this));
+ // console.log(pathFor(this));
return false;
});
- $("a:contains(controllers)").parent().addClass("active")
+ $("a:contains(controllers)").parent().addClass("active");
+
+ $("#methods, #details").bind("scroll", function(e) {
+ if($(this).scrollTop() == 4) $(this).scrollTop($(this).data("top"));
+ else $(this).data("top", $(this).scrollTop());
+ });
+
+ $(".yellow").live("webkitTransitionEnd", function() {
+ $(this).removeClass("yellow");
+ });
+
+ var currentURL;
+
+ function gotoName(name) {
+ if(name) {
+ var element = $("[id='" + name + "']");
+ var top = element.offset().top;
+ $("#details").scrollTop(top);
+ element.addClass("yellow");
+ }
+ }
+
+ $("div.method-list li a").click(function(e) {
+ e.preventDefault();
+
+ var url = $(this).attr("href");
+ var moduleURL = url.match(/(.*)(#.*)/);
+ moduleURL = moduleURL ? moduleURL[1] : url;
+ var name = $(this).attr("data-name");
+
+ $("#methods a").removeClass("current");
+ $(this).addClass("current");
+
+ if(currentURL == moduleURL) {
+ gotoName(name);
+ } else {
+ currentURL = moduleURL;
+
+ $.get(url, function(html) {
+ $("#details").replaceWith($("#details", html));
+ gotoName(name);
+ });
+ }
+ return false;
+ });
});
View
10 public/stylesheets/sass/screen.sass
@@ -37,6 +37,16 @@ html, body, #page
#tree, #methods, #details
padding: 10px
+.yellow
+ -webkit-transition-property: background-color
+ -webkit-transition-duration: 500ms
+ background-color: #ffc
+
+*
+ -webkit-transition-property: background-color
+ -webkit-transition-duration: 1000ms
+ background-color: inherit
+
#tree
padding: 0
background-color: #e8e8e8

0 comments on commit 4aa40d1

Please sign in to comment.
Something went wrong with that request. Please try again.