Przeglądaj źródła

Add Ruby on Rails documentation

Thibaut 12 lat temu
rodzic
commit
dc0e174253

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -143,6 +143,11 @@ credits = [
     '1993-2013 Yukihiro Matsumoto',
     'Ruby',
     'https://www.ruby-lang.org/en/about/license.txt'
+  ], [
+    'Ruby on Rails',
+    '2004-2013 David Heinemeier Hansson',
+    'MIT',
+    'https://raw.github.com/rails/rails/master/activerecord/MIT-LICENSE'
   ], [
     'Sass',
     '2006-2013 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',

+ 4 - 1
assets/javascripts/templates/pages/news_tmpl.coffee

@@ -24,7 +24,10 @@ newsItem = (date, news) ->
   result
 
 app.news = [
-  [ 1384560000000, # November 16, 2013
+  [ 1384819200000, # November 19, 2013
+    """ New <a href="/rails/">Ruby on Rails</a> documentation """
+  ], [
+    1384560000000, # November 16, 2013
     """ New <a href="/ruby/">Ruby</a> documentation """
   ], [
     1382572800000, # October 24, 2013

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -40,3 +40,4 @@
 ._icon-lodash:before        { background-position: -1rem -5rem; }
 ._icon-php:before           { background-position: -2rem -5rem; }
 ._icon-ruby:before          { background-position: -3rem -5rem; }
+._icon-rails:before         { background-position: -4rem -5rem; }

+ 73 - 0
lib/docs/filters/rails/entries.rb

@@ -0,0 +1,73 @@
+module Docs
+  class Rails
+    class EntriesFilter < Docs::Rdoc::EntriesFilter
+      TYPE_BY_NAME_MATCHES = {
+        /Assertions|::Test|Fixture/                          => 'Testing',
+        /\AActiveRecord.+Assoc/                              => 'ActiveRecord/Associations',
+        /\AActiveRecord.+Attribute/                          => 'ActiveRecord/Attributes',
+        /\AActiveRecord.+(Migration|Schema|Adapters::Table)/ => 'ActiveRecord/Migrations',
+        /\AActiveSupport.+(Subscriber|Notifications)/        => 'ActiveSupport/Instrumentation',
+        /\A(False|Nil|True)Class/                            => 'Boolean' }
+
+      TYPE_BY_NAME_STARTS_WITH = {
+        'ActionDispatch::Integration' => 'Testing',
+        'ActionDispatch::Routing'     => 'ActionDispatch/Routing',
+        'ActionView::Helpers'         => 'ActionView/Helpers',
+        'ActiveModel::Errors'         => 'ActiveModel/Validation',
+        'ActiveModel::Valid'          => 'ActiveModel/Validation',
+        'ActiveRecord::Batches'       => 'ActiveModel/Query',
+        'ActiveRecord::Calculations'  => 'ActiveModel/Query',
+        'ActiveRecord::Connection'    => 'ActiveModel/Connection',
+        'ActiveRecord::FinderMethods' => 'ActiveModel/Query',
+        'ActiveRecord::Query'         => 'ActiveModel/Query',
+        'ActiveRecord::Relation'      => 'ActiveModel/Relation',
+        'ActiveRecord::Result'        => 'ActiveModel/Connection',
+        'ActiveRecord::Scoping'       => 'ActiveModel/Query',
+        'ActiveRecord::SpawnMethods'  => 'ActiveModel/Query',
+        'ActiveSupport::Cach'         => 'ActiveSupport/Caching',
+        'ActiveSupport::Hash'         => 'ActiveSupport/Hash',
+        'ActiveSupport::Inflector'    => 'ActiveSupport/Inflector',
+        'ActiveSupport::Ordered'      => 'ActiveSupport/Hash',
+        'ActiveSupport::Time'         => 'ActiveSupport/TimeZones',
+        'Rails::Application'          => 'Rails/Application',
+        'Rails::Engine'               => 'Rails/Engine',
+        'Rails::Railtie'              => 'Rails/Railtie' }
+
+      def get_name
+        name = super
+        name.sub! 'HashWithIndifferentAccess::HashWithIndifferentAccess', 'HashWithIndifferentAccess'
+        name
+      end
+
+      def get_type
+        parent = at_css('.meta-parent').try(:content).to_s
+
+        if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') }
+          return 'Errors'
+        end
+
+        TYPE_BY_NAME_MATCHES.each_pair do |key, value|
+          return value if name =~ key
+        end
+
+        TYPE_BY_NAME_STARTS_WITH.each_pair do |key, value|
+          return value if name.start_with?(key)
+        end
+
+        super
+      end
+
+      def include_default_entry?
+        super && !skip?
+      end
+
+      def additional_entries
+        skip? ? [] : super
+      end
+
+      def skip?
+        @skip ||= !css('p').any? { |node| node.content.present? }
+      end
+    end
+  end
+end

+ 96 - 0
lib/docs/scrapers/rdoc/rails.rb

@@ -0,0 +1,96 @@
+module Docs
+  class Rails < Rdoc
+    # Generated with:
+    # find \
+    #   actionmailer \
+    #   actionpack \
+    #   activemodel \
+    #   activerecord \
+    #   activesupport \
+    #   railties \
+    #   -name '*.rb' \
+    #   -not -name 'version.rb' \
+    #   -not -wholename '*generators/*' \
+    #   -not -wholename '*test/*' \
+    #   -not -wholename '*examples/*' \
+    # | xargs \
+    #   rdoc --format=darkfish --no-line-numbers --op=rdoc --visibility=public
+
+    self.name = 'Ruby on Rails'
+    self.slug = 'rails'
+    self.version = '4.0.1'
+    self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Rails'
+
+    html_filters.replace 'rdoc/entries', 'rails/entries'
+
+    options[:root_title] = 'Ruby on Rails'
+
+    options[:skip] += %w(
+      AbstractController/Callbacks.html
+      AbstractController/UrlFor.html
+      ActionController.html
+      ActionController/Instrumentation.html
+      ActionController/ModelNaming.html
+      ActionController/Rendering.html
+      ActionController/Rescue.html
+      ActionController/UrlFor.html
+      ActionDispatch/DebugExceptions.htnl
+      ActionDispatch/Http/FilterParameters.html
+      ActionDispatch/Http/URL.html
+      ActionDispatch/Integration/Runner.html
+      ActionDispatch/Integration/Session.html
+      ActionDispatch/Reloader.html
+      ActionDispatch/RequestId.html
+      ActionDispatch/Routing/HtmlTableFormatter.html
+      ActionDispatch/Routing/Mapper.html
+      ActionDispatch/ShowExceptions.html
+      ActionView.html
+      ActionView/Context.html
+      ActionView/DependencyTracker/ERBTracker.html
+      ActionView/FileSystemResolver.html
+      ActionView/FixtureResolver.html
+      ActionView/LogSubscriber.html
+      ActionView/ModelNaming.html
+      ActionView/Template/Handlers/Erubis.html
+      ActiveModel.html
+      ActiveModel/Lint/Tests.html
+      ActiveRecord.html
+      ActiveRecord/DynamicMatchers/Finder.html
+      ActiveRecord/Sanitization.html
+      ActiveRecord/Tasks/DatabaseTasks.html
+      ActiveSupport.html
+      ActiveSupport/Configurable/Configuration.html
+      ActiveSupport/Dependencies/WatchStack.html
+      ActiveSupport/DescendantsTracker.html
+      ActiveSupport/FileUpdateChecker.html
+      ActiveSupport/Notifications/Fanout.html
+      ActiveSupport/Testing/ConstantLookup.html
+      ActiveSupport/Testing/Declarative.html
+      ActiveSupport/Testing/Isolation/Subprocess.html
+      Rails/API/Task.html
+      Rails/ConsoleMethods.html)
+
+    options[:skip_patterns] = [
+      /\AAbstractController\/ViewPaths/,
+      /\AActionController\/Caching(?!\/Fragments|\.)/,
+      /\AActionController\/HideActions/,
+      /\AActionController\/RequestForgeryProtection\/ProtectionMethods/,
+      /\AActionController\/Test/,
+      /\AActionDispatch\/RemoteIp/,
+      /\AActionDispatch\/Test/,
+      /\AActionMailer\/DeliveryMethods/,
+      /\AActionView\/LookupContext/,
+      /\AActionView\/Resolver/,
+      /\AActiveRecord\/ConnectionAdapters\/(?!DatabaseStatements|SchemaStatements|Table)/,
+      /\AActiveSupport\/JSON\//,
+      /\AActiveSupport\/Multibyte\/Unicode\//,
+      /\AActiveSupport\/XML/i,
+      /\ALogger/,
+      /\ASourceAnnotationExtractor/]
+
+    options[:attribution] = <<-HTML
+      &copy; 2004&ndash;2013 David Heinemeier Hansson<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

BIN
public/icons/docs/rails/16.png


BIN
public/icons/docs/rails/16@2x.png


+ 1 - 0
public/icons/docs/rails/SOURCE

@@ -0,0 +1 @@
+http://commons.wikimedia.org/wiki/File:Ruby_logo.svg