mirror of https://github.com/freeCodeCamp/devdocs
Merge pull request #1879 from vallabhtiwari/wagtail
Added doc support for Wagtail a Content Management System based on Djangopull/1896/head
commit
5ac1a4d9c8
@ -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
|
@ -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
|
@ -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
|
||||
© 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
|
After Width: | Height: | Size: 553 B |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1 @@
|
||||
https://github.com/wagtail/wagtail/blob/main/docs/logo.png
|
Loading…
Reference in new issue