浏览代码

Add Mongoose documentation

Thibaut 11 年之前
父节点
当前提交
5d0f2cd5a6

二进制
assets/images/icons.png


二进制
assets/images/icons@2x.png


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

@@ -212,6 +212,11 @@ credits = [
     '2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors',
     'MIT',
     'https://raw.github.com/moment/moment/master/LICENSE'
+  ], [
+    'Mongoose',
+    '2010 LearnBoost',
+    'MIT',
+    'https://github.com/LearnBoost/mongoose/blob/master/README.md#license'
   ], [
     'nginx',
     '2002-2014 Igor Sysoev<br>&copy; 2011-2014 Nginx, Inc.',

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

@@ -34,7 +34,7 @@ newsItem = (date, news) ->
 
 app.news = [
   [ 1413676800000, # October 19, 2014
-    """ New <a href="/svg/">SVG</a> and <a href="/marionette">Marionette.js</a> documentations """,
+    """ New <a href="/svg/">SVG</a>, <a href="/marionette/">Marionette.js</a>, and <a href="/mongoose/">Mongoose</a> documentations """,
   ], [
     1413590400000, # October 18, 2014
     """ New <a href="/nginx/">nginx</a> documentation """,

+ 4 - 0
assets/javascripts/views/pages/mongoose.coffee

@@ -0,0 +1,4 @@
+#= require views/pages/base
+#= require views/pages/underscore
+
+app.views.MongoosePage = app.views.UnderscorePage

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

@@ -50,6 +50,7 @@
         'pages/maxcdn',
         'pages/mdn',
         'pages/moment',
+        'pages/mongoose',
         'pages/nginx',
         'pages/node',
         'pages/php',

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

@@ -68,3 +68,4 @@
 ._icon-nginx:before         { background-position: -4rem -10rem; }
 ._icon-svg:before           { background-position: 0 -11rem; }
 ._icon-marionette:before    { background-position: -1rem -11rem; }
+._icon-mongoose:before      { background-position: -2rem -11rem; }

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

@@ -0,0 +1,8 @@
+._mongoose {
+  padding-left: 1rem;
+
+  > h1, > h2, > h3 { margin-left: -1rem; }
+  > h2 { @extend %block-heading; }
+  > h3 { @extend %block-label, %label-blue; }
+  h4 { font-size: 1em; }
+}

+ 31 - 0
lib/docs/filters/mongoose/clean_html.rb

@@ -0,0 +1,31 @@
+module Docs
+  class Mongoose
+    class CleanHtmlFilter < Filter
+      def call
+        css('hr', '.showcode', '.sourcecode').remove
+
+        if slug == 'api'
+          at_css('.controls').after('<h1>Mongoose API</h1>')
+
+          css('.private', '.controls').remove
+
+          css('a + .method').each do |node|
+            node.previous_element.replace("<h2>#{node.previous_element.to_html}</h2>")
+          end
+        else
+          at_css('h2').name = 'h1'
+
+          css('h3').each do |node|
+            node.name = 'h2'
+          end
+        end
+
+        css('pre > code', 'h1 + ul', '.module', '.item', 'h3 > a', 'h3 code').each do |node|
+          node.before(node.children).remove
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 39 - 0
lib/docs/filters/mongoose/entries.rb

@@ -0,0 +1,39 @@
+module Docs
+  class Mongoose
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        if slug == 'api'
+          'Mongoose'
+        else
+          at_css('h1').content
+        end
+      end
+
+      def get_type
+        if slug == 'api'
+          'Mongoose'
+        else
+          'Guides'
+        end
+      end
+
+      def additional_entries
+        return [] unless slug == 'api'
+        entries = []
+
+        css('h3[id]').each do |node|
+          next if node['id'] == 'index_'
+
+          name = node.content.strip
+          name.sub! %r{\(.+\)}, '()'
+          next if name.include?(' ')
+
+          type = name.split(/[#\.\(]/).first
+          entries << [name, node['id'], type]
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 25 - 0
lib/docs/scrapers/mongoose.rb

@@ -0,0 +1,25 @@
+module Docs
+  class Mongoose < UrlScraper
+    self.name = 'Mongoose'
+    self.type = 'mongoose'
+    self.version = '3.8.17'
+    self.base_url = 'http://mongoosejs.com/docs/'
+    self.root_path = 'index.html'
+    self.initial_paths = %w(guide.html api.html)
+
+    html_filters.push 'mongoose/clean_html', 'mongoose/entries'
+
+    options[:container] = '#content'
+
+    options[:skip] = %w(
+      faq.html
+      prior.html
+      migration.html
+      plugins)
+
+    options[:attribution] = <<-HTML
+      &copy; 2010 LearnBoost<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

二进制
public/icons/docs/mongoose/16.png


二进制
public/icons/docs/mongoose/16@2x.png