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 @@
11 [
22 [
3+ "2016-07-02",
4+ "New documentation: <a href=\"/cmake/\">CMake</a>"
5+ ], [
36 "2016-06-19",
47 "New documentation: <a href=\"/love/\">L&Ouml;VE</a>"
58 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -135,6 +135,11 @@ credits = [ · 134 unmodified lines
135135 'Rich Hickey',
136136 'EPL',
137137 '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/'
138143 ], [
139144 'CodeIgniter',
140145 '2014-2016 British Columbia Institute of Technology',
assets/stylesheets/global/_icons.scss+1−0
@@ -132,6 +132,7 @@ · 131 unmodified lines
132132 ._icon-q:before { background-position: -5rem -8rem; }
133133 ._icon-react_native:before { background-position: 0 -9rem; }
134134 ._icon-phalcon:before { background-position: -1rem -9rem; }
135+._icon-cmake:before { background-position: -3rem -9rem; }
135136 ._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
136137 ._icon-vagrant:before { background-position: -5rem -9rem; }
137138 ._icon-dojo:before { background-position: -6rem -9rem; }
lib/docs/filters/cmake/clean_html.rb+34−26
@@ -1,39 +1,47 @@
11 module Docs
22 class Cmake
33 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−
184 def call
19− css('.headerlink').remove
5+ css('.headerlink', '#contents .topic-title').remove
6+
207 if root_page?
21− css('#release-notes').remove
22− css('#index-and-search').remove
23− return doc
8+ css('#release-notes', '#index-and-search').remove
9+
10+ 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
2418 end
25− css('.toc-backref').each do |link|
26− link.replace(link.text)
19+
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)
2728 end
28− css('#contents').remove
2929
30− # change urls pointing to entries which don't have a default entry
31− css('a').each do |link|
32− URL_MAPPING.each do |key, value|
33− if link['href'].end_with? key
34− link['href'] = link['href'][0..-(key.length + 1)] + value
30+ css('span[id]:empty').each do |node|
31+ node.next_element['id'] = node['id']
32+ node.remove
33+ end
34+
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']
3541 end
3642 end
43+
44+ node.before(node.children).remove
3745 end
3846
3947 doc
lib/docs/filters/cmake/entries.rb+20−42
@@ -1,63 +1,41 @@
11 module Docs
22 class Cmake
33 class EntriesFilter < Docs::EntriesFilter
4− MISCELLANEOUS = {
4+ NAME_BY_SLUG = {
55 'manual/cmake.1' => 'CMake',
66 'manual/ctest.1' => 'CTest',
77 'manual/cpack.1' => 'CPack',
88 'manual/cmake-gui.1' => 'CMake GUI',
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' }
9+ 'manual/ccmake.1' => 'CCMake' }
2410
25− GROUPS = {
11+ TYPE_BY_DIR = {
2612 'command' => 'Commands',
13+ 'manual' => 'Manual',
14+ 'module' => 'Modules',
2715 'policy' => 'Policies',
16+ 'prop_cache' => 'Properties: Cache Entries',
17+ 'prop_dir' => 'Properties: Directories',
2818 'prop_gbl' => 'Properties of Global Scope',
29− 'prop_dir' => 'Properties on Directories',
30− 'prop_tgt' => 'Properties on Targets',
31− 'prop_test' => 'Properties on Tests',
32− 'prop_sf' => 'Properties on Source Files',
33− 'prop_cache' => 'Properties on Cache Entries',
34− 'prop_inst' => 'Properties on Installed Files',
19+ 'prop_inst' => 'Properties: Installed Files',
20+ 'prop_sf' => 'Properties: Source Files',
21+ 'prop_test' => 'Properties: Tests',
22+ 'prop_tgt' => 'Properties: Targets',
3523 'variable' => 'Variables' }
3624
3725 def get_name
38− if MISCELLANEOUS.key?(slug)
39− return MISCELLANEOUS[slug]
26+ if NAME_BY_SLUG.key?(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
4034 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
5035 end
5136
5237 def get_type
53− if MISCELLANEOUS.key?(slug)
54− return 'Miscellaneous'
55− end
56− parts = slug.split('/')
57− if GROUPS.key?(parts.first)
58− return GROUPS[parts.first]
59− end
60− slug
38+ TYPE_BY_DIR[slug.split('/').first]
6139 end
6240 end
6341 end
lib/docs/scrapers/cmake.rb+16−19
@@ -1,32 +1,29 @@
11 module Docs
22 class Cmake < UrlScraper
33 self.name = 'CMake'
4− self.slug = 'cmake'
5− self.type = 'cmake'
6− self.release = '3.5'
7− self.base_url = 'https://cmake.org/cmake/help/v3.5/'
4+ self.type = 'sphinx_simple'
5+ self.links = {
6+ home: 'https://cmake.org/',
7+ code: 'https://cmake.org/gitweb?p=cmake.git;a=summary'
8+ }
89
9− options[:skip] = %w(
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− ]
10+ html_filters.push 'cmake/clean_html', 'cmake/entries', 'title'
2211
2312 options[:container] = '.body'
24−
25− html_filters.push 'cmake/clean_html', 'cmake/entries'
13+ options[:title] = false
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/]
2617
2718 options[:attribution] = <<-HTML
2819 &copy; 2000&ndash;2016 Kitware, Inc.<br>
20+ &copy; 2000&ndash;2011 Insight Software Consortium<br>
2921 Licensed under the BSD 3-clause License.
3022 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
3128 end
3229 end
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 @@
1+https://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Source/QtDialog/CMakeSetup.ico;hb=refs/heads/master