Unified · Split
| @@ -135,9 +135,9 @@ credits = [ · 134 unmodified lines | |||
| 135 | 'https://raw.github.com/knockout/knockout/master/LICENSE' | 135 | 'https://raw.github.com/knockout/knockout/master/LICENSE' |
| 136 | ], [ | 136 | ], [ |
| 137 | 'Less', | 137 | 'Less', |
| 138 | '2009-2014 Alexis Sellier & The Core Less Team', | 138 | '2009-2014 The Core Less Team', |
| 139 | 'Apache v2', | 139 | 'CC BY', |
| 140 | 'https://raw.github.com/less/less.js/master/LICENSE' | 140 | 'http://creativecommons.org/licenses/by/3.0/' |
| 141 | ], [ | 141 | ], [ |
| 142 | 'Lo-Dash', | 142 | 'Lo-Dash', |
| 143 | '2009-2013 The Dojo Foundation', | 143 | '2009-2013 The Dojo Foundation', |
| @@ -1,12 +1,8 @@ | |||
| 1 | ._less { | 1 | ._less { |
| 2 | padding-left: 1rem; | 2 | padding-left: 1rem; |
| 3 | 3 | ||
| 4 | > h1, > h2, > h3 { margin-left: -1rem; } | 4 | > h1, > h2, h3, h4 { margin-left: -1rem; } |
| 5 | > h2, > h3 { @extend %block-heading; } | 5 | > h2 { @extend %block-heading; } |
| 6 | > h4 { margin-top: 2em; } | 6 | h3, h4 { @extend %block-label, %label-blue; } |
| 7 | 7 | code { @extend %label; } | |
| 8 | > .function { | ||
| 9 | margin-left: -1rem; | ||
| 10 | @extend %block-label, %label-blue; | ||
| 11 | } | ||
| 12 | } | 8 | } |
| @@ -2,37 +2,26 @@ module Docs · 1 unmodified line | |||
| 2 | class Less | 2 | class Less |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | # Remove everything but language and function reference | 5 | css('.source-link').remove |
| 6 | doc.children = css('#docs', '#reference').children | ||
| 7 | 6 | ||
| 8 | # Change headings | 7 | css('#functions-overview').each do |node| |
| 9 | css('h1', 'h2', 'h3').each do |node| | 8 | node.ancestors('.docs-section').remove |
| 10 | node.name = "h#{node.name.last.to_i + 1}" | ||
| 11 | node['id'] ||= node.content.strip.parameterize | ||
| 12 | end | 9 | end |
| 13 | 10 | ||
| 14 | # Remove .content div | 11 | css('.docs-section', 'blockquote').each do |node| |
| 15 | css('.content').each do |node| | 12 | node.before(node.children).remove |
| 16 | node.before(node.elements) | ||
| 17 | node.remove | ||
| 18 | end | 13 | end |
| 19 | 14 | ||
| 20 | # Remove function index | 15 | css('.page-header').each do |node| |
| 21 | css('#function-reference').each do |node| | 16 | node.before(node.first_element_child).remove |
| 22 | while node.next.content.strip != 'String functions' | ||
| 23 | node.next.remove | ||
| 24 | end | ||
| 25 | end | 17 | end |
| 26 | 18 | ||
| 27 | # Remove duplicates | 19 | css('h1, h2, h3, h4').each do |node| |
| 28 | [css('[id="unit"]').last, css('[id="color"]').last].each do |node| | 20 | node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } |
| 29 | node.next.remove while %w(h2 h3 h4).exclude?(node.next.name) | ||
| 30 | node.remove | ||
| 31 | end | 21 | end |
| 32 | 22 | ||
| 33 | # Differentiate function headings | 23 | css('pre').each do |node| |
| 34 | css('#function-reference ~ h4').each do |node| | 24 | node.content = node.content |
| 35 | node['class'] = 'function' | ||
| 36 | end | 25 | end |
| 37 | 26 | ||
| 38 | doc | 27 | doc |
| @@ -1,48 +1,61 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Less | 2 | class Less |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | SKIP_NAMES = ['Parametric Mixins', 'Mixins With Multiple Parameters', | 4 | def name |
| 5 | 'Return Values', 'Unlocking Mixins', 'Media Queries as Variables'] | 5 | at_css('h1').content |
| 6 | 6 | end | |
| 7 | REPLACE_NAMES = { | 7 | |
| 8 | 'The @arguments variable' => '@arguments', | 8 | def type |
| 9 | 'Advanced arguments and the @rest variable' => '@rest', | 9 | root_page? ? 'Language' : nil |
| 10 | 'The Keyword !important' => '!important', | ||
| 11 | 'Pattern-matching and Guard expressions' => 'Pattern-matching', | ||
| 12 | 'Advanced Usage of &' => '&', | ||
| 13 | 'Importing' => '@import', | ||
| 14 | 'JavaScript evaluation' => 'JavaScript', | ||
| 15 | '% format' => '%' | ||
| 16 | } | ||
| 17 | |||
| 18 | def include_default_entry? | ||
| 19 | false | ||
| 20 | end | 10 | end |
| 21 | 11 | ||
| 22 | def additional_entries | 12 | def additional_entries |
| 13 | root_page? ? language_entries : function_entries | ||
| 14 | end | ||
| 15 | |||
| 16 | def language_entries | ||
| 23 | entries = [] | 17 | entries = [] |
| 24 | type = '' | ||
| 25 | |||
| 26 | css('> [id]').each do |node| | ||
| 27 | if node.name == 'h2' | ||
| 28 | type = node.content.strip | ||
| 29 | type.sub! 'The Language', 'Language' | ||
| 30 | type.sub! 'functions', 'Functions' | ||
| 31 | next | ||
| 32 | end | ||
| 33 | 18 | ||
| 34 | # Skip function categories (e.g. "Color definition") | 19 | css('h1').each do |node| |
| 35 | next if node.name == 'h3' && type != 'Language' | 20 | name = node.content |
| 21 | entries << [name, node['id']] unless name == 'Overview' | ||
| 22 | end | ||
| 23 | |||
| 24 | css('h2[id^="import-options-"]').each do |node| | ||
| 25 | entries << ["@import #{node.content}", node['id']] | ||
| 26 | end | ||
| 36 | 27 | ||
| 37 | name = node.content.strip | 28 | entries.concat [ |
| 29 | ['@var', 'variables-feature'], | ||
| 30 | ['@{} interpolation', 'variables-feature-variable-interpolation'], | ||
| 31 | ['url()', 'variables-feature-urls'], | ||
| 32 | ['@property', 'variables-feature-properties'], | ||
| 33 | ['@@var', 'variables-feature-variable-names'], | ||
| 34 | [':extend()', 'extend-feature'], | ||
| 35 | [':extend(all)', 'extend-feature-extend-quotallquot'], | ||
| 36 | ['@arguments', 'mixins-parametric-feature-the-codeargumentscode-variable'], | ||
| 37 | ['@rest', 'mixins-parametric-feature-advanced-arguments-and-the-coderestcode-variable'], | ||
| 38 | ['@import', 'import-directives-feature'], | ||
| 39 | ['when', 'mixin-guards-feature'], | ||
| 40 | ['.loop()', 'loops-feature'], | ||
| 41 | ['+:', 'merge-feature'] ] | ||
| 38 | 42 | ||
| 39 | next if SKIP_NAMES.include?(name) | 43 | entries |
| 44 | end | ||
| 40 | 45 | ||
| 41 | name = REPLACE_NAMES[name] if REPLACE_NAMES[name] | 46 | def function_entries |
| 42 | name.gsub!(/ [A-Z]/) { |str| str.downcase! } | 47 | entries = [] |
| 48 | type = nil | ||
| 43 | 49 | ||
| 44 | entries << ['~', node['id'], type] if name == 'e' | 50 | css('.docs-section').each do |section| |
| 45 | entries << [name, node['id'], type] | 51 | if title = section.at_css('h1') |
| 52 | type = title.content | ||
| 53 | type.sub! %r{(\w+) Functions}, 'Functions: \1' | ||
| 54 | end | ||
| 55 | |||
| 56 | section.css('h3').each do |node| | ||
| 57 | entries << [node.content, node['id'], type] | ||
| 58 | end | ||
| 46 | end | 59 | end |
| 47 | 60 | ||
| 48 | entries | 61 | entries |
| @@ -1,18 +1,21 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Less < UrlScraper | 2 | class Less < UrlScraper |
| 3 | self.type = 'less' | 3 | self.type = 'less' |
| 4 | self.version = '1.6.0' | 4 | self.version = '1.6.3' |
| 5 | self.base_url = 'http://lesscss.org' | 5 | self.base_url = 'http://lesscss.org' |
| 6 | self.root_path = '/features' | ||
| 7 | self.initial_paths = %w(/functions) | ||
| 6 | 8 | ||
| 7 | html_filters.push 'less/clean_html', 'less/entries', 'title' | 9 | html_filters.push 'less/entries', 'less/clean_html', 'title' |
| 8 | 10 | ||
| 9 | options[:title] = 'LESS' | 11 | options[:title] = 'Less' |
| 10 | options[:container] = 'section' | 12 | options[:container] = 'div[role=main]' |
| 11 | options[:skip_links] = true | 13 | options[:follow_links] = false |
| 14 | options[:trailing_slash] = false | ||
| 12 | 15 | ||
| 13 | options[:attribution] = <<-HTML | 16 | options[:attribution] = <<-HTML |
| 14 | © 2009–2014 Alexis Sellier & The Core Less Team<br> | 17 | © 2009–2014 The Core Less Team<br> |
| 15 | Licensed under the Apache License v2.0. | 18 | Licensed under the Creative Commons Attribution License 3.0. |
| 16 | HTML | 19 | HTML |
| 17 | end | 20 | end |
| 18 | end | 21 | end |