Browse Source

Update and improve Express.js documentation (4.11.1)

Thibaut 11 years ago
parent
commit
31d0f25035

+ 1 - 1
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -132,7 +132,7 @@ credits = [
     'https://raw.github.com/emberjs/ember.js/master/LICENSE'
   ], [
     'Express',
-    '2009-2014 TJ Holowaychuk',
+    '2009-2015 TJ Holowaychuk',
     'MIT',
     'https://raw.githubusercontent.com/visionmedia/express/master/LICENSE'
   ], [

+ 2 - 0
assets/stylesheets/pages/_express.scss

@@ -5,4 +5,6 @@
   h2 { @extend %block-heading; }
   h3 { @extend %block-label, %label-blue; }
   p > code { @extend %label; }
+  .doc-box { @extend %note; }
+  .doc-warn { @extend %note-red; }
 }

+ 4 - 2
lib/docs/filters/express/clean_html.rb

@@ -2,12 +2,14 @@ module Docs
   class Express
     class CleanHtmlFilter < Filter
       def call
-        at_css('h1').remove
-
         css('section').each do |node|
           node.before(node.children).remove
         end
 
+        doc.child.remove while doc.child.name != 'h1'
+
+        at_css('h1').remove if root_page?
+
         # Put id attributes on headings
         css('h2 + a[name]').each do |node|
           node.previous_element['id'] = node['name']

+ 15 - 0
lib/docs/filters/express/entries.rb

@@ -1,7 +1,22 @@
 module Docs
   class Express
     class EntriesFilter < Docs::EntriesFilter
+      TYPES_BY_PATH = {
+        'starter' => 'Getting started',
+        'guide' => 'Guide',
+        'advanced' => 'Guide'
+      }
+
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        TYPES_BY_PATH[slug.split('/').first]
+      end
+
       def additional_entries
+        return [] unless root_page?
         type = 'Application'
 
         doc.children.each_with_object [] do |node, entries|

+ 13 - 6
lib/docs/scrapers/express.rb

@@ -2,17 +2,24 @@ module Docs
   class Express < UrlScraper
     self.name = 'Express'
     self.type = 'express'
-    self.version = '4.10.0'
-    self.base_url = 'http://expressjs.com/4x/api.html'
+    self.version = '4.11.1'
+    self.base_url = 'http://expressjs.com/'
+    self.root_path = '4x/api.html'
 
     html_filters.push 'express/clean_html', 'express/entries', 'title'
 
-    options[:title] = 'Express'
-    options[:container] = '#api-doc'
-    options[:skip_links] = true
+    options[:title] = false
+    options[:root_title] = 'Express'
+    options[:container] = ->(filter) { filter.root_page? ? '#api-doc' : '.content' }
+
+    options[:only_patterns] = [
+      /\Astarter/,
+      /\Aguide/,
+      /\Aadvanced/
+    ]
 
     options[:attribution] = <<-HTML
-      &copy; 2009&ndash;2014 TJ Holowaychuk<br>
+      &copy; 2009&ndash;2015 TJ Holowaychuk<br>
       Licensed under the MIT License.
     HTML
   end