mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1408 from scherepn/pallets-projects
Add Pallets projects (Flask, Jinja, and Werkzeug) documentation
This commit is contained in:
commit
31264ad08f
16 changed files with 334 additions and 0 deletions
|
@ -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>© 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',
|
||||
|
|
82
lib/docs/filters/flask/entries.rb
Executable file
82
lib/docs/filters/flask/entries.rb
Executable 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
|
55
lib/docs/filters/jinja/entries.rb
Executable file
55
lib/docs/filters/jinja/entries.rb
Executable 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
|
61
lib/docs/filters/werkzeug/entries.rb
Executable file
61
lib/docs/filters/werkzeug/entries.rb
Executable 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
40
lib/docs/scrapers/flask.rb
Executable 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
|
||||
© 2007–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
39
lib/docs/scrapers/jinja.rb
Executable 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
|
||||
© 2007–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
39
lib/docs/scrapers/werkzeug.rb
Executable 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
|
||||
© 2007–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
|
BIN
public/icons/docs/flask/16.png
Normal file
BIN
public/icons/docs/flask/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
public/icons/docs/flask/16@2x.png
Normal file
BIN
public/icons/docs/flask/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
1
public/icons/docs/flask/SOURCE
Normal file
1
public/icons/docs/flask/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://flask.palletsprojects.com/en/1.1.x/_static/flask-icon.png
|
BIN
public/icons/docs/jinja/16.png
Normal file
BIN
public/icons/docs/jinja/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
public/icons/docs/jinja/16@2x.png
Normal file
BIN
public/icons/docs/jinja/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
1
public/icons/docs/jinja/SOURCE
Normal file
1
public/icons/docs/jinja/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://jinja.palletsprojects.com/en/2.11.x/_static/jinja-logo-sidebar.png
|
BIN
public/icons/docs/werkzeug/16.png
Normal file
BIN
public/icons/docs/werkzeug/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 801 B |
BIN
public/icons/docs/werkzeug/16@2x.png
Normal file
BIN
public/icons/docs/werkzeug/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
1
public/icons/docs/werkzeug/SOURCE
Normal file
1
public/icons/docs/werkzeug/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://werkzeug.palletsprojects.com/en/1.0.x/_static/favicon.ico
|
Loading…
Reference in a new issue