Skip to content

Commit 6b37efd

Browse files
committed
Finish GNU Fortran scraper
1 parent d366e14 commit 6b37efd

17 files changed

Lines changed: 129 additions & 87 deletions

File tree

assets/images/icons.png

320 Bytes
Loading

assets/images/[email protected]

679 Bytes
Loading

assets/javascripts/news.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[
22
[
33
"2016-04-10",
4-
"New documentation: <a href=\"/browser_support_tables/\">Support tables (caniuse.com)</a>"
4+
"New documentations: <a href=\"/browser_support_tables/\">Support tables (caniuse.com)</a> and <a href=\"/gnu_fortran/\">GNU Fortran</a>"
55
], [
66
"2016-03-27",
77
"New documentation: <a href=\"/typescript/\">TypeScript</a>"
88
], [
99
"2016-03-06",
10-
"New documentation: <a href=\"/tensorflow/\">TensorFlow</a>, <a href=\"/haxe/\">Haxe</a> and <a href=\"/ansible/\">Ansible</a>"
10+
"New documentations: <a href=\"/tensorflow/\">TensorFlow</a>, <a href=\"/haxe/\">Haxe</a> and <a href=\"/ansible/\">Ansible</a>"
1111
], [
1212
"2016-02-28",
1313
"New documentations: <a href=\"/codeigniter/\">CodeIgniter</a>, <a href=\"/nginx_lua_module/\">nginx Lua Module</a> and <a href=\"/influxdata/\">InfluxData</a>"

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ credits = [
199199
'2005-2016 Linus Torvalds and others',
200200
'GPLv2',
201201
'https://raw.githubusercontent.com/git/git/master/COPYING'
202+
], [
203+
'GNU Fortran',
204+
'Free Software Foundation',
205+
'GFDL',
206+
'https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gfortran/GNU-Free-Documentation-License.html'
202207
], [
203208
'Go',
204209
'Google, Inc.',

assets/stylesheets/global/_icons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@
134134
._icon-ansible:before { background-position: -8rem -10rem; @extend %darkIconFix !optional; }
135135
._icon-typescript:before { background-position: -9rem -10rem; }
136136
._icon-browser_support_tables:before { background-position: 0rem -11rem; }
137+
._icon-gnu_fortran:before { background-position: -1rem -11rem; }

assets/stylesheets/pages/_base.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
._cordova,
20-
._fortran,
20+
._gnu_fortran,
2121
._grunt,
2222
._haxe,
2323
._influxdata,

lib/docs/filters/fortran/clean_html.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/docs/filters/fortran/entries.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
class GnuFortran
3+
class CleanHtmlFilter < Filter
4+
def call
5+
heading = at_css('h1, h2, h3, h4, h5')
6+
heading_level = heading.name[/h(\d)/, 1].to_i
7+
8+
css('h2, h3, h4, h5, h6').each do |node|
9+
node.name = node.name.sub(/\d/) { |i| i.to_i - (heading_level - 1) }
10+
end
11+
12+
css('.node > a[name]').each do |node|
13+
node.parent.next_element['id'] = node['name']
14+
end
15+
16+
css('a[name]').each do |node|
17+
node['id'] = node['name']
18+
end
19+
20+
css('samp > span:first-child:last-child').each do |node|
21+
node.parent.name = 'code'
22+
node.before(node.children).remove
23+
end
24+
25+
css('pre').each do |node|
26+
node.inner_html = node.inner_html.strip_heredoc.strip
27+
end
28+
29+
css('dt > em', 'acronym', 'dfn').each do |node|
30+
node.before(node.children).remove
31+
end
32+
33+
css('.node', 'br').remove
34+
35+
doc
36+
end
37+
end
38+
end
39+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module Docs
2+
class GnuFortran
3+
class EntriesFilter < Docs::EntriesFilter
4+
TYPE_BY_CHAPTER = { }
5+
6+
def initialize(*)
7+
super
8+
detect_chapters if root_page?
9+
end
10+
11+
def get_name
12+
at_css('h1').content.split(' ').drop(1).join(' ').split('—').first
13+
end
14+
15+
def get_type
16+
"#{chapter_number}. #{TYPE_BY_CHAPTER[chapter_number]}"
17+
end
18+
19+
def include_default_entry?
20+
!at_css('ul.menu')
21+
end
22+
23+
private
24+
25+
def detect_chapters
26+
css('.contents > ul > li > a').each do |node|
27+
index = node.content.strip.to_i
28+
next unless index > 0
29+
name = node.content.split(' ').drop(1).join(' ')
30+
name.remove! 'GNU Fortran '
31+
name.remove! %r{:.*}
32+
TYPE_BY_CHAPTER[index] = name # YOLO
33+
end
34+
end
35+
36+
def chapter_number
37+
at_css('h1').content.to_i
38+
end
39+
end
40+
end
41+
end

0 commit comments

Comments
 (0)