Forráskód Böngészése

Finish CMake scraper

Thibaut Courouble 9 éve
szülő
commit
ab41f0c0ca

BIN
assets/images/docs.png


BIN
assets/images/docs@2x.png


+ 3 - 0
assets/javascripts/news.json

@@ -1,5 +1,8 @@
 [
   [
+    "2016-07-02",
+    "New documentation: <a href=\"/cmake/\">CMake</a>"
+  ], [
     "2016-06-19",
     "New documentation: <a href=\"/love/\">L&Ouml;VE</a>"
   ], [

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -135,6 +135,11 @@ credits = [
     'Rich Hickey',
     'EPL',
     'https://github.com/clojure/clojure/blob/master/epl-v10.html'
+  ], [
+    'CMake',
+    '2000-2016 Kitware, Inc.<br>&copy; 2000-2011 Insight Software Consortium',
+    'BSD',
+    'https://cmake.org/licensing/'
   ], [
     'CodeIgniter',
     '2014-2016 British Columbia Institute of Technology',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -132,6 +132,7 @@
 ._icon-q:before             { background-position: -5rem -8rem; }
 ._icon-react_native:before  { background-position: 0 -9rem; }
 ._icon-phalcon:before       { background-position: -1rem -9rem; }
+._icon-cmake:before         { background-position: -3rem -9rem; }
 ._icon-elixir:before        { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
 ._icon-vagrant:before       { background-position: -5rem -9rem; }
 ._icon-dojo:before          { background-position: -6rem -9rem; }

+ 34 - 26
lib/docs/filters/cmake/clean_html.rb

@@ -1,39 +1,47 @@
 module Docs
   class Cmake
     class CleanHtmlFilter < Filter
-      # since each property category has its own entry redirect to that one instead
-      URL_MAPPING = {
-        '/manual/cmake-properties.7#properties-of-global-scope' => '/../cmake-properties-of-global-scope/',
-        '/manual/cmake-properties.7#properties-on-directories' => '/../cmake-properties-on-directories/',
-        '/manual/cmake-properties.7#target-properties' => '/../cmake-properties-on-targets/',
-        '/manual/cmake-properties.7.html#properties-on-tests' => '/../cmake-properties-on-tests/',
-        '/manual/cmake-properties.7.html#properties-on-source-files' => '/../cmake-properties-on-source-files/',
-        '/manual/cmake-properties.7.html#properties-on-cache-entries' => '/../cmake-properties-on-cache-entries/',
-        '/manual/cmake-properties.7.html#properties-on-installed-files' => '/../cmake-properties-on-installed-files/',
-        '/manual/cmake-properties.7.html#deprecated-properties-on-directories' => '/../cmake-deprecated-properties-on-directories/',
-        '/manual/cmake-properties.7.html#deprecated-properties-on-targets' => '/../cmake-deprecated-properties-on-targets/',
-        '/manual/cmake-properties.7.html#deprecated-properties-on-source-files' => '/../cmake-deprecated-properties-on-source-files/'
-      }
-
       def call
-        css('.headerlink').remove
+        css('.headerlink', '#contents .topic-title').remove
+
         if root_page?
-          css('#release-notes').remove
-          css('#index-and-search').remove
-          return doc
+          css('#release-notes', '#index-and-search').remove
+
+          css('h1').each do |node|
+            node.name = 'h2'
+          end
+        end
+
+        css('.contents > ul.simple > li:first-child:last-child').each do |node|
+          node.parent.before(node.at_css('> ul'))
+          node.remove
         end
-        css('.toc-backref').each do |link|
-          link.replace(link.text)
+
+        css('.toc-backref', '.toctree-wrapper', '.contents', 'span.pre', 'pre a > code').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('div[class*="highlight-"]').each do |node|
+          pre = node.at_css('pre')
+          pre.content = pre.content
+          node.replace(pre)
         end
-        css('#contents').remove
 
-        # change urls pointing to entries which don't have a default entry
-        css('a').each do |link|
-          URL_MAPPING.each do |key, value|
-            if link['href'].end_with? key
-              link['href'] = link['href'][0..-(key.length + 1)] + value
+        css('span[id]:empty').each do |node|
+          node.next_element['id'] = node['id']
+          node.remove
+        end
+
+        css('.section').each do |node|
+          if node['id']
+            if node.first_element_child['id']
+              node.element_children[1]['id'] = node['id']
+            else
+              node.first_element_child['id'] = node['id']
             end
           end
+
+          node.before(node.children).remove
         end
 
         doc

+ 20 - 42
lib/docs/filters/cmake/entries.rb

@@ -1,63 +1,41 @@
 module Docs
   class Cmake
     class EntriesFilter < Docs::EntriesFilter
-      MISCELLANEOUS = {
+      NAME_BY_SLUG = {
         'manual/cmake.1' => 'CMake',
         'manual/ctest.1' => 'CTest',
         'manual/cpack.1' => 'CPack',
         'manual/cmake-gui.1' => 'CMake GUI',
-        'manual/ccmake.1' => 'CCMake',
-        'manual/cmake-buildsystem.7' => 'Buildsystem',
-        'manual/cmake-commands.7' => 'Commands',
-        'manual/cmake-compile-features.7' => 'Compile Features',
-        'manual/cmake-developer.7' => 'Developer',
-        'manual/cmake-generator-expressions.7' => 'Generator Expressions',
-        'manual/cmake-generators.7' => 'Generators',
-        'manual/cmake-language.7' => 'Language',
-        'manual/cmake-modules.7' => 'Modules',
-        'manual/cmake-packages.7' => 'Packages',
-        'manual/cmake-policies.7' => 'Policies',
-        'manual/cmake-properties.7' => 'Properties',
-        'manual/cmake-qt.7' => 'Qt',
-        'manual/cmake-toolchains.7' => 'Toolchains',
-        'manual/cmake-variables.7' => 'Variables' }
+        'manual/ccmake.1' => 'CCMake' }
 
-      GROUPS = {
+      TYPE_BY_DIR = {
         'command' => 'Commands',
+        'manual' => 'Manual',
+        'module' => 'Modules',
         'policy' => 'Policies',
+        'prop_cache' => 'Properties: Cache Entries',
+        'prop_dir' => 'Properties: Directories',
         'prop_gbl' => 'Properties of Global Scope',
-        'prop_dir' => 'Properties on Directories',
-        'prop_tgt' => 'Properties on Targets',
-        'prop_test' => 'Properties on Tests',
-        'prop_sf' => 'Properties on Source Files',
-        'prop_cache' => 'Properties on Cache Entries',
-        'prop_inst' => 'Properties on Installed Files',
+        'prop_inst' => 'Properties: Installed Files',
+        'prop_sf' => 'Properties: Source Files',
+        'prop_test' => 'Properties: Tests',
+        'prop_tgt' => 'Properties: Targets',
         'variable' => 'Variables' }
 
       def get_name
-        if MISCELLANEOUS.key?(slug)
-          return MISCELLANEOUS[slug]
+        if NAME_BY_SLUG.key?(slug)
+          NAME_BY_SLUG[slug]
+        elsif slug =~ /\Amanual\/cmake-([\w\-]+)\.7\z/
+          $1.titleize
+        else
+          dir, name = slug.split('/')
+          name << '()' if dir == 'command'
+          name
         end
-        parts = slug.split('/')
-        name = parts.drop(1).first
-        if name == ''
-          return slug
-        end
-        if parts.first == 'command'
-          name += '()'
-        end
-        name
       end
 
       def get_type
-        if MISCELLANEOUS.key?(slug)
-          return 'Miscellaneous'
-        end
-        parts = slug.split('/')
-        if GROUPS.key?(parts.first)
-          return GROUPS[parts.first]
-        end
-        slug
+        TYPE_BY_DIR[slug.split('/').first]
       end
     end
   end

+ 16 - 19
lib/docs/scrapers/cmake.rb

@@ -1,32 +1,29 @@
 module Docs
   class Cmake < UrlScraper
     self.name = 'CMake'
-    self.slug = 'cmake'
-    self.type = 'cmake'
-    self.release = '3.5'
-    self.base_url = 'https://cmake.org/cmake/help/v3.5/'
+    self.type = 'sphinx_simple'
+    self.links = {
+      home: 'https://cmake.org/',
+      code: 'https://cmake.org/gitweb?p=cmake.git;a=summary'
+    }
 
-    options[:skip] = %w(
-      release/index.html
-      genindex.html
-      search.html
-    )
-
-    options[:only_patterns] = [
-     /manual/,
-     /command/,
-     /policy/,
-     /prop_/,
-     /variable/
-    ]
+    html_filters.push 'cmake/clean_html', 'cmake/entries', 'title'
 
     options[:container] = '.body'
-
-    html_filters.push 'cmake/clean_html', 'cmake/entries'
+    options[:title] = false
+    options[:root_title] = 'CMake Reference Documentation'
+    options[:skip] = %w(release/index.html genindex.html search.html)
+    options[:skip_patterns] = [/\Agenerator/, /\Ainclude/, /\Arelease/]
 
     options[:attribution] = <<-HTML
       &copy; 2000&ndash;2016 Kitware, Inc.<br>
+      &copy; 2000&ndash;2011 Insight Software Consortium<br>
       Licensed under the BSD 3-clause License.
     HTML
+
+    version '3.5' do
+      self.release = '3.5.2'
+      self.base_url = 'https://cmake.org/cmake/help/v3.5/'
+    end
   end
 end

BIN
public/icons/docs/cmake/16.png


BIN
public/icons/docs/cmake/16@2x.png


+ 1 - 0
public/icons/docs/cmake/SOURCE

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