Browse Source

Merge pull request #1486 from dohsimpson/add_react_bootstrap_doc

Added Documentation for React-bootstrap
Simon Legner 4 năm trước cách đây
mục cha
commit
7480257c59

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2021-02-26",
+    "New documentation: <a href=\"/react_bootstrap/\">React Bootstrap</a>"
+  ],
   [
     "2021-01-03",
     "New documentation: <a href=\"/ocaml/\">OCaml</a>"

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

@@ -686,6 +686,11 @@ credits = [
     '2013-present Facebook Inc.',
     'MIT',
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE'
+  ], [
+    'React Bootstrap',
+    '2014-present Stephen J. Collings, Matthew Honnibal, Pieter Vanderwerff',
+    'MIT',
+    'https://raw.githubusercontent.com/react-bootstrap/react-bootstrap/master/LICENSE'
   ], [
     'ReactiveX',
     'ReactiveX contributors',

+ 33 - 0
lib/docs/filters/react_bootstrap/clean_html.rb

@@ -0,0 +1,33 @@
+module Docs
+  class ReactBootstrap
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = doc.at_css('main')
+
+        css('.flex-column.d-flex').remove
+        css('header').remove
+        css('.bs-example').remove
+
+        css('.position-relative pre').each do |node|
+          node.content = node.children.map(&:content).join("\n")
+          node.remove_attribute('style')
+          node['data-language'] = 'jsx'
+          node.parent.replace(node)
+        end
+
+        css('div, main, pre, h1, h2, h3, h4, h5, h6, a, p').each do |node|
+          node.delete 'class'
+        end
+        css('h1, h2, h3, h4, h5, h6').each do |node|
+          node.css('a').remove
+          node.content = node.content
+        end
+
+        css('#___gatsby, #gatsby-focus-wrapper').each do |node|
+          node.delete 'id'
+        end
+        doc
+      end
+    end
+  end
+end

+ 23 - 0
lib/docs/filters/react_bootstrap/entries.rb

@@ -0,0 +1,23 @@
+module Docs
+  class ReactBootstrap
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('#rb-docs-content h1, #rb-docs-content h2').content
+        if name.end_with? '#'
+          name = name[0..-2]
+        end
+        name
+      end
+
+      def get_type
+        type = slug.split('/')[0..-2].join(': ')
+        if type == ''
+          type = slug.split('/').join('')
+        end
+        type.gsub!('-', ' ')
+        type = type.split.map(&:capitalize).join(' ')
+        type
+      end
+    end
+  end
+end

+ 35 - 0
lib/docs/scrapers/react_bootstrap.rb

@@ -0,0 +1,35 @@
+module Docs
+  class ReactBootstrap < UrlScraper
+    self.name = 'React Bootstrap'
+    self.slug = 'react_bootstrap'
+    self.type = 'simple'
+    self.release = '1.5.0'
+    self.base_url = 'https://react-bootstrap.github.io/'
+
+    self.links = {
+      home: 'https://react-bootstrap.github.io',
+      code: 'https://github.com/react-bootstrap/react-bootstrap'
+    }
+
+    html_filters.push 'react_bootstrap/entries', 'react_bootstrap/clean_html'
+
+    options[:skip] = %w(
+      react-overlays/
+    )
+
+    options[:replace_paths] = {
+    }
+
+    options[:trailing_slash] = true
+
+    options[:attribution] = <<-HTML
+      &copy; 2014&ndash;present Stephen J. Collings, Matthew Honnibal, Pieter Vanderwerff<br>
+      Licensed under the MIT License (MIT).
+    HTML
+
+    def get_latest_version(opts)
+      doc = fetch_doc('https://react-bootstrap.github.io/', opts)
+      doc.at_css('#t-version>a').content.split()[0].strip[1..-1]
+    end
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://github.com/react-bootstrap/react-bootstrap/blob/master/www/static/logo.svg