Add Dart documentation

pull/847/merge
Jasper van Merle 7 years ago committed by Thibaut Courouble
parent 4e56a77012
commit 0429e07761

@ -215,6 +215,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',

@ -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'
}
});

@ -46,6 +46,7 @@
'pages/crystal',
'pages/d',
'pages/d3',
'pages/dart',
'pages/dojo',
'pages/drupal',
'pages/elixir',

@ -46,6 +46,7 @@
'pages/crystal',
'pages/d',
'pages/d3',
'pages/dart',
'pages/dojo',
'pages/drupal',
'pages/elixir',

@ -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;
}
}
}

@ -0,0 +1,51 @@
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("<h1>#{name} #{kind}</h1>")
end
# Add a title to the homepage of the v2 docs
if subpath == 'index.html' && at_css('.main-content > h1').nil?
at_css('.main-content').prepend_child('<h1>Dart SDK</h1>')
end
# Add the library to the main content (it is not always visible in the menu entry)
breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a')
if breadcrumbs.length > 1
library = breadcrumbs[1].content
# Generate the link to the homepage of the library
with_hypens = library.gsub(/:/, '-')
location = "#{'../' * subpath.count('/')}#{with_hypens}/#{with_hypens}-library"
link = "<a href=\"#{location}\" class=\"_links-link\">#{library}</span>"
# Add the link to the main title, just like how the "Homepage" and "Source code" links appear
at_css('.main-content').prepend_child("<p class=\"_links\">#{link}</p>")
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

@ -0,0 +1,58 @@
module Docs
class Dart
class EntriesFilter < Docs::EntriesFilter
def get_name
title = get_title
kind = get_kind
breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a')
first_part = ''
if breadcrumbs.length == 2 && !kind.include?('class')
first_part = breadcrumbs[1].content
elsif breadcrumbs.length == 3
first_part = breadcrumbs[2].content
end
separator = ''
unless first_part.empty?
if kind.include?('class')
separator = ':'
else
separator = '.'
end
end
first_part + separator + title
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
def get_kind
title = at_css('h1.title')
if not title.nil?
# v1
title.at_css('.kind').content
else
# v2
at_css('.main-content > h1').content[/(.*)( )(.+)/, 3]
end
end
end
end
end

@ -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
&copy; 2012, the Dart project authors<br>
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -0,0 +1 @@
https://github.com/dart-lang/logos
Loading…
Cancel
Save