Sfoglia il codice sorgente

Add Laravel documentation

Thibaut 11 anni fa
parent
commit
060052beb7

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


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

@@ -155,6 +155,11 @@ credits = [
     'Steven Sanderson, the Knockout.js team, and other contributors',
     'MIT',
     'https://raw.github.com/knockout/knockout/master/LICENSE'
+  ], [
+    'Laravel',
+    'Taylor Otwell',
+    'MIT',
+    'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'
   ], [
     'Less',
     '2009-2014 The Core Less Team',

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

@@ -24,7 +24,10 @@ newsItem = (date, news) ->
   result
 
 app.news = [
-  [ 1399161600000, # May 4, 2014
+  [ 1400976000000, # May 25, 2014
+    """ New <a href="/laravel/">Laravel</a> documentation """,
+  ], [
+    1399161600000, # May 4, 2014
     """ New <a href="/express/">Express</a>, <a href="/grunt/">Grunt</a>, and <a href="/maxcdn/">MaxCDN</a> documentations """,
   ], [
     1396742400000, # April 6, 2014

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -39,6 +39,7 @@
         'pages/knockout',
         'pages/git',
         'pages/grunt',
+        'pages/laravel',
         'pages/less',
         'pages/lodash',
         'pages/maxcdn',

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

@@ -4,7 +4,7 @@
   width: 1rem;
   height: 1rem;
   background-image: image-url('icons.png');
-  background-size: 5rem 9rem;
+  background-size: 5rem 10rem;
 }
 
 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -56,3 +56,4 @@
 ._icon-express:before       { background-position: -2rem -8rem; }
 ._icon-grunt:before         { background-position: -3rem -8rem; }
 ._icon-maxcdn:before        { background-position: -4rem -8rem; }
+._icon-laravel:before       { background-position: 0 -9rem; }

+ 8 - 0
assets/stylesheets/pages/_laravel.scss

@@ -0,0 +1,8 @@
+._sami {
+  h2 { @extend %block-heading; }
+  h3 { @extend %block-label, %label-blue; }
+  h4 { font-size: 1em; }
+
+  blockquote { @extend %note; }
+  p > code { @extend %label; }
+}

+ 55 - 0
lib/docs/filters/laravel/clean_html.rb

@@ -0,0 +1,55 @@
+module Docs
+  class Laravel
+    class CleanHtmlFilter < Filter
+      def call
+        if subpath.start_with?('/api')
+          api
+        else
+          other
+        end
+
+        doc
+      end
+
+      def api
+        css('#footer', '.location').remove
+
+        # Replace .header with <h1>
+        css('.header > h1').each do |node|
+          node.parent.before(node).remove
+          node.content = 'Laravel' if root_page?
+        end
+
+        # Remove <abbr>
+        css('a > abbr').each do |node|
+          node.parent['title'] = node['title']
+          node.before(node.children).remove
+        end
+
+        # Clean up headings
+        css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node|
+          node.before(node.children).remove
+        end
+
+        # Remove empty <td>
+        css('td').each do |node|
+          node.remove if node.content =~ /\A\s+\z/
+        end
+      end
+
+      def other
+        @doc = at_css('#docs-content')
+
+        # Clean up headings
+        css('h2 > a').each do |node|
+          node.before(node.children).remove
+        end
+
+        # Remove code highlighting
+        css('pre').each do |node|
+          node.content = node.content
+        end
+      end
+    end
+  end
+end

+ 40 - 0
lib/docs/filters/laravel/entries.rb

@@ -0,0 +1,40 @@
+module Docs
+  class Laravel
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        if api_page?
+          at_css('h1').content.strip.split('\\').last
+        else
+          at_css('h1').content.strip
+        end
+      end
+
+      def get_type
+        if api_page?
+          type = at_css('h1').content.strip.remove('Illuminate\\').remove(/\\\w+?\z/)
+          type.end_with?('Console') ? type.split('\\').first : type
+        else
+          'Guides'
+        end
+      end
+
+      def additional_entries
+        return [] unless api_page?
+
+        css('h3[id^="method_"]').each_with_object [] do |node, entries|
+          next if node.at_css('.location').content.start_with?('in')
+
+          name = node['id'].remove('method_')
+          name.prepend "#{self.name}::"
+          name << '()'
+
+          entries << [name, node['id']]
+        end
+      end
+
+      def api_page?
+        subpath.start_with?('/api')
+      end
+    end
+  end
+end

+ 39 - 0
lib/docs/scrapers/laravel.rb

@@ -0,0 +1,39 @@
+module Docs
+  class Laravel < UrlScraper
+    self.name = 'Laravel'
+    self.slug = 'laravel'
+    self.type = 'laravel'
+    self.version = '4.1.29'
+    self.base_url = 'http://laravel.com'
+    self.root_path = '/docs/introduction'
+    self.initial_paths = %w(/api/4.1/namespaces.html)
+
+    html_filters.push 'laravel/entries', 'laravel/clean_html'
+
+    options[:container] = ->(filter) {
+      filter.subpath.start_with?('/api') ? nil : '#documentation > article'
+    }
+
+    options[:only_patterns] = [
+      /\A\/api\/4\.1\//,
+      /\A\/docs\//]
+
+    options[:skip] = %w(
+      /docs/quick
+      /docs/releases
+      /docs/upgrade
+      /docs/artisan
+      /docs/commands
+      /api/4.1/panel.html
+      /api/4.1/classes.html
+      /api/4.1/interfaces.html
+      /api/4.1/traits.html
+      /api/4.1/doc-index.html
+      /api/4.1/Illuminate.html)
+
+    options[:attribution] = <<-HTML
+      &copy; Taylor Otwell<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://github.com/laravel/art