Merge pull request #1408 from scherepn/pallets-projects

Add Pallets projects (Flask, Jinja, and Werkzeug) documentation
This commit is contained in:
Simon Legner 2020-12-07 12:42:17 +01:00 committed by GitHub
commit 31264ad08f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 334 additions and 0 deletions

View file

@ -306,6 +306,11 @@ credits = [
'2005-2009 Axel Liljencrantz',
'GPLv2',
'https://fishshell.com/docs/current/license.html'
], [
'Flask',
'2007-2020 Pallets',
'BSD',
'https://github.com/pallets/flask/blob/master/LICENSE.rst'
], [
'GCC<br>GNU Fortran',
'Free Software Foundation',
@ -401,6 +406,11 @@ credits = [
'2020 Facebook, Inc.',
'MIT',
'https://raw.githubusercontent.com/facebook/jest/master/LICENSE'
], [
'Jinja',
'2007-2020 Pallets',
'BSD',
'https://github.com/pallets/jinja/blob/master/LICENSE.rst'
], [
'jQuery',
'Packt Publishing<br>&copy; jQuery Foundation and other contributors',
@ -831,6 +841,11 @@ credits = [
'JS Foundation and other contributors',
'CC BY',
'https://creativecommons.org/licenses/by/4.0/'
], [
'Werkzeug',
'2007-2020 Pallets',
'BSD',
'https://github.com/pallets/werkzeug/blob/master/LICENSE.rst'
], [
'Wordpress',
'2003-2019 WordPress Foundation',

View file

@ -0,0 +1,82 @@
module Docs
class Flask
class EntriesFilter < Docs::EntriesFilter
TYPE_BY_SLUG = {}
def call
if root_page?
css('.section').each do |node|
type = node.at_css('h2').content[0..-2]
node.css('li > a').each do |n|
s = n['href'].split('/')[-2]
TYPE_BY_SLUG[s] = type
end
end
end
super
end
def get_name
at_css('h1').content[0..-2]
end
def get_type
case slug
when /deploying/
'User\'s Guide: Deploying'
when /patterns/
'User\'s Guide: Design Patterns'
else
TYPE_BY_SLUG[slug.split('/').first] || 'Other'
end
end
def include_default_entry?
slug != 'api/'
end
def additional_entries
entries = []
css('dl.function > dt[id]').each do |node|
name = node['id'].split('.').last + '()'
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
entries << [name, id, type]
end
css('dl.class > dt[id]').each do |node|
name = node['id'].split('.').last
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
entries << [name, id, type]
end
css('dl.attribute > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.')
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
type = 'flask' if type == ''
entries << [name, id, type]
end
css('dl.data > dt[id]').each do |node|
name = node['id']
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
type = 'flask' if type == ''
type = 'Configuration' if slug == 'config/'
entries << [name, id, type]
end
css('dl.method > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.') + '()'
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
entries << [name, id, type]
end
entries
end
end
end
end

View file

@ -0,0 +1,55 @@
module Docs
class Jinja
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1').content[0..-2]
end
def get_type
'User Guide'
end
def include_default_entry?
slug != 'api/'
end
def additional_entries
entries = []
css('dl.function > dt[id]').each do |node|
name = node['id'].split('.').last + '()'
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
type = 'Template Language' if slug == 'templates/'
entries << [name, id, type]
end
css('dl.class > dt[id], dl.exception > dt[id]').each do |node|
name = node['id'].split('.').last
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
type = 'Template Language' if slug == 'templates/'
entries << [name, id, type]
end
css('dl.attribute > dt[id], dl.property > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.')
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
type = 'Template Language' if slug == 'templates/'
entries << [name, id, type]
end
css('dl.method > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.') + '()'
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
type = 'Template Language' if slug == 'templates/'
entries << [name, id, type]
end
entries
end
end
end
end

View file

@ -0,0 +1,61 @@
module Docs
class Werkzeug
class EntriesFilter < Docs::EntriesFilter
TYPE_BY_SLUG = {}
def call
if root_page?
css('.section').each do |node|
type = node.at_css('h2').content[0..-2]
node.css('li > a').each do |n|
s = n['href'].split('/')[-2]
TYPE_BY_SLUG[s] = type
end
end
end
super
end
def get_name
at_css('h1').content[0..-2]
end
def get_type
TYPE_BY_SLUG[slug.split('/').first] || 'Other'
end
def additional_entries
entries = []
css('dl.function > dt[id]').each do |node|
name = node['id'].split('.').last + '()'
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
entries << [name, id, type]
end
css('dl.class > dt[id]').each do |node|
name = node['id'].split('.').last
id = node['id']
type = node['id'].split('.')[0..-2].join('.')
entries << [name, id, type]
end
css('dl.attribute > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.')
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
entries << [name, id, type]
end
css('dl.method > dt[id], dl.classmethod > dt[id], dl.staticmethod > dt[id]').each do |node|
name = node['id'].split('.')[-2..-1].join('.') + '()'
id = node['id']
type = node['id'].split('.')[0..-3].join('.')
entries << [name, id, type]
end
entries
end
end
end
end

40
lib/docs/scrapers/flask.rb Executable file
View file

@ -0,0 +1,40 @@
module Docs
class Flask < UrlScraper
self.type = 'sphinx'
self.root_path = 'index.html'
self.links = {
home: 'https://palletsprojects.com/p/flask/',
code: 'https://github.com/pallets/flask'
}
html_filters.push 'flask/entries', 'sphinx/clean_html'
options[:container] = '.body > .section'
options[:skip] = %w(extensiondev/ styleguide/ upgrading/ changelog/ license/ contributing/)
options[:skip_patterns] = [/\Atutorial\//]
options[:attribution] = <<-HTML
&copy; 2007&ndash;2020 Pallets<br>
Licensed under the BSD 3-clause License.
HTML
version '1.1' do
self.release = '1.1.x'
self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
end
version '1.0' do
self.release = '1.0.x'
self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
end
version '0.12' do
self.release = '0.12.x'
self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
end
def get_latest_version(opts)
get_latest_github_release('pallets', 'flask', opts)
end
end
end

39
lib/docs/scrapers/jinja.rb Executable file
View file

@ -0,0 +1,39 @@
module Docs
class Jinja < UrlScraper
self.type = 'sphinx'
self.root_path = 'index.html'
self.links = {
home: 'https://palletsprojects.com/p/jinja/',
code: 'https://github.com/pallets/jinja'
}
html_filters.push 'jinja/entries', 'sphinx/clean_html'
options[:container] = '.body > .section'
options[:skip] = %w(integration/ switching/ faq/ changelog/ search/ genindex/)
options[:attribution] = <<-HTML
&copy; 2007&ndash;2020 Pallets<br>
Licensed under the BSD 3-clause License.
HTML
version '2.11' do
self.release = '2.11.x'
self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
end
version '2.10' do
self.release = '2.10.x'
self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
end
version '2.9' do
self.release = '2.9.x'
self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
end
def get_latest_version(opts)
get_latest_github_release('pallets', 'jinja', opts)
end
end
end

39
lib/docs/scrapers/werkzeug.rb Executable file
View file

@ -0,0 +1,39 @@
module Docs
class Werkzeug < UrlScraper
self.type = 'sphinx'
self.root_path = 'index.html'
self.links = {
home: 'https://palletsprojects.com/p/werkzeug/',
code: 'https://github.com/pallets/werkzeug'
}
html_filters.push 'werkzeug/entries', 'sphinx/clean_html'
options[:container] = '.body > .section'
options[:skip] = %w(changes/)
options[:attribution] = <<-HTML
&copy; 2007&ndash;2020 Pallets<br>
Licensed under the BSD 3-clause License.
HTML
version '1.0' do
self.release = '1.0.x'
self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
end
version '0.16' do
self.release = '0.16.x'
self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
end
version '0.15' do
self.release = '0.15.x'
self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
end
def get_latest_version(opts)
get_latest_github_release('pallets', 'werkzeug', opts)
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1 @@
https://flask.palletsprojects.com/en/1.1.x/_static/flask-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1 @@
https://jinja.palletsprojects.com/en/2.11.x/_static/jinja-logo-sidebar.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1 @@
https://werkzeug.palletsprojects.com/en/1.0.x/_static/favicon.ico