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 {
|
||||
@extend %simple;
|
||||
|
||||
blockquote {
|
||||
@extend %note;
|
||||
.signature { @extend %code; }
|
||||
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
|
||||
class Crystal
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
# Set the name to h1 content
|
||||
def get_name
|
||||
node = at_css("h1")
|
||||
node.content.strip
|
||||
if slug.start_with?('docs/')
|
||||
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
|
||||
|
||||
# Crystal types from url slug
|
||||
def get_type
|
||||
slug["blob/master/"] = ""
|
||||
object, method = *slug.split("/")
|
||||
object = object.capitalize
|
||||
method ? object : "Index"
|
||||
return if root_page?
|
||||
|
||||
if slug.start_with?('docs/syntax_and_semantics')
|
||||
'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
|
||||
|
||||
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
|
||||
|
@ -1,22 +1,37 @@
|
||||
module Docs
|
||||
class Crystal < UrlScraper
|
||||
self.name = "Crystal"
|
||||
self.type = "crystal"
|
||||
self.base_url = "https://github.com/crystal-lang/crystal-book"
|
||||
self.initial_paths = %w(/blob/master/SUMMARY.md)
|
||||
self.type = 'crystal'
|
||||
self.release = '0.18.7'
|
||||
self.base_url = 'https://crystal-lang.org/'
|
||||
self.root_path = 'api/0.18.7/index.html'
|
||||
self.initial_paths = %w(docs/index.html)
|
||||
self.links = {
|
||||
home: "https://crystal-lang.org/",
|
||||
code: "https://github.com/crystal-lang/crystal"
|
||||
home: 'https://crystal-lang.org/',
|
||||
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] = [/\/blob\/master\/.*\.md/]
|
||||
options[:skip] = %w(/blob/master/README.md)
|
||||
options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
<a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
|
||||
HTML
|
||||
options[:replace_paths] = {
|
||||
"api/#{release}/" => "api/#{release}/index.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
|
||||
|
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 |