Merge pull request #1879 from vallabhtiwari/wagtail

Added doc support for Wagtail a Content Management System based on Django
This commit is contained in:
Simon Legner 2022-12-20 22:51:10 +01:00 committed by GitHub
commit 5ac1a4d9c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 142 additions and 1 deletions

View file

@ -970,6 +970,11 @@ 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',

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

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