diff --git a/.gitignore b/.gitignore index 8b222826..9c439451 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ public/fonts public/docs/**/* !public/docs/docs.json !public/docs/**/index.json +.idea +log diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index fef9a024..bc477a74 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -210,6 +210,11 @@ credits = [ '2010-2018 Michael Bostock', 'BSD', 'https://raw.githubusercontent.com/d3/d3/master/LICENSE' + ], [ + 'Dart', + '2012 the Dart project authors', + 'CC BY-SA', + 'https://creativecommons.org/licenses/by-sa/4.0/' ], [ 'Django', 'Django Software Foundation and individual contributors', diff --git a/assets/javascripts/vendor/prism.js b/assets/javascripts/vendor/prism.js index 3dc04a14..a99402d9 100644 --- a/assets/javascripts/vendor/prism.js +++ b/assets/javascripts/vendor/prism.js @@ -2113,3 +2113,27 @@ Prism.languages.yaml = { 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./ }; +Prism.languages.dart = Prism.languages.extend('clike', { + 'string': [ + { + pattern: /r?("""|''')[\s\S]*?\1/, + greedy: true + }, + { + pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, + greedy: true + } + ], + 'keyword': [ + /\b(?:async|sync|yield)\*/, + /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/ + ], + 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/ +}); + +Prism.languages.insertBefore('dart','function',{ + 'metadata': { + pattern: /@\w+/, + alias: 'symbol' + } +}); diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 4500f90f..5d3dcac5 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -45,6 +45,7 @@ 'pages/crystal', 'pages/d', 'pages/d3', + 'pages/dart', 'pages/dojo', 'pages/drupal', 'pages/elixir', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index f7321135..4d54b548 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -45,6 +45,7 @@ 'pages/crystal', 'pages/d', 'pages/d3', + 'pages/dart', 'pages/dojo', 'pages/drupal', 'pages/elixir', diff --git a/assets/stylesheets/pages/_dart.scss b/assets/stylesheets/pages/_dart.scss new file mode 100644 index 00000000..87159057 --- /dev/null +++ b/assets/stylesheets/pages/_dart.scss @@ -0,0 +1,12 @@ +._dart { + @extend %simple; + + dl:not(.dl-horizontal) dt, .multi-line-signature { + @extend %note, %note-blue; + padding: 1px 0.5rem 2px 0.5rem; + + .features { + float: right; + } + } +} diff --git a/lib/docs/filters/dart/clean_html.rb b/lib/docs/filters/dart/clean_html.rb new file mode 100644 index 00000000..6032a994 --- /dev/null +++ b/lib/docs/filters/dart/clean_html.rb @@ -0,0 +1,32 @@ +module Docs + class Dart + class CleanHtmlFilter < Filter + def call + # Move the title into the main content node in the v1 docs + title = at_css('h1.title') + unless title.nil? + name = title.children.last.content.strip + kind = title.at_css('.kind').content + at_css('.main-content').prepend_child("

#{name} #{kind}

") + end + + # Extract the actual content + # We can't use options[:container] here because the entries filter uses the breadcrumbs node + @doc = at_css('.main-content') + + # Move the features (i.e. "read-only, inherited") into the blue header + css('.features').each do |node| + header = node.xpath('parent::dd/preceding::dt').last + header.add_child node unless header.nil? + end + + # Make code blocks detectable by Prism + css('pre').each do |node| + node['data-language'] = 'dart' + end + + doc + end + end + end +end diff --git a/lib/docs/filters/dart/entries.rb b/lib/docs/filters/dart/entries.rb new file mode 100644 index 00000000..b07cc597 --- /dev/null +++ b/lib/docs/filters/dart/entries.rb @@ -0,0 +1,32 @@ +module Docs + class Dart + class EntriesFilter < Docs::EntriesFilter + def get_name + breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a') + breadcrumbs = breadcrumbs.length == 1 ? [] : breadcrumbs.slice(1..-1).map {|node| node.content} + + first_part = breadcrumbs.join(':') + separator = first_part.empty? ? '' : ':' + last_part = get_title + + first_part + separator + last_part + end + + def get_type + at_css('.breadcrumbs > li:nth-child(2)').content.split(' ')[0] + end + + def get_title + title = at_css('h1.title') + + if not title.nil? + # v1 + title.children.last.content.strip + else + # v2 + at_css('.main-content > h1').content[/(.*)( )/, 1].split(' top-level')[0] + end + end + end + end +end diff --git a/lib/docs/scrapers/dart.rb b/lib/docs/scrapers/dart.rb new file mode 100644 index 00000000..b06960b2 --- /dev/null +++ b/lib/docs/scrapers/dart.rb @@ -0,0 +1,34 @@ +module Docs + class Dart < FileScraper + self.type = 'dart' + self.root_path = 'index.html' + self.links = { + home: 'https://www.dartlang.org/', + code: 'https://github.com/dart-lang/sdk' + } + + html_filters.push 'dart/entries', 'dart/clean_html' + + options[:fix_urls] = ->(url) do + # localhost/dart-web_audio/..dart-io/dart-io-library.html > localhost/dart-io/dart-io-library.html + url.sub(/(([^\/]+)\/\.\.)/, '') + end + + options[:attribution] = <<-HTML + © 2012, the Dart project authors
+ Licensed under the Creative Commons Attribution-ShareAlike License v4.0. + HTML + + # Download the documentation from https://www.dartlang.org/tools/sdk/archive + + version '1' do + self.release = '1.24.3' + self.dir = '/home/jasper/Documents/dart-docs-1.24.3' + end + + version '2' do + self.release = '2.0.0-dev.68.0' + self.dir = '/home/jasper/Documents/dart-docs-2.0.0-dev.68.0' + end + end +end diff --git a/public/icons/docs/dart/16.png b/public/icons/docs/dart/16.png new file mode 100644 index 00000000..3272c1d7 Binary files /dev/null and b/public/icons/docs/dart/16.png differ diff --git a/public/icons/docs/dart/16@2x.png b/public/icons/docs/dart/16@2x.png new file mode 100644 index 00000000..cad29d18 Binary files /dev/null and b/public/icons/docs/dart/16@2x.png differ diff --git a/public/icons/docs/dart/SOURCE b/public/icons/docs/dart/SOURCE new file mode 100644 index 00000000..dd21f7e7 --- /dev/null +++ b/public/icons/docs/dart/SOURCE @@ -0,0 +1 @@ +https://github.com/dart-lang/logos