Showing the changes to lib/docs (3 of 16 files). Show all
Unified · Split
| @@ -0,0 +1,64 @@ | ||
| 1 | +module Docs | |
| 2 | + class Bootstrap | |
| 3 | + class CleanHtmlV3Filter < Filter | |
| 4 | + def call | |
| 5 | + at_css('div[role=main]').child.before(at_css('#content .container').inner_html) | |
| 6 | + @doc = at_css('div[role=main]') | |
| 7 | + | |
| 8 | + css('h1, h2, h3, h4, h5').each do |node| | |
| 9 | + node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } | |
| 10 | + end | |
| 11 | + at_css('h2').name = 'h1' | |
| 12 | + | |
| 13 | + css('hr', '.zero-clipboard', '.modal', '.panel-group').remove | |
| 14 | + | |
| 15 | + css('.bs-docs-section', '.table-responsive').each do |node| | |
| 16 | + node.before(node.children).remove | |
| 17 | + end | |
| 18 | + | |
| 19 | + css('> .show-grid', '.bs-example', '.bs-glyphicons', '.responsive-utilities-test').each do |node| | |
| 20 | + if node.previous_element['class'].try(:include?, 'bs-example') | |
| 21 | + node.remove | |
| 22 | + else | |
| 23 | + node.content = '' | |
| 24 | + node.name = 'p' | |
| 25 | + node['class'] = 'bs-example' | |
| 26 | + node.remove_attribute('data-example-id') | |
| 27 | + prev = node.previous_element | |
| 28 | + prev = prev.previous_element until prev['id'] | |
| 29 | + node.inner_html = %(<a href="#{current_url}/##{prev['id']}">Open example on getbootstrap.com</a>) | |
| 30 | + end | |
| 31 | + end | |
| 32 | + | |
| 33 | + css('.bs-example + figure').each do |node| | |
| 34 | + node.previous_element.name = 'div' | |
| 35 | + end | |
| 36 | + | |
| 37 | + css('div[class*="col-"]').each do |node| | |
| 38 | + node['class'] = 'col' | |
| 39 | + end | |
| 40 | + | |
| 41 | + css('.__cf_email__').each do |node| | |
| 42 | + node.replace(decode_cloudflare_email(node['data-cfemail'])) | |
| 43 | + end | |
| 44 | + | |
| 45 | + css('figure.highlight').each do |node| | |
| 46 | + code = node.at_css('code') | |
| 47 | + node['data-language'] = code['data-lang'] | |
| 48 | + node.content = code.content | |
| 49 | + node.name = 'pre' | |
| 50 | + end | |
| 51 | + | |
| 52 | + css('table, tr, td, th, pre').each do |node| | |
| 53 | + node.remove_attribute('class') | |
| 54 | + end | |
| 55 | + | |
| 56 | + css('thead td:empty').each do |node| | |
| 57 | + node.name = 'th' | |
| 58 | + end | |
| 59 | + | |
| 60 | + doc | |
| 61 | + end | |
| 62 | + end | |
| 63 | + end | |
| 64 | +end | |
| @@ -0,0 +1,65 @@ | ||
| 1 | +module Docs | |
| 2 | + class Bootstrap | |
| 3 | + class EntriesV3Filter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + at_css('h1').content | |
| 6 | + end | |
| 7 | + | |
| 8 | + def get_type | |
| 9 | + name | |
| 10 | + end | |
| 11 | + | |
| 12 | + def additional_entries | |
| 13 | + return [] if root_page? | |
| 14 | + entries = [] | |
| 15 | + | |
| 16 | + css('.bs-docs-sidenav > li').each do |node| | |
| 17 | + link = node.at_css('a') | |
| 18 | + name = link.content | |
| 19 | + next if IGNORE_ENTRIES.include?(name) | |
| 20 | + | |
| 21 | + id = link['href'].remove('#') | |
| 22 | + entries << [name, id] | |
| 23 | + next if name =~ /Sass|Less|Glyphicons/ | |
| 24 | + | |
| 25 | + node.css('> ul > li > a').each do |link| | |
| 26 | + n = link.content | |
| 27 | + next if n.start_with?('Ex: ') || n.start_with?('Default ') || n =~ /example/i || IGNORE_ENTRIES.include?(n) | |
| 28 | + id = link['href'].remove('#') | |
| 29 | + n.downcase! | |
| 30 | + n.prepend "#{name}: " | |
| 31 | + entries << [n, id] | |
| 32 | + end | |
| 33 | + end | |
| 34 | + | |
| 35 | + %w(modals dropdowns scrollspy tabs tooltips popovers alerts buttons collapse carousel affix).each do |dom_id| | |
| 36 | + css("##{dom_id}-options + p + div tbody td:first-child").each do |node| | |
| 37 | + name = node.content.strip | |
| 38 | + id = node.parent['id'] = "#{dom_id}-#{name.parameterize}-option" | |
| 39 | + name.prepend "#{dom_id.singularize.titleize}: " | |
| 40 | + name << ' (option)' | |
| 41 | + entries << [name, id] | |
| 42 | + end | |
| 43 | + | |
| 44 | + css("##{dom_id}-methods ~ h4 code").each do |node| | |
| 45 | + next unless name = node.content[/\('(\w+)'\)/, 1] | |
| 46 | + id = node.parent['id'] = "#{dom_id}-#{name.parameterize}-method" | |
| 47 | + name.prepend "#{dom_id.singularize.titleize}: " | |
| 48 | + name << ' (method)' | |
| 49 | + entries << [name, id] | |
| 50 | + end | |
| 51 | + end | |
| 52 | + | |
| 53 | + entries | |
| 54 | + end | |
| 55 | + | |
| 56 | + IGNORE_ENTRIES = %w( | |
| 57 | + Overview | |
| 58 | + Introduction | |
| 59 | + Usage | |
| 60 | + Methods | |
| 61 | + Options | |
| 62 | + ) | |
| 63 | + end | |
| 64 | + end | |
| 65 | +end | |
| @@ -0,0 +1,33 @@ | ||
| 1 | +module Docs | |
| 2 | + class Bootstrap < UrlScraper | |
| 3 | + options[:attribution] = <<-HTML | |
| 4 | + © 2011–2016 Twitter, Inc.<br> | |
| 5 | + Code licensed under the MIT License.<br> | |
| 6 | + Documentation licensed under the Creative Commons Attribution License v3.0. | |
| 7 | + HTML | |
| 8 | + | |
| 9 | + version '3' do | |
| 10 | + self.type = 'bsv3' | |
| 11 | + self.release = '3.3.7' | |
| 12 | + self.base_url = 'https://getbootstrap.com/' | |
| 13 | + self.root_path = 'getting-started' | |
| 14 | + self.links = { | |
| 15 | + home: 'https://getbootstrap.com/', | |
| 16 | + code: 'https://github.com/twbs/bootstrap' | |
| 17 | + } | |
| 18 | + | |
| 19 | + html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3' | |
| 20 | + | |
| 21 | + options[:trailing_slash] = false | |
| 22 | + options[:only] = %w(getting-started css components javascript) | |
| 23 | + end | |
| 24 | + | |
| 25 | + private | |
| 26 | + | |
| 27 | + def handle_response(response) | |
| 28 | + response.effective_url.scheme = 'https' | |
| 29 | + response.effective_url.path = response.effective_url.path.remove(/\/\z/) | |
| 30 | + super | |
| 31 | + end | |
| 32 | + end | |
| 33 | +end | |