Unified · Split
| @@ -708,7 +708,7 @@ credits = [ · 707 unmodified lines | |||
| 708 | 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE' | 708 | 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE' |
| 709 | ], [ | 709 | ], [ |
| 710 | 'Sass', | 710 | 'Sass', |
| 711 | '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein', | 711 | '2006-2020 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein', |
| 712 | 'MIT', | 712 | 'MIT', |
| 713 | 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE' | 713 | 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE' |
| 714 | ], [ | 714 | ], [ |
| @@ -2,62 +2,99 @@ module Docs · 1 unmodified line | |||
| 2 | class Sass | 2 | class Sass |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | css('tt').each do |node| | 5 | |
| 6 | node.name = 'code' | 6 | css('.sl-c-alert').remove |
| 7 | |||
| 8 | css('.sl-l-medium-holy-grail__navigation').remove | ||
| 9 | |||
| 10 | css('.sl-r-banner').remove | ||
| 11 | |||
| 12 | css('.site-footer').remove | ||
| 13 | |||
| 14 | # Add id to code blocks | ||
| 15 | css('pre.signature').each do |node| | ||
| 16 | |||
| 17 | id = node.content | ||
| 18 | |||
| 19 | if id.match(/\(/) | ||
| 20 | id = id.scan(/.+\(/)[0].chop | ||
| 21 | end | ||
| 22 | |||
| 23 | if id.include?('$pi') | ||
| 24 | node.set_attribute('id', 'pi') | ||
| 25 | elsif id.include?('$e') | ||
| 26 | node.set_attribute('id', 'e') | ||
| 27 | else | ||
| 28 | node.set_attribute('id', id) | ||
| 29 | end | ||
| 30 | |||
| 7 | end | 31 | end |
| 8 | 32 | ||
| 9 | css('pre').each do |node| | 33 | # Remove duplicate ids |
| 10 | node.content = node.content | 34 | css('.sl-c-callout--function').each do |node| |
| 35 | node.remove_attribute('id') | ||
| 11 | end | 36 | end |
| 12 | 37 | ||
| 13 | root_page? ? root : other | 38 | # Hidden title links |
| 39 | css('.visuallyhidden').remove | ||
| 14 | 40 | ||
| 15 | doc | 41 | ### Syntax Highlight ### |
| 16 | end | 42 | css('.kt').each do |node| |
| 43 | node.remove_attribute('class') | ||
| 44 | node.add_class('token constant') | ||
| 45 | end | ||
| 17 | 46 | ||
| 18 | def root | 47 | css('.k, .kn, .kc, .cp, .ow').each do |node| |
| 19 | at_css('h1 + ul').remove | 48 | node.remove_attribute('class') |
| 20 | end | 49 | node.add_class('token keyword') |
| 50 | end | ||
| 21 | 51 | ||
| 22 | def other | 52 | css('.nv, .no').each do |node| |
| 23 | at_css('h2').remove | 53 | node.remove_attribute('class') |
| 54 | node.add_class('token variable') | ||
| 55 | end | ||
| 24 | 56 | ||
| 25 | css('.showSource', '.source_code').remove | 57 | css('.nb, .n').each do |node| |
| 58 | node.remove_attribute('class') | ||
| 59 | node.add_class('token string') | ||
| 60 | end | ||
| 26 | 61 | ||
| 27 | css('div.docstring', 'div.discussion').each do |node| | 62 | css('.p').each do |node| |
| 28 | node.before(node.children).remove | 63 | node.remove_attribute('class') |
| 64 | node.add_class('token punctuation') | ||
| 29 | end | 65 | end |
| 30 | 66 | ||
| 31 | # Remove "See Also" | 67 | css('.nf').each do |node| |
| 32 | css('.see').each do |node| | 68 | node.remove_attribute('class') |
| 33 | node.previous_element.remove | 69 | node.add_class('token function') |
| 34 | node.remove | ||
| 35 | end | 70 | end |
| 36 | 71 | ||
| 37 | # Remove "- ([...])" before method names | 72 | css('.o').each do |node| |
| 38 | css('.signature', 'span.overload', 'span.signature').each do |node| | 73 | node.remove_attribute('class') |
| 39 | next if node.at_css('.overload') | 74 | node.add_class('token operator') |
| 40 | node.child.remove while node.child.name != 'strong' | ||
| 41 | end | 75 | end |
| 42 | 76 | ||
| 43 | # Clean up .inline divs | 77 | css('.c1, .cm, .c').each do |node| |
| 44 | css('div.inline').each do |node| | 78 | node.remove_attribute('class') |
| 45 | node.content = node.content | 79 | node.add_class('token comment') |
| 46 | node.name = 'span' | ||
| 47 | end | 80 | end |
| 48 | 81 | ||
| 49 | # Remove links to type classes (e.g. Number) | 82 | css('.mh, .m, .mi').each do |node| |
| 50 | css('.type > code').each do |node| | 83 | node.remove_attribute('class') |
| 51 | node.before(node.content.remove('Sass::Script::Value::').remove('Sass::Script::')).remove | 84 | node.add_class('token number') |
| 52 | end | 85 | end |
| 53 | 86 | ||
| 54 | css('li > span.signature').each do |node| | 87 | css('.nc, .nt').each do |node| |
| 55 | node.name = 'p' | 88 | node.remove_attribute('class') |
| 89 | node.add_class('token selector') | ||
| 56 | end | 90 | end |
| 57 | 91 | ||
| 58 | css('h3 strong', 'span.overload').each do |node| | 92 | css('.nl').each do |node| |
| 59 | node.before(node.children).remove | 93 | node.remove_attribute('class') |
| 94 | node.add_class('token property') | ||
| 60 | end | 95 | end |
| 96 | |||
| 97 | doc | ||
| 61 | end | 98 | end |
| 62 | end | 99 | end |
| 63 | end | 100 | end |
| @@ -1,89 +1,53 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Sass | 2 | class Sass |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | TYPES = ['CSS Extensions', 'SassScript', '@-Rules and Directives', | ||
| 5 | 'Output Styles'] | ||
| 6 | |||
| 7 | SKIP_NAMES = ['Interactive Shell', 'Data Types', 'Operations', | ||
| 8 | 'Division and /', 'Keyword Arguments'] | ||
| 9 | |||
| 10 | REPLACE_NAMES = { | ||
| 11 | '%foo' => '%placeholder selector', | ||
| 12 | '&' => '& parent selector', | ||
| 13 | '$' => '$ variables', | ||
| 14 | '`' => '#{} interpolation', | ||
| 15 | 'The !optional Flag' => '!optional' | ||
| 16 | } | ||
| 17 | 4 | ||
| 18 | def get_name | 5 | def get_name |
| 19 | 'Functions' | 6 | at_css('#main-content > h1').content |
| 20 | end | 7 | end |
| 21 | 8 | ||
| 22 | def get_type | 9 | def get_type |
| 23 | 'Functions' | 10 | return 'Syntax' if slug.include?('syntax') |
| 11 | return 'Style rules' if slug.include?('style') | ||
| 12 | return 'At-Rules' if slug.include?('at') | ||
| 13 | return 'Values' if slug.include?('values') | ||
| 14 | return 'Operators' if slug.include?('operators') | ||
| 15 | return 'Command line' if slug.include?('cli') | ||
| 16 | return 'Modules' if slug.include?('modules') | ||
| 17 | 'Misc' | ||
| 24 | end | 18 | end |
| 25 | 19 | ||
| 26 | def additional_entries | 20 | def additional_entries |
| 27 | root_page? ? root_entries : function_entries | ||
| 28 | end | ||
| 29 | |||
| 30 | def root_entries | ||
| 31 | entries = [] | 21 | entries = [] |
| 32 | type = '' | ||
| 33 | |||
| 34 | css('*').each do |node| | ||
| 35 | if node.name == 'h2' | ||
| 36 | type = node.content.strip | ||
| 37 | type.remove! %r{\s#.*} | ||
| 38 | node['id'] = type.parameterize | ||
| 39 | |||
| 40 | if type == 'Function Directives' | ||
| 41 | entries << ['@function', node['id'], '@-Rules and Directives'] | ||
| 42 | end | ||
| 43 | |||
| 44 | if type.include? 'Directives' | ||
| 45 | type = '@-Rules and Directives' | ||
| 46 | elsif type == 'Output Style' | ||
| 47 | type = 'Output Styles' | ||
| 48 | end | ||
| 49 | 22 | ||
| 50 | next | 23 | signatureElement = css('.signature') |
| 51 | elsif node.name == 'h3' || node.name == 'h4' | ||
| 52 | next unless TYPES.include?(type) | ||
| 53 | 24 | ||
| 54 | name = node.content.strip | 25 | if signatureElement |
| 55 | name.remove! %r{\A.+?: } | ||
| 56 | name.remove! %r{\s#.*} | ||
| 57 | 26 | ||
| 58 | node['id'] = name.parameterize | 27 | signatureElement.each do |node| |
| 59 | 28 | ||
| 60 | next if SKIP_NAMES.include?(name) | 29 | entry_name = node.content |
| 61 | 30 | ||
| 62 | name = REPLACE_NAMES[name] if REPLACE_NAMES[name] | 31 | if entry_name.match(/\(/) |
| 63 | name.gsub!(/ [A-Z]/) { |str| str.downcase! } | 32 | entry_name = entry_name.scan(/.+\(/)[0].chop |
| 33 | end | ||
| 64 | 34 | ||
| 65 | if type == '@-Rules and Directives' | 35 | if entry_name.include?('$pi') |
| 66 | next unless name =~ /\A@[\w\-]+\z/ || name == '!optional' | 36 | entries << [entry_name, 'pi', 'Variable'] |
| 37 | elsif entry_name.include?('$e') | ||
| 38 | entries << [entry_name, 'e', 'Variable'] | ||
| 39 | else | ||
| 40 | entries << [entry_name, entry_name, 'Functions'] | ||
| 67 | end | 41 | end |
| 68 | 42 | ||
| 69 | entries << [name, node['id'], type] | ||
| 70 | end | 43 | end |
| 44 | |||
| 71 | end | 45 | end |
| 72 | 46 | ||
| 73 | entries | 47 | entries |
| 74 | end | ||
| 75 | |||
| 76 | def function_entries | ||
| 77 | css('.method_details > .signature').inject [] do |entries, node| | ||
| 78 | name = node.content.strip.remove(%r{\(.*}) | ||
| 79 | 48 | ||
| 80 | unless name == entries.last.try(:first) | ||
| 81 | entries << [name, node['id'], 'Functions'] | ||
| 82 | end | ||
| 83 | |||
| 84 | entries | ||
| 85 | end | ||
| 86 | end | 49 | end |
| 50 | |||
| 87 | end | 51 | end |
| 88 | end | 52 | end |
| 89 | end | 53 | end |
| @@ -1,9 +1,9 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Sass < UrlScraper | 2 | class Sass < UrlScraper |
| 3 | self.type = 'yard' | 3 | self.type = 'yard' |
| 4 | self.release = '3.5.3' | 4 | self.release = '3.6.4' |
| 5 | self.base_url = 'http://sass-lang.com/documentation/' | 5 | self.base_url = 'https://sass-lang.com/documentation' |
| 6 | self.root_path = 'file.SASS_REFERENCE.html' | 6 | self.root_path = 'index.html' |
| 7 | self.links = { | 7 | self.links = { |
| 8 | home: 'http://sass-lang.com/', | 8 | home: 'http://sass-lang.com/', |
| 9 | code: 'https://github.com/sass/sass' | 9 | code: 'https://github.com/sass/sass' |
| @@ -11,21 +11,21 @@ module Docs · 1 unmodified line | |||
| 11 | 11 | ||
| 12 | html_filters.push 'sass/clean_html', 'sass/entries', 'title' | 12 | html_filters.push 'sass/clean_html', 'sass/entries', 'title' |
| 13 | 13 | ||
| 14 | options[:only] = %w(Sass/Script/Functions.html) | ||
| 15 | options[:root_title] = false | 14 | options[:root_title] = false |
| 16 | options[:title] = 'Sass Functions' | 15 | options[:title] = 'Sass Functions' |
| 17 | 16 | ||
| 18 | options[:container] = ->(filter) do | 17 | options[:skip_patterns] = [/breaking-changes/] |
| 19 | filter.root_page? ? '#filecontents' : '#instance_method_details' | 18 | |
| 20 | end | 19 | # options[:container] = '#main-content' |
| 21 | 20 | ||
| 22 | options[:attribution] = <<-HTML | 21 | options[:attribution] = <<-HTML |
| 23 | © 2006–2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein<br> | 22 | © 2006–2020 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein<br> |
| 24 | Licensed under the MIT License. | 23 | Licensed under the MIT License. |
| 25 | HTML | 24 | HTML |
| 26 | 25 | ||
| 27 | def get_latest_version(opts) | 26 | def get_latest_version(opts) |
| 28 | get_latest_github_release('sass', 'libsass', opts) | 27 | get_latest_github_release('sass', 'libsass', opts) |
| 29 | end | 28 | end |
| 29 | |||
| 30 | end | 30 | end |
| 31 | end | 31 | end |