Skip to content

Commit 0df3a77

Browse files
committed
Finish Vulkan scraper
1 parent 2f62bca commit 0df3a77

11 files changed

Lines changed: 66 additions & 56 deletions

File tree

assets/images/docs-2.png

369 Bytes
Loading

assets/images/[email protected]

915 Bytes
Loading

assets/javascripts/news.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"2017-09-03",
4-
"New documentation: <a href=\"/nim/\">Nim</a>"
4+
"New documentations: <a href=\"/nim/\">Nim</a> and <a href=\"/vulkan/\">Vulkan</a>"
55
], [
66
"2017-07-23",
77
"New documentation: <a href=\"/godot/\">Godot</a>"

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,11 @@ credits = [
633633
'2013-2017 Evan You, Vue.js contributors',
634634
'MIT',
635635
'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
636+
], [
637+
'Vulkan',
638+
'2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',
639+
'CC BY',
640+
'https://creativecommons.org/licenses/by/4.0/'
636641
], [
637642
'webpack',
638643
'JS Foundation and other contributors',

assets/stylesheets/global/_icons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,4 @@
174174
._icon-falcon:before { background-position: -3rem -2rem; @extend %doc-icon-2; }
175175
._icon-godot:before { background-position: -4rem -2rem; @extend %doc-icon-2; }
176176
._icon-nim:before { background-position: -5rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
177+
._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }

assets/stylesheets/pages/_simple.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
._requirejs,
4444
._typescript,
4545
._vagrant,
46+
._vulkan,
4647
._yarn {
4748
@extend %simple;
4849
}

lib/docs/filters/vulkan/clean_html.rb

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,51 @@ module Docs
22
class Vulkan
33
class CleanHtmlFilter < Filter
44
def call
5-
# Copyright is already added via attribution option
6-
css('#_copyright').map do |node|
7-
node.parent.remove
5+
at_css('#_copyright').parent.remove
6+
7+
css('.sect1', '.sectionbody', '.sect2', '.sect3', 'div.paragraph', 'li > p:only-child', 'dd > p:only-child', 'span', '.ulist').each do |node|
8+
node.before(node.children).remove
9+
end
10+
11+
css('a[id]:empty').each do |node|
12+
node.parent['id'] ||= node['id']
13+
node.remove
14+
end
15+
16+
css('.listingblock').each do |node|
17+
node['data-language'] = node.at_css('[data-lang]')['data-lang']
18+
node.content = node.content.strip
19+
node.name = 'pre'
20+
node.remove_attribute('class')
21+
end
22+
23+
css('.sidebarblock').each do |node|
24+
node.name = 'blockquote'
25+
node.at_css('.title').name = 'h5'
26+
node.css('div').each { |n| n.before(n.children).remove }
27+
node.remove_attribute('class')
828
end
929

30+
css('.admonitionblock').each do |node|
31+
node.name = 'blockquote'
32+
node.children = node.at_css('.content').children
33+
node.at_css('.title').name = 'h5'
34+
node.remove_attribute('class')
35+
end
36+
37+
css('table').each do |node|
38+
node.before %(<div class="_table"></div>)
39+
node.previous_element << node
40+
end
41+
42+
css('strong', 'dt', 'a').remove_attr('class')
43+
44+
css('h4 + h4').each do |node|
45+
node.previous_element.remove
46+
end
47+
48+
css('p:contains("This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.")').remove
49+
1050
doc
1151
end
1252
end

lib/docs/filters/vulkan/entries.rb

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,12 @@
11
module Docs
22
class Vulkan
33
class EntriesFilter < Docs::EntriesFilter
4-
def get_name
5-
name = at_css('h1').content.strip
6-
name
7-
end
8-
9-
def get_type
10-
# As only documentation is single-paged, hardcode type
11-
initial_page? ? 'Vulkan' : 'Specifications'
12-
end
13-
14-
def include_default_entry?
15-
# additional_entries is responsible to extract relevant entries
16-
false
17-
end
18-
194
def additional_entries
20-
if initial_page?
21-
# We pack each subsections into their corresponding category for apispec.html
22-
subsections = css('.sect2').map do |node|
23-
# Parse '.sect1' parent, to know what is the entry's type
24-
parent_node = node.parent.parent
25-
# Type is the parent's h2 header
26-
type = parent_node.at_css('h2').content.strip
27-
# Entry node is the one under h3
28-
header_node = node.at_css('h3')
29-
[header_node.content, header_node['id'], type]
30-
end
31-
else
32-
# We create a new category for vkspec.html page
33-
main_sections = css('.sect1').map do |node|
34-
# Entry node is the one under h2
35-
header_node = node.at_css('h2')
36-
[header_node.content, header_node['id'], 'Specifications']
5+
css('.sect1').each_with_object [] do |node, entries|
6+
type = node.at_css('h2').content
7+
8+
node.css('h3').each do |n|
9+
entries << [n.content, n['id'], type]
3710
end
3811
end
3912
end

lib/docs/scrapers/vulkan.rb

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
module Docs
2-
# class Vulkan < FileScraper
32
class Vulkan < UrlScraper
43
self.name = 'Vulkan'
5-
6-
self.slug = 'vk'
74
self.type = 'vulkan'
5+
self.release = '1.0.59'
6+
self.base_url = 'https://www.khronos.org/registry/vulkan/specs/1.0/'
7+
self.root_path = 'apispec.html'
88
self.links = {
9-
home: 'https://www.khronos.org/registry/vulkan/specs/',
10-
code: 'https://github.com/KhronosGroup/Vulkan-Docs'
9+
home: 'https://www.khronos.org/vulkan/'
1110
}
1211

13-
self.root_path = 'apispec.html'
14-
15-
self.release = '1.0.56'
16-
# self.dir = '/mnt/d/theblackunknown/Documents/GitHub/Vulkan-Docs/out/1.0/'
17-
self.base_url = 'https://www.khronos.org/registry/vulkan/specs/1.0/'
18-
19-
html_filters.push 'vulkan/entries', 'vulkan/clean_html'
12+
html_filters.push 'vulkan/entries', 'vulkan/clean_html', 'title'
2013

21-
# in apispec.html, skip #header and #footer
14+
options[:skip_links] = true
2215
options[:container] = '#content'
23-
24-
# If we only want API, we should skip this one
25-
options[:skip] = %w(
26-
html/vkspec.html
27-
)
16+
options[:root_title] = 'Vulkan API Reference'
2817

2918
options[:attribution] = <<-HTML
30-
Copyright &copy; 2014-2017 Khronos Group. <br>
31-
This work is licensed under a Creative Commons Attribution 4.0 International License
19+
&copy; 2014&ndash;2017 Khronos Group Inc.<br>
20+
Licensed under the Creative Commons Attribution 4.0 International License.<br>
21+
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.
3222
HTML
3323
end
3424
end

public/icons/docs/vulkan/16.png

-942 Bytes
Loading

0 commit comments

Comments
 (0)