mirror of https://github.com/freeCodeCamp/devdocs
parent
4e56a77012
commit
0429e07761
@ -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
|
||||
© 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
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 4.1 KiB |
@ -0,0 +1 @@
|
||||
https://github.com/dart-lang/logos
|
Loading…
Reference in new issue