1
0
Эх сурвалжийг харах

Merge pull request #1879 from vallabhtiwari/wagtail

Added doc support for Wagtail a Content Management System based on Django
Simon Legner 3 жил өмнө
parent
commit
5ac1a4d9c8

+ 6 - 1
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -970,7 +970,12 @@ credits = [
     '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',
     'CC BY',
     'https://creativecommons.org/licenses/by/4.0/'
-  ], [
+  ],[
+    'wagtail',
+    '2014-present Torchbox Ltd and individual contributors',
+    'BSD',
+    'https://github.com/wagtail/wagtail/blob/main/LICENSE'
+  ],[
     'webpack',
     'JS Foundation and other contributors',
     'CC BY',

+ 5 - 0
assets/stylesheets/pages/_sphinx.scss

@@ -47,6 +47,11 @@
   span.descclassname, span.descname { font-family: var(--monoFont) }
 }
 
+nav[aria-label="Page navigation"]{
+  display: flex !important;
+  justify-content: space-between !important;
+}
+
 ._sphinx {
   @extend %sphinx;
 }

+ 67 - 0
lib/docs/filters/wagtail/clean_html.rb

@@ -0,0 +1,67 @@
+module Docs
+  class Wagtail
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('main > section', 'main')
+
+        # footer contains links like about,contact us etc which
+        # are not needed in documentation so removed
+        doc.search('footer').each do |footer|
+          footer.remove
+        end
+
+        # aside bar contains the search bar and navigation links
+        # which are not needed
+        doc.search('aside').each do |aside|
+          aside.remove
+        end
+
+        # header contains links which are not needed(see sourch code of Wagtail docs)
+        doc.search('header').each do |head|
+          head.remove
+        end
+
+        # nav bar contains the search bar and navigation links(older versions)
+        # which are not needed
+        doc.search('nav.wy-nav-side').each do |nav|
+          nav.remove
+        end
+
+        # removing unimportant links(older versions)
+        doc.search('nav.wy-nav-top').each do |nav|
+          nav.remove
+        end
+
+        # removing unimportant links from header of very old versions
+        doc.search('ul.wy-breadcrumbs').each do |ul|
+          ul.remove
+        end
+
+        # removing release notes
+        doc.search('li.toctree-l1').each do |li|
+          li.remove if li.to_s.include? 'Release notes'
+        end
+
+        # removing release notes(older versions)
+        doc.search('dl').each do |dl|
+          dl.remove
+        end
+
+        # removing scripts and style
+        css('script', 'style', 'link').remove
+        css('hr').remove
+        # Make proper table headers
+        css('td.header').each do |node|
+          node.name = 'th'
+        end
+
+        # Remove code highlighting
+        css('pre').each do |node|
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 15 - 0
lib/docs/filters/wagtail/entries.rb

@@ -0,0 +1,15 @@
+module Docs
+  class Wagtail
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        # removing the pilcrow sign and returning the heading
+        at_css('h1').content.strip.remove("\u{00b6}")
+      end
+
+      def get_type
+        object, method = *slug.split('/')
+        method ? object : 'Miscellaneous'
+      end
+    end
+  end
+end

+ 48 - 0
lib/docs/scrapers/wagtail.rb

@@ -0,0 +1,48 @@
+module Docs
+  class Wagtail < UrlScraper
+    self.name = 'Wagtail'
+    self.type = 'sphinx'
+    self.root_path = 'index.html'
+    self.links = {
+      home: 'https://wagtail.org/',
+      code: 'https://github.com/wagtail/wagtail'
+    }
+
+    # adding filters from lib/docs/filters/wagtail
+    html_filters.push 'wagtail/entries', 'sphinx/clean_html', 'wagtail/clean_html'
+
+    # attributions are seen at the bottom of every page(copyright and license etc. details)
+    options[:attribution] = <<-HTML
+      &copy; 2014-present Torchbox Ltd and individual contributors.<br>
+      All rights are reserved.<br>
+      Licensed under the BSD License.
+    HTML
+
+    # no one wants to see docs about search or release notes
+    options[:skip] = %w[search.html]
+    options[:skip_patterns] = [
+      %r{\Areleases/}
+    ]
+
+    # updating release and base_url for different versions
+    version do
+      self.release = '4.1.1'
+      self.base_url = 'https://docs.wagtail.org/en/stable/'
+    end
+
+    version '3' do
+      self.release = '3.0.3'
+      self.base_url = "https://docs.wagtail.org/en/v#{release}/"
+    end
+
+    version '2' do
+      self.release = '2.16.3'
+      self.base_url = "https://docs.wagtail.org/en/v#{release}/"
+    end
+
+    # this method will fetch the latest version of wagtail
+    def get_latest_version(opts)
+      get_latest_github_release('wagtail', 'wagtail', opts)
+    end
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://github.com/wagtail/wagtail/blob/main/docs/logo.png