History

Add GCC documentation

Thibaut Courouble committed 10 years ago

Commit 35c70b81 parent 995142815 files · +144 −54Browse files

Showing the changes to lib/docs (6 of 15 files). Show all

Unified · Split

6 files
  1. lib/docs/filters/gnu/clean_html.rb +3 −3
  2. lib/docs/filters/gnu/entries.rb +9 −9
  3. lib/docs/scrapers/gnu.rb +30 −0
  4. lib/docs/scrapers/gnu/gcc.rb +78 −0
  5. lib/docs/scrapers/gnu/gnu_fortran.rb +21 −0
  6. lib/docs/scrapers/gnu_fortran.rb +0 −40
lib/docs/filters/gnu/clean_html.rbrenamed from lib/docs/filters/gnu_fortran/clean_html.rb+3−3
@@ -1,5 +1,5 @@
1module Docs1module Docs
2 class GnuFortran2 class Gnu
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 heading = at_css('h1, h2, h3, h4, h5')5 heading = at_css('h1, h2, h3, h4, h5')
@@ -26,11 +26,11 @@ module Docs · 20 unmodified lines
26 node.inner_html = node.inner_html.strip_heredoc.strip26 node.inner_html = node.inner_html.strip_heredoc.strip
27 end27 end
28 28
29 css('dt > em', 'acronym', 'dfn').each do |node|29 css('dt > em', 'acronym', 'dfn', 'cite').each do |node|
30 node.before(node.children).remove30 node.before(node.children).remove
31 end31 end
32 32
33 css('.node', 'br').remove33 css('.node', 'br', 'hr').remove
34 34
35 doc35 doc
36 end36 end
lib/docs/filters/gnu/entries.rbrenamed from lib/docs/filters/gnu_fortran/entries.rb+9−9
@@ -1,5 +1,5 @@
1module Docs1module Docs
2 class GnuFortran2 class Gnu
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 TYPE_BY_CHAPTER = { }4 TYPE_BY_CHAPTER = { }
5 5
@@ -9,32 +9,32 @@ module Docs · 3 unmodified lines
9 end9 end
10 10
11 def get_name11 def get_name
12 at_css('h1').content.split(' ').drop(1).join(' ').split('—').first12 name = at_css('h1').content
13 name.remove! %r{\A[\d\.]*}
14 name.split('—').first.strip
13 end15 end
14 16
15 def get_type17 def get_type
16 "#{chapter_number}. #{TYPE_BY_CHAPTER[chapter_number]}"18 "#{chapter_number}. #{TYPE_BY_CHAPTER[chapter_number]}"
17 end19 end
18 20
19 def include_default_entry?
20 !at_css('ul.menu')
21 end
22
23 private21 private
24 22
25 def detect_chapters23 def detect_chapters
24 TYPE_BY_CHAPTER.clear # YOLO
26 css('.contents > ul > li > a').each do |node|25 css('.contents > ul > li > a').each do |node|
27 index = node.content.strip.to_i26 index = node.content.strip.to_i
28 next unless index > 027 next unless index > 0
29 name = node.content.split(' ').drop(1).join(' ')28 name = node.content.split(' ').drop(1).join(' ')
30 name.remove! 'GNU Fortran '29 name.remove! 'GNU Fortran '
31 name.remove! %r{:.*}30 name.remove! 'with GCC'
32 TYPE_BY_CHAPTER[index] = name # YOLO31 name.remove! %r{[\:\u{2013}\u{2014}].*}
32 TYPE_BY_CHAPTER[index] = name
33 end33 end
34 end34 end
35 35
36 def chapter_number36 def chapter_number
37 at_css('h1').content.to_i37 [at_css('h1').content.to_i, 1].max
38 end38 end
39 end39 end
40 end40 end
lib/docs/scrapers/gnu.rb+30−0
@@ -0,0 +1,30 @@
1module Docs
2 class Gnu < FileScraper
3 self.type = 'gnu'
4 self.root_path = 'index.html'
5 self.abstract = 'true'
6
7 html_filters.push 'gnu/clean_html', 'gnu/entries'
8
9 options[:skip] = %w(
10 GNU-Project.html
11 Service.html
12 )
13
14 options[:skip_patterns] = [
15 /Funding/,
16 /Projects/,
17 /Copying/,
18 /License/,
19 /Proposed/,
20 /Contribut/,
21 /Index/,
22 /\ABug/
23 ]
24
25 options[:attribution] = <<-HTML
26 &copy; Free Software Foundation<br>
27 Licensed under the GNU Free Documentation License, Version 1.3.
28 HTML
29 end
30end
lib/docs/scrapers/gnu/gcc.rb+78−0
@@ -0,0 +1,78 @@
1module Docs
2 class Gcc < Gnu
3 self.name = 'GCC'
4 self.slug = 'gcc'
5 self.links = {
6 home: 'https://gcc.gnu.org/'
7 }
8
9 html_filters.push 'title'
10
11 options[:root_title] = 'Using the GNU Compiler Collection (GCC)'
12 options[:title] = false
13
14 options[:replace_paths] = {
15 'AssemblerTemplate.html' => 'Extended-Asm.html',
16 'AVR-Named-Address-Spaces.html' => 'Named-Address-Spaces.html',
17 'AVR-Variable-Attributes.html' => 'Variable-Attributes.html',
18 'Clobbers.html' => 'Extended-Asm.html',
19 'dashMF.html' => 'Preprocessor-Options.html',
20 'GotoLabels.html' => 'Extended-Asm.html',
21 'InputOperands.html' => 'Extended-Asm.html',
22 'OutputOperands.html' => 'Extended-Asm.html',
23 'PowerPC-Type-Attributes.html' => 'Type-Attributes.html',
24 'SPU-Type-Attributes.html' => 'Type-Attributes.html',
25 'Type_002dpunning.html' => 'Optimize-Options.html',
26 'Volatile.html' => 'Extended-Asm.html',
27 'Wtrigraphs.html' => 'Preprocessor-Options.html',
28 'x86-Type-Attributes.html' => 'Type-Attributes.html',
29 'x86-Variable-Attributes.html' => 'Variable-Attributes.html',
30 'x86floatingpointasmoperands.html' => 'Extended-Asm.html',
31 'x86Operandmodifiers.html' => 'Extended-Asm.html',
32
33 'Example-of-asm-with-clobbered-asm-reg.html' => 'Extended-Asm.html',
34 'Extended-asm-with-goto.html' => 'Extended-Asm.html',
35 'fdollars_002din_002didentifiers.html' => 'Preprocessor-Options.html',
36 'i386-Type-Attributes.html' => 'Variable-Attributes.html',
37 'i386-Variable-Attributes.html' => 'Variable-Attributes.html'
38 }
39
40 CPP_PATHS = {
41 'dashMF.html' => 'Invocation.html',
42 'fdollars_002din_002didentifiers.html' => 'Invocation.html',
43 'Identifier-characters.html' => 'Implementation_002ddefined-behavior.html',
44 'trigraphs.html' => 'Initial-processing.html',
45 'Wtrigraphs.html' => 'Invocation.html'
46 }
47
48 version '5' do
49 self.release = '5.3.0'
50 self.dir = '/Users/Thibaut/DevDocs/Docs/gcc5'
51 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gcc/"
52 end
53
54 version '5 CPP' do
55 self.release = '5.3.0'
56 self.dir = '/Users/Thibaut/DevDocs/Docs/gcpp5'
57 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/cpp/"
58
59 options[:root_title] = false
60 options[:replace_paths] = CPP_PATHS
61 end
62
63 version '4' do
64 self.release = '4.9.3'
65 self.dir = '/Users/Thibaut/DevDocs/Docs/gcc4'
66 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gcc/"
67 end
68
69 version '4 CPP' do
70 self.release = '4.9.3'
71 self.dir = '/Users/Thibaut/DevDocs/Docs/gcpp4'
72 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/cpp/"
73
74 options[:root_title] = false
75 options[:replace_paths] = CPP_PATHS
76 end
77 end
78end
lib/docs/scrapers/gnu/gnu_fortran.rb+21−0
@@ -0,0 +1,21 @@
1module Docs
2 class GnuFortran < Gnu
3 self.name = 'GNU Fortran'
4 self.slug = 'gnu_fortran'
5 self.links = {
6 home: 'https://gcc.gnu.org/fortran/'
7 }
8
9 version '5' do
10 self.release = '5.3.0'
11 self.dir = '/Users/Thibaut/DevDocs/Docs/gfortran5'
12 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
13 end
14
15 version '4' do
16 self.release = '4.9.3'
17 self.dir = '/Users/Thibaut/DevDocs/Docs/gfortran4'
18 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
19 end
20 end
21end
lib/docs/scrapers/gnu_fortran.rb+0−40
@@ -1,40 +0,0 @@
1module Docs
2 class GnuFortran < FileScraper
3 self.name = 'GNU Fortran'
4 self.slug = 'gnu_fortran'
5 self.type = 'gnu_fortran'
6 self.dir = '/Users/Thibaut/DevDocs/Docs/gfortran'
7 self.root_path = 'index.html'
8
9 self.links = {
10 home: 'https://gcc.gnu.org/fortran/'
11 }
12
13 html_filters.push 'gnu_fortran/clean_html', 'gnu_fortran/entries'
14
15 options[:skip_patterns] = [
16 /Funding/,
17 /Projects/,
18 /Copying/,
19 /License/,
20 /Proposed/,
21 /Contribut/,
22 /Index/
23 ]
24
25 options[:attribution] = <<-HTML
26 &copy; Free Software Foundation<br>
27 Licensed under the GNU Free Documentation License, Version 1.3.
28 HTML
29
30 version '5' do
31 self.release = '5.3.0'
32 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
33 end
34
35 version '4' do
36 self.release = '4.9.3'
37 self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
38 end
39 end
40end