Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
@ -1,6 +0,0 @@
|
|||||||
#= require views/pages/base
|
|
||||||
|
|
||||||
class app.views.CrystalPage extends app.views.BasePage
|
|
||||||
prepare: ->
|
|
||||||
@highlightCode @findAllByTag('pre'), 'ruby'
|
|
||||||
return
|
|
@ -1,7 +1,26 @@
|
|||||||
._crystal {
|
._crystal {
|
||||||
@extend %simple;
|
@extend %simple;
|
||||||
|
|
||||||
blockquote {
|
.signature { @extend %code; }
|
||||||
@extend %note;
|
a.signature, .superclass > a { @extend %label; }
|
||||||
|
|
||||||
|
.entry-detail { margin-top: 1em; }
|
||||||
|
.view-source { float: right; }
|
||||||
|
|
||||||
|
.superclass-hierarchy {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.superclass {
|
||||||
|
float: left;
|
||||||
|
margin: 0 .5em 0 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.superclass + li.superclass:before {
|
||||||
|
content: '<';
|
||||||
|
margin-right: .5em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,74 @@
|
|||||||
module Docs
|
module Docs
|
||||||
class Crystal
|
class Crystal
|
||||||
class EntriesFilter < Docs::EntriesFilter
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
|
||||||
# Set the name to h1 content
|
|
||||||
def get_name
|
def get_name
|
||||||
node = at_css("h1")
|
if slug.start_with?('docs/')
|
||||||
node.content.strip
|
name = at_css('.page-inner h1').content.strip
|
||||||
|
|
||||||
|
if slug.start_with?('docs/syntax_and_semantics')
|
||||||
|
name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3
|
||||||
|
elsif slug.split('/').length > 1
|
||||||
|
chapter = slug.split('/')[1].titleize.capitalize
|
||||||
|
name.prepend "#{chapter}: " unless name == chapter
|
||||||
|
end
|
||||||
|
|
||||||
|
name
|
||||||
|
else
|
||||||
|
name = at_css('h1').children.last.content.strip
|
||||||
|
name.remove! %r{\(.*\)}
|
||||||
|
name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Crystal types from url slug
|
|
||||||
def get_type
|
def get_type
|
||||||
slug["blob/master/"] = ""
|
return if root_page?
|
||||||
object, method = *slug.split("/")
|
|
||||||
object = object.capitalize
|
if slug.start_with?('docs/syntax_and_semantics')
|
||||||
method ? object : "Index"
|
'Book: Language'
|
||||||
|
elsif slug.start_with?('docs/')
|
||||||
|
'Book'
|
||||||
|
else
|
||||||
|
hierarchy = at_css('.superclass-hierarchy')
|
||||||
|
if hierarchy && hierarchy.content.include?('Exception')
|
||||||
|
'Exceptions'
|
||||||
|
else
|
||||||
|
type = at_css('#types-list > ul > .current > a').content
|
||||||
|
type = 'Float' if type.start_with?('Float')
|
||||||
|
type = 'Int' if type.start_with?('Int')
|
||||||
|
type = 'UInt' if type.start_with?('UInt')
|
||||||
|
type = 'TCP' if type.start_with?('TCP')
|
||||||
|
type
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def additional_entries
|
||||||
|
return [] unless slug.start_with?('api')
|
||||||
|
entries = []
|
||||||
|
|
||||||
|
css('.entry-detail[id$="class-method"]').each do |node|
|
||||||
|
name = node.at_css('.signature > strong').content.strip
|
||||||
|
name.prepend "#{self.name}." unless slug.end_with?('toplevel')
|
||||||
|
id = node['id'] = node['id'].remove(/<.+?>/)
|
||||||
|
entries << [name, id] unless entries.last && entries.last[0] == name
|
||||||
|
end
|
||||||
|
|
||||||
|
css('.entry-detail[id$="instance-method"]').each do |node|
|
||||||
|
name = node.at_css('.signature > strong').content.strip
|
||||||
|
name.prepend "#{self.name}#" unless slug.end_with?('toplevel')
|
||||||
|
id = node['id'] = node['id'].remove(/<.+?>/)
|
||||||
|
entries << [name, id] unless entries.last && entries.last[0] == name
|
||||||
|
end
|
||||||
|
|
||||||
|
css('.entry-detail[id$="macro"]').each do |node|
|
||||||
|
name = node.at_css('.signature > strong').content.strip
|
||||||
|
name.prepend "#{self.name} " unless slug.end_with?('toplevel')
|
||||||
|
id = node['id'] = node['id'].remove(/<.+?>/)
|
||||||
|
entries << [name, id] unless entries.last && entries.last[0] == name
|
||||||
|
end
|
||||||
|
|
||||||
|
entries
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,22 +1,37 @@
|
|||||||
module Docs
|
module Docs
|
||||||
class Crystal < UrlScraper
|
class Crystal < UrlScraper
|
||||||
self.name = "Crystal"
|
self.type = 'crystal'
|
||||||
self.type = "crystal"
|
self.release = '0.18.7'
|
||||||
self.base_url = "https://github.com/crystal-lang/crystal-book"
|
self.base_url = 'https://crystal-lang.org/'
|
||||||
self.initial_paths = %w(/blob/master/SUMMARY.md)
|
self.root_path = 'api/0.18.7/index.html'
|
||||||
|
self.initial_paths = %w(docs/index.html)
|
||||||
self.links = {
|
self.links = {
|
||||||
home: "https://crystal-lang.org/",
|
home: 'https://crystal-lang.org/',
|
||||||
code: "https://github.com/crystal-lang/crystal"
|
code: 'https://github.com/crystal-lang/crystal'
|
||||||
}
|
}
|
||||||
|
|
||||||
html_filters.push "crystal/clean_html", "crystal/entries"
|
html_filters.push 'crystal/entries', 'crystal/clean_html'
|
||||||
|
|
||||||
options[:container] = ".entry-content"
|
options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//]
|
||||||
options[:only_patterns] = [/\/blob\/master\/.*\.md/]
|
|
||||||
options[:skip] = %w(/blob/master/README.md)
|
|
||||||
|
|
||||||
options[:attribution] = <<-HTML
|
options[:replace_paths] = {
|
||||||
<a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
|
"api/#{release}/" => "api/#{release}/index.html",
|
||||||
HTML
|
'docs/' => 'docs/index.html'
|
||||||
|
}
|
||||||
|
|
||||||
|
options[:attribution] = ->(filter) {
|
||||||
|
if filter.slug.start_with?('docs')
|
||||||
|
<<-HTML
|
||||||
|
To the extent possible under law, the persons who contributed to this work
|
||||||
|
have waived<br>all copyright and related or neighboring rights to this work
|
||||||
|
by associating CC0 with it.
|
||||||
|
HTML
|
||||||
|
else
|
||||||
|
<<-HTML
|
||||||
|
© 2012–2016 Manas Technology Solutions.<br>
|
||||||
|
Licensed under the Apache License, Version 2.0.
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 734 B After Width: | Height: | Size: 535 B |