History

Finish CMake scraper

Thibaut Courouble committed 10 years ago

Commit ab41f0c1 parent 96d45d511 files · +76 −83Browse files

Unified · Split

11 files
  1. assets/images/docs.png +0 −0
  2. assets/images/docs@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/cmake/clean_html.rb +34 −26
  7. lib/docs/filters/cmake/entries.rb +20 −42
  8. lib/docs/scrapers/cmake.rb +16 −19
  9. public/icons/docs/cmake/16.png +0 −0
  10. public/icons/docs/cmake/16@2x.png +0 −0
  11. public/icons/docs/cmake/SOURCE +1 −0
assets/images/docs.png+0−0

Binary file not shown.

assets/images/docs@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
1[1[
2 [2 [
3 "2016-07-02",
4 "New documentation: <a href=\"/cmake/\">CMake</a>"
5 ], [
3 "2016-06-19",6 "2016-06-19",
4 "New documentation: <a href=\"/love/\">L&Ouml;VE</a>"7 "New documentation: <a href=\"/love/\">L&Ouml;VE</a>"
5 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -135,6 +135,11 @@ credits = [ · 134 unmodified lines
135 'Rich Hickey',135 'Rich Hickey',
136 'EPL',136 'EPL',
137 'https://github.com/clojure/clojure/blob/master/epl-v10.html'137 'https://github.com/clojure/clojure/blob/master/epl-v10.html'
138 ], [
139 'CMake',
140 '2000-2016 Kitware, Inc.<br>&copy; 2000-2011 Insight Software Consortium',
141 'BSD',
142 'https://cmake.org/licensing/'
138 ], [143 ], [
139 'CodeIgniter',144 'CodeIgniter',
140 '2014-2016 British Columbia Institute of Technology',145 '2014-2016 British Columbia Institute of Technology',
assets/stylesheets/global/_icons.scss+1−0
@@ -132,6 +132,7 @@ · 131 unmodified lines
132._icon-q:before { background-position: -5rem -8rem; }132._icon-q:before { background-position: -5rem -8rem; }
133._icon-react_native:before { background-position: 0 -9rem; }133._icon-react_native:before { background-position: 0 -9rem; }
134._icon-phalcon:before { background-position: -1rem -9rem; }134._icon-phalcon:before { background-position: -1rem -9rem; }
135._icon-cmake:before { background-position: -3rem -9rem; }
135._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }136._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
136._icon-vagrant:before { background-position: -5rem -9rem; }137._icon-vagrant:before { background-position: -5rem -9rem; }
137._icon-dojo:before { background-position: -6rem -9rem; }138._icon-dojo:before { background-position: -6rem -9rem; }
lib/docs/filters/cmake/clean_html.rb+34−26
@@ -1,39 +1,47 @@
1module Docs1module Docs
2 class Cmake2 class Cmake
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 # since each property category has its own entry redirect to that one instead
5 URL_MAPPING = {
6 '/manual/cmake-properties.7#properties-of-global-scope' => '/../cmake-properties-of-global-scope/',
7 '/manual/cmake-properties.7#properties-on-directories' => '/../cmake-properties-on-directories/',
8 '/manual/cmake-properties.7#target-properties' => '/../cmake-properties-on-targets/',
9 '/manual/cmake-properties.7.html#properties-on-tests' => '/../cmake-properties-on-tests/',
10 '/manual/cmake-properties.7.html#properties-on-source-files' => '/../cmake-properties-on-source-files/',
11 '/manual/cmake-properties.7.html#properties-on-cache-entries' => '/../cmake-properties-on-cache-entries/',
12 '/manual/cmake-properties.7.html#properties-on-installed-files' => '/../cmake-properties-on-installed-files/',
13 '/manual/cmake-properties.7.html#deprecated-properties-on-directories' => '/../cmake-deprecated-properties-on-directories/',
14 '/manual/cmake-properties.7.html#deprecated-properties-on-targets' => '/../cmake-deprecated-properties-on-targets/',
15 '/manual/cmake-properties.7.html#deprecated-properties-on-source-files' => '/../cmake-deprecated-properties-on-source-files/'
16 }
17
18 def call4 def call
19 css('.headerlink').remove5 css('.headerlink', '#contents .topic-title').remove
6
20 if root_page?7 if root_page?
21 css('#release-notes').remove8 css('#release-notes', '#index-and-search').remove
22 css('#index-and-search').remove9
23 return doc10 css('h1').each do |node|
11 node.name = 'h2'
12 end
13 end
14
15 css('.contents > ul.simple > li:first-child:last-child').each do |node|
16 node.parent.before(node.at_css('> ul'))
17 node.remove
24 end18 end
25 css('.toc-backref').each do |link|19
26 link.replace(link.text)20 css('.toc-backref', '.toctree-wrapper', '.contents', 'span.pre', 'pre a > code').each do |node|
21 node.before(node.children).remove
22 end
23
24 css('div[class*="highlight-"]').each do |node|
25 pre = node.at_css('pre')
26 pre.content = pre.content
27 node.replace(pre)
27 end28 end
28 css('#contents').remove
29 29
30 # change urls pointing to entries which don't have a default entry30 css('span[id]:empty').each do |node|
31 css('a').each do |link|31 node.next_element['id'] = node['id']
32 URL_MAPPING.each do |key, value|32 node.remove
33 if link['href'].end_with? key33 end
34 link['href'] = link['href'][0..-(key.length + 1)] + value34
35 css('.section').each do |node|
36 if node['id']
37 if node.first_element_child['id']
38 node.element_children[1]['id'] = node['id']
39 else
40 node.first_element_child['id'] = node['id']
35 end41 end
36 end42 end
43
44 node.before(node.children).remove
37 end45 end
38 46
39 doc47 doc
lib/docs/filters/cmake/entries.rb+20−42
@@ -1,63 +1,41 @@
1module Docs1module Docs
2 class Cmake2 class Cmake
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 MISCELLANEOUS = {4 NAME_BY_SLUG = {
5 'manual/cmake.1' => 'CMake',5 'manual/cmake.1' => 'CMake',
6 'manual/ctest.1' => 'CTest',6 'manual/ctest.1' => 'CTest',
7 'manual/cpack.1' => 'CPack',7 'manual/cpack.1' => 'CPack',
8 'manual/cmake-gui.1' => 'CMake GUI',8 'manual/cmake-gui.1' => 'CMake GUI',
9 'manual/ccmake.1' => 'CCMake',9 'manual/ccmake.1' => 'CCMake' }
10 'manual/cmake-buildsystem.7' => 'Buildsystem',
11 'manual/cmake-commands.7' => 'Commands',
12 'manual/cmake-compile-features.7' => 'Compile Features',
13 'manual/cmake-developer.7' => 'Developer',
14 'manual/cmake-generator-expressions.7' => 'Generator Expressions',
15 'manual/cmake-generators.7' => 'Generators',
16 'manual/cmake-language.7' => 'Language',
17 'manual/cmake-modules.7' => 'Modules',
18 'manual/cmake-packages.7' => 'Packages',
19 'manual/cmake-policies.7' => 'Policies',
20 'manual/cmake-properties.7' => 'Properties',
21 'manual/cmake-qt.7' => 'Qt',
22 'manual/cmake-toolchains.7' => 'Toolchains',
23 'manual/cmake-variables.7' => 'Variables' }
24 10
25 GROUPS = {11 TYPE_BY_DIR = {
26 'command' => 'Commands',12 'command' => 'Commands',
13 'manual' => 'Manual',
14 'module' => 'Modules',
27 'policy' => 'Policies',15 'policy' => 'Policies',
16 'prop_cache' => 'Properties: Cache Entries',
17 'prop_dir' => 'Properties: Directories',
28 'prop_gbl' => 'Properties of Global Scope',18 'prop_gbl' => 'Properties of Global Scope',
29 'prop_dir' => 'Properties on Directories',19 'prop_inst' => 'Properties: Installed Files',
30 'prop_tgt' => 'Properties on Targets',20 'prop_sf' => 'Properties: Source Files',
31 'prop_test' => 'Properties on Tests',21 'prop_test' => 'Properties: Tests',
32 'prop_sf' => 'Properties on Source Files',22 'prop_tgt' => 'Properties: Targets',
33 'prop_cache' => 'Properties on Cache Entries',
34 'prop_inst' => 'Properties on Installed Files',
35 'variable' => 'Variables' }23 'variable' => 'Variables' }
36 24
37 def get_name25 def get_name
38 if MISCELLANEOUS.key?(slug)26 if NAME_BY_SLUG.key?(slug)
39 return MISCELLANEOUS[slug]27 NAME_BY_SLUG[slug]
28 elsif slug =~ /\Amanual\/cmake-([\w\-]+)\.7\z/
29 $1.titleize
30 else
31 dir, name = slug.split('/')
32 name << '()' if dir == 'command'
33 name
40 end34 end
41 parts = slug.split('/')
42 name = parts.drop(1).first
43 if name == ''
44 return slug
45 end
46 if parts.first == 'command'
47 name += '()'
48 end
49 name
50 end35 end
51 36
52 def get_type37 def get_type
53 if MISCELLANEOUS.key?(slug)38 TYPE_BY_DIR[slug.split('/').first]
54 return 'Miscellaneous'
55 end
56 parts = slug.split('/')
57 if GROUPS.key?(parts.first)
58 return GROUPS[parts.first]
59 end
60 slug
61 end39 end
62 end40 end
63 end41 end
lib/docs/scrapers/cmake.rb+16−19
@@ -1,32 +1,29 @@
1module Docs1module Docs
2 class Cmake < UrlScraper2 class Cmake < UrlScraper
3 self.name = 'CMake'3 self.name = 'CMake'
4 self.slug = 'cmake'4 self.type = 'sphinx_simple'
5 self.type = 'cmake'5 self.links = {
6 self.release = '3.5'6 home: 'https://cmake.org/',
7 self.base_url = 'https://cmake.org/cmake/help/v3.5/'7 code: 'https://cmake.org/gitweb?p=cmake.git;a=summary'
8 }
8 9
9 options[:skip] = %w(10 html_filters.push 'cmake/clean_html', 'cmake/entries', 'title'
10 release/index.html
11 genindex.html
12 search.html
13 )
14
15 options[:only_patterns] = [
16 /manual/,
17 /command/,
18 /policy/,
19 /prop_/,
20 /variable/
21 ]
22 11
23 options[:container] = '.body'12 options[:container] = '.body'
24 13 options[:title] = false
25 html_filters.push 'cmake/clean_html', 'cmake/entries'14 options[:root_title] = 'CMake Reference Documentation'
15 options[:skip] = %w(release/index.html genindex.html search.html)
16 options[:skip_patterns] = [/\Agenerator/, /\Ainclude/, /\Arelease/]
26 17
27 options[:attribution] = <<-HTML18 options[:attribution] = <<-HTML
28 &copy; 2000&ndash;2016 Kitware, Inc.<br>19 &copy; 2000&ndash;2016 Kitware, Inc.<br>
20 &copy; 2000&ndash;2011 Insight Software Consortium<br>
29 Licensed under the BSD 3-clause License.21 Licensed under the BSD 3-clause License.
30 HTML22 HTML
23
24 version '3.5' do
25 self.release = '3.5.2'
26 self.base_url = 'https://cmake.org/cmake/help/v3.5/'
27 end
31 end28 end
32end29end
public/icons/docs/cmake/16.png+0−0

Binary file not shown.

public/icons/docs/cmake/16@2x.png+0−0

Binary file not shown.

public/icons/docs/cmake/SOURCE+1−0
@@ -0,0 +1 @@
1https://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Source/QtDialog/CMakeSetup.ico;hb=refs/heads/master