diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 8e719586..7cedbf59 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -67,6 +67,7 @@ 'pages/meteor', 'pages/modernizr', 'pages/moment', + 'pages/nim', 'pages/nginx', 'pages/node', 'pages/npm', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 21ce39a3..e909e005 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -67,6 +67,7 @@ 'pages/meteor', 'pages/modernizr', 'pages/moment', + 'pages/nim', 'pages/nginx', 'pages/node', 'pages/npm', diff --git a/assets/stylesheets/pages/_nim.scss b/assets/stylesheets/pages/_nim.scss new file mode 100644 index 00000000..590fb342 --- /dev/null +++ b/assets/stylesheets/pages/_nim.scss @@ -0,0 +1,81 @@ +._nim { + @extend %simple; + + @if $style == 'dark' { + span.DecNumber { color: #AE81FF; } + span.BinNumber { color: #AE81FF; } + span.HexNumber { color: #AE81FF; } + span.OctNumber { color: #AE81FF; } + span.FloatNumber { color: #AE81FF; } + span.Identifier { color: #F8F8F2; } + span.Keyword { font-weight: 600; color: #F92672; } + span.StringLit { color: #E6DB74; } + span.LongStringLit { color: #E6DB74; } + span.CharLit { color: #E6DB74; } + span.EscapeSequence { color: white; } + span.Operator { color: white; } + span.Punctuation {color: white; } + span.Comment, span.LongComment { + font-style: italic; + font-weight: 400; + color: #75715E; } + + span.RegularExpression { color: darkviolet; } + span.TagStart { color: #F92672; } + span.TagEnd { color: #F92672; } + span.Key { color: #AE81FF; } + span.Value { color: #AE81FF; } + span.RawData { color: #a4255b; } + span.Assembler { color: #AE81FF; } + span.Preprocessor { color: #AE81FF; } + span.Directive { color: #AE81FF; } + + span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference, + span.Other { color: white; } + + /* Pop type, const, proc, and iterator defs in nim def blocks */ + dt pre > span.Identifier, dt pre > span.Operator { color: #529B2F; font-weight: 700; } + } @else { + span.DecNumber { color: #252dbe; } + span.BinNumber { color: #252dbe; } + span.HexNumber { color: #252dbe; } + span.OctNumber { color: #252dbe; } + span.FloatNumber { color: #252dbe; } + span.Identifier { color: #3b3b3b; } + span.Keyword { font-weight: 600; color: #5e8f60; } + span.StringLit { color: #a4255b; } + span.LongStringLit { color: #a4255b; } + span.CharLit { color: #a4255b; } + span.EscapeSequence { color: black; } + span.Operator { color: black; } + span.Punctuation {color: black; } + span.Comment, span.LongComment { + font-style: italic; + font-weight: 400; + color: #484a86; } + + span.RegularExpression { color: darkviolet; } + span.TagStart { color: darkviolet; } + span.TagEnd { color: darkviolet; } + span.Key { color: #252dbe; } + span.Value { color: #252dbe; } + span.RawData { color: #a4255b; } + span.Assembler { color: #252dbe; } + span.Preprocessor { color: #252dbe; } + span.Directive { color: #252dbe; } + + span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference, + span.Other { color: black; } + + /* Pop type, const, proc, and iterator defs in nim def blocks */ + dt pre > span.Identifier, dt pre > span.Operator { color: #155da4; font-weight: 700; } + } + dt pre > span.Identifier ~ span.Identifier, dt pre > span.Operator ~ span.Identifier { + color: inherit; + font-weight: inherit; } + + dt pre > span.Operator ~ span.Identifier, dt pre > span.Operator ~ span.Operator { + color: inherit; + font-weight: inherit; } + +} diff --git a/lib/docs/filters/nim/clean_html.rb b/lib/docs/filters/nim/clean_html.rb new file mode 100644 index 00000000..3231f9eb --- /dev/null +++ b/lib/docs/filters/nim/clean_html.rb @@ -0,0 +1,31 @@ +module Docs + class Nim + class CleanHtmlFilter < Filter + def call + @doc = at_css('#documentId .container') + + css('.docinfo').remove + + content = at_css('#content') + if content != nil + at_css('#content').remove_attribute('class') + @doc.add_child(at_css('#content').inner_html) + end + + css('> div.row').remove + + css('pre').each do |node| + node['data-language'] = 'nim' + end + + # remove link from headers + css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node| + node.parent['id'] = node['id'] + node.parent.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/nim/entries.rb b/lib/docs/filters/nim/entries.rb new file mode 100644 index 00000000..ddcd7522 --- /dev/null +++ b/lib/docs/filters/nim/entries.rb @@ -0,0 +1,51 @@ +module Docs + class Nim + class EntriesFilter < Docs::EntriesFilter + def get_type + at_css('h1').content + end + + def get_name + at_css('h1').content + end + + def additional_entries + entries = [] + if get_name.start_with? 'Module ' + module_name = get_name[7..-1] + css('div .section').map do |node| + section_node = node.at_css('h1 a') + if section_node != nil + section_name = section_node.content.strip + items_node = node.at_css('dl.item') + if items_node != nil + items_node.css('dt a').map do |item_node| + item_name = item_node['name'] + if item_name.include? ',' + item_name = item_name.sub(',', '(') + ')' + end + entries << [module_name + '.' + item_name, item_node.parent['id']] + end + end + end + end + else + css('h1', 'h2', 'h3').map do |node| + id = node['id'] + name = node.content.strip + if id != nil + entries << [name, id] + else + a = node.at_css('a') + if a != nil + id = a['id'] + entries << [name, id] + end + end + end + end + entries + end + end + end +end diff --git a/lib/docs/scrapers/nim.rb b/lib/docs/scrapers/nim.rb new file mode 100644 index 00000000..571c529a --- /dev/null +++ b/lib/docs/scrapers/nim.rb @@ -0,0 +1,21 @@ +module Docs + class Nim < UrlScraper + self.type = 'nim' + self.release = '0.17.0' + self.links = { + home: 'https://nim-lang.org/', + code: 'https://github.com/nim-lang/Nim' + } + self.base_url = 'https://nim-lang.org/' + self.root_path = 'docs/overview.html' + + html_filters.push 'nim/entries', 'nim/clean_html' + + options[:skip] = %w(cdn-cgi/l/email-protection docs/theindex.html docs/docgen.txt) + options[:attribution] = <<-HTML + © 2006–2017 Andreas Rumpf
+ All rights reserved. Licensed under the MIT License. + HTML + + end +end \ No newline at end of file diff --git a/public/icons/docs/nim/16.png b/public/icons/docs/nim/16.png new file mode 100644 index 00000000..1945b395 Binary files /dev/null and b/public/icons/docs/nim/16.png differ diff --git a/public/icons/docs/nim/16@2x.png b/public/icons/docs/nim/16@2x.png new file mode 100644 index 00000000..bd13ba65 Binary files /dev/null and b/public/icons/docs/nim/16@2x.png differ diff --git a/public/icons/docs/nim/SOURCE b/public/icons/docs/nim/SOURCE new file mode 100644 index 00000000..ed29d859 --- /dev/null +++ b/public/icons/docs/nim/SOURCE @@ -0,0 +1 @@ +https://nim-lang.org/assets/img/logo.svg \ No newline at end of file