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 @@
11 module Docs
2− class GnuFortran
2+ class Gnu
33 class CleanHtmlFilter < Filter
44 def call
55 heading = at_css('h1, h2, h3, h4, h5')
@@ -26,11 +26,11 @@ module Docs · 20 unmodified lines
2626 node.inner_html = node.inner_html.strip_heredoc.strip
2727 end
2828
29− css('dt > em', 'acronym', 'dfn').each do |node|
29+ css('dt > em', 'acronym', 'dfn', 'cite').each do |node|
3030 node.before(node.children).remove
3131 end
3232
33− css('.node', 'br').remove
33+ css('.node', 'br', 'hr').remove
3434
3535 doc
3636 end
lib/docs/filters/gnu/entries.rbrenamed from lib/docs/filters/gnu_fortran/entries.rb+9−9
@@ -1,5 +1,5 @@
11 module Docs
2− class GnuFortran
2+ class Gnu
33 class EntriesFilter < Docs::EntriesFilter
44 TYPE_BY_CHAPTER = { }
55
@@ -9,32 +9,32 @@ module Docs · 3 unmodified lines
99 end
1010
1111 def get_name
12− at_css('h1').content.split(' ').drop(1).join(' ').split('—').first
12+ name = at_css('h1').content
13+ name.remove! %r{\A[\d\.]*}
14+ name.split('—').first.strip
1315 end
1416
1517 def get_type
1618 "#{chapter_number}. #{TYPE_BY_CHAPTER[chapter_number]}"
1719 end
1820
19− def include_default_entry?
20− !at_css('ul.menu')
21− end
22−
2321 private
2422
2523 def detect_chapters
24+ TYPE_BY_CHAPTER.clear # YOLO
2625 css('.contents > ul > li > a').each do |node|
2726 index = node.content.strip.to_i
2827 next unless index > 0
2928 name = node.content.split(' ').drop(1).join(' ')
3029 name.remove! 'GNU Fortran '
31− name.remove! %r{:.*}
32− TYPE_BY_CHAPTER[index] = name # YOLO
30+ name.remove! 'with GCC'
31+ name.remove! %r{[\:\u{2013}\u{2014}].*}
32+ TYPE_BY_CHAPTER[index] = name
3333 end
3434 end
3535
3636 def chapter_number
37− at_css('h1').content.to_i
37+ [at_css('h1').content.to_i, 1].max
3838 end
3939 end
4040 end
lib/docs/scrapers/gnu.rb+30−0
@@ -0,0 +1,30 @@
1+module 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
30+end
lib/docs/scrapers/gnu/gcc.rb+78−0
@@ -0,0 +1,78 @@
1+module 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
78+end
lib/docs/scrapers/gnu/gnu_fortran.rb+21−0
@@ -0,0 +1,21 @@
1+module 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
21+end
lib/docs/scrapers/gnu_fortran.rb+0−40
@@ -1,40 +0,0 @@
1−module 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
40−end