History

Merge pull request #1408 from scherepn/pallets-projects

Add Pallets projects (Flask, Jinja, and Werkzeug) documentation

Simon Legner committed 5 years ago

Commit 31264ad2 parents b924eb1 319074f16 files · +328 −-6Browse files

Unified · Split

16 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +15 −0
  2. lib/docs/filters/flask/entries.rb +82 −0
  3. lib/docs/filters/jinja/entries.rb +55 −0
  4. lib/docs/filters/werkzeug/entries.rb +61 −0
  5. lib/docs/scrapers/flask.rb +40 −0
  6. lib/docs/scrapers/jinja.rb +39 −0
  7. lib/docs/scrapers/werkzeug.rb +39 −0
  8. public/icons/docs/flask/16.png +0 −0
  9. public/icons/docs/flask/16@2x.png +0 −0
  10. public/icons/docs/flask/SOURCE +1 −0
  11. public/icons/docs/jinja/16.png +0 −0
  12. public/icons/docs/jinja/16@2x.png +0 −0
  13. public/icons/docs/jinja/SOURCE +1 −0
  14. public/icons/docs/werkzeug/16.png +0 −0
  15. public/icons/docs/werkzeug/16@2x.png +0 −0
  16. public/icons/docs/werkzeug/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+15−0
@@ -306,6 +306,11 @@ credits = [ · 305 unmodified lines
306306 '2005-2009 Axel Liljencrantz',
307307 'GPLv2',
308308 'https://fishshell.com/docs/current/license.html'
309+ ], [
310+ 'Flask',
311+ '2007-2020 Pallets',
312+ 'BSD',
313+ 'https://github.com/pallets/flask/blob/master/LICENSE.rst'
309314 ], [
310315 'GCC<br>GNU Fortran',
311316 'Free Software Foundation',
@@ -401,6 +406,11 @@ credits = [ · 89 unmodified lines
401406 '2020 Facebook, Inc.',
402407 'MIT',
403408 'https://raw.githubusercontent.com/facebook/jest/master/LICENSE'
409+ ], [
410+ 'Jinja',
411+ '2007-2020 Pallets',
412+ 'BSD',
413+ 'https://github.com/pallets/jinja/blob/master/LICENSE.rst'
404414 ], [
405415 'jQuery',
406416 'Packt Publishing<br>&copy; jQuery Foundation and other contributors',
@@ -831,6 +841,11 @@ credits = [ · 424 unmodified lines
831841 'JS Foundation and other contributors',
832842 'CC BY',
833843 'https://creativecommons.org/licenses/by/4.0/'
844+ ], [
845+ 'Werkzeug',
846+ '2007-2020 Pallets',
847+ 'BSD',
848+ 'https://github.com/pallets/werkzeug/blob/master/LICENSE.rst'
834849 ], [
835850 'Wordpress',
836851 '2003-2019 WordPress Foundation',
lib/docs/filters/flask/entries.rb+82−0
@@ -0,0 +1,82 @@
1+module Docs
2+ class Flask
3+ class EntriesFilter < Docs::EntriesFilter
4+ TYPE_BY_SLUG = {}
5+
6+ def call
7+ if root_page?
8+ css('.section').each do |node|
9+ type = node.at_css('h2').content[0..-2]
10+ node.css('li > a').each do |n|
11+ s = n['href'].split('/')[-2]
12+ TYPE_BY_SLUG[s] = type
13+ end
14+ end
15+ end
16+ super
17+ end
18+
19+ def get_name
20+ at_css('h1').content[0..-2]
21+ end
22+
23+ def get_type
24+ case slug
25+ when /deploying/
26+ 'User\'s Guide: Deploying'
27+ when /patterns/
28+ 'User\'s Guide: Design Patterns'
29+ else
30+ TYPE_BY_SLUG[slug.split('/').first] || 'Other'
31+ end
32+ end
33+
34+ def include_default_entry?
35+ slug != 'api/'
36+ end
37+
38+ def additional_entries
39+ entries = []
40+ css('dl.function > dt[id]').each do |node|
41+ name = node['id'].split('.').last + '()'
42+ id = node['id']
43+ type = node['id'].split('.')[0..-2].join('.')
44+ entries << [name, id, type]
45+ end
46+
47+ css('dl.class > dt[id]').each do |node|
48+ name = node['id'].split('.').last
49+ id = node['id']
50+ type = node['id'].split('.')[0..-2].join('.')
51+ entries << [name, id, type]
52+ end
53+
54+ css('dl.attribute > dt[id]').each do |node|
55+ name = node['id'].split('.')[-2..-1].join('.')
56+ id = node['id']
57+ type = node['id'].split('.')[0..-3].join('.')
58+ type = 'flask' if type == ''
59+ entries << [name, id, type]
60+ end
61+
62+ css('dl.data > dt[id]').each do |node|
63+ name = node['id']
64+ id = node['id']
65+ type = node['id'].split('.')[0..-3].join('.')
66+ type = 'flask' if type == ''
67+ type = 'Configuration' if slug == 'config/'
68+ entries << [name, id, type]
69+ end
70+
71+ css('dl.method > dt[id]').each do |node|
72+ name = node['id'].split('.')[-2..-1].join('.') + '()'
73+ id = node['id']
74+ type = node['id'].split('.')[0..-3].join('.')
75+ entries << [name, id, type]
76+ end
77+ entries
78+ end
79+
80+ end
81+ end
82+end
lib/docs/filters/jinja/entries.rb+55−0
@@ -0,0 +1,55 @@
1+module Docs
2+ class Jinja
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def get_name
6+ at_css('h1').content[0..-2]
7+ end
8+
9+ def get_type
10+ 'User Guide'
11+ end
12+
13+ def include_default_entry?
14+ slug != 'api/'
15+ end
16+
17+ def additional_entries
18+ entries = []
19+ css('dl.function > dt[id]').each do |node|
20+ name = node['id'].split('.').last + '()'
21+ id = node['id']
22+ type = node['id'].split('.')[0..-2].join('.')
23+ type = 'Template Language' if slug == 'templates/'
24+ entries << [name, id, type]
25+ end
26+
27+ css('dl.class > dt[id], dl.exception > dt[id]').each do |node|
28+ name = node['id'].split('.').last
29+ id = node['id']
30+ type = node['id'].split('.')[0..-2].join('.')
31+ type = 'Template Language' if slug == 'templates/'
32+ entries << [name, id, type]
33+ end
34+
35+ css('dl.attribute > dt[id], dl.property > dt[id]').each do |node|
36+ name = node['id'].split('.')[-2..-1].join('.')
37+ id = node['id']
38+ type = node['id'].split('.')[0..-3].join('.')
39+ type = 'Template Language' if slug == 'templates/'
40+ entries << [name, id, type]
41+ end
42+
43+ css('dl.method > dt[id]').each do |node|
44+ name = node['id'].split('.')[-2..-1].join('.') + '()'
45+ id = node['id']
46+ type = node['id'].split('.')[0..-3].join('.')
47+ type = 'Template Language' if slug == 'templates/'
48+ entries << [name, id, type]
49+ end
50+ entries
51+ end
52+
53+ end
54+ end
55+end
lib/docs/filters/werkzeug/entries.rb+61−0
@@ -0,0 +1,61 @@
1+module Docs
2+ class Werkzeug
3+ class EntriesFilter < Docs::EntriesFilter
4+ TYPE_BY_SLUG = {}
5+
6+ def call
7+ if root_page?
8+ css('.section').each do |node|
9+ type = node.at_css('h2').content[0..-2]
10+ node.css('li > a').each do |n|
11+ s = n['href'].split('/')[-2]
12+ TYPE_BY_SLUG[s] = type
13+ end
14+ end
15+ end
16+ super
17+ end
18+
19+ def get_name
20+ at_css('h1').content[0..-2]
21+ end
22+
23+ def get_type
24+ TYPE_BY_SLUG[slug.split('/').first] || 'Other'
25+ end
26+
27+ def additional_entries
28+ entries = []
29+ css('dl.function > dt[id]').each do |node|
30+ name = node['id'].split('.').last + '()'
31+ id = node['id']
32+ type = node['id'].split('.')[0..-2].join('.')
33+ entries << [name, id, type]
34+ end
35+
36+ css('dl.class > dt[id]').each do |node|
37+ name = node['id'].split('.').last
38+ id = node['id']
39+ type = node['id'].split('.')[0..-2].join('.')
40+ entries << [name, id, type]
41+ end
42+
43+ css('dl.attribute > dt[id]').each do |node|
44+ name = node['id'].split('.')[-2..-1].join('.')
45+ id = node['id']
46+ type = node['id'].split('.')[0..-3].join('.')
47+ entries << [name, id, type]
48+ end
49+
50+ css('dl.method > dt[id], dl.classmethod > dt[id], dl.staticmethod > dt[id]').each do |node|
51+ name = node['id'].split('.')[-2..-1].join('.') + '()'
52+ id = node['id']
53+ type = node['id'].split('.')[0..-3].join('.')
54+ entries << [name, id, type]
55+ end
56+ entries
57+ end
58+
59+ end
60+ end
61+end
lib/docs/scrapers/flask.rb+40−0
@@ -0,0 +1,40 @@
1+module Docs
2+ class Flask < UrlScraper
3+ self.type = 'sphinx'
4+ self.root_path = 'index.html'
5+ self.links = {
6+ home: 'https://palletsprojects.com/p/flask/',
7+ code: 'https://github.com/pallets/flask'
8+ }
9+
10+ html_filters.push 'flask/entries', 'sphinx/clean_html'
11+
12+ options[:container] = '.body > .section'
13+ options[:skip] = %w(extensiondev/ styleguide/ upgrading/ changelog/ license/ contributing/)
14+ options[:skip_patterns] = [/\Atutorial\//]
15+
16+ options[:attribution] = <<-HTML
17+ &copy; 2007&ndash;2020 Pallets<br>
18+ Licensed under the BSD 3-clause License.
19+ HTML
20+
21+ version '1.1' do
22+ self.release = '1.1.x'
23+ self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
24+ end
25+
26+ version '1.0' do
27+ self.release = '1.0.x'
28+ self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
29+ end
30+
31+ version '0.12' do
32+ self.release = '0.12.x'
33+ self.base_url = "https://flask.palletsprojects.com/en/#{self.release}/"
34+ end
35+
36+ def get_latest_version(opts)
37+ get_latest_github_release('pallets', 'flask', opts)
38+ end
39+ end
40+end
lib/docs/scrapers/jinja.rb+39−0
@@ -0,0 +1,39 @@
1+module Docs
2+ class Jinja < UrlScraper
3+ self.type = 'sphinx'
4+ self.root_path = 'index.html'
5+ self.links = {
6+ home: 'https://palletsprojects.com/p/jinja/',
7+ code: 'https://github.com/pallets/jinja'
8+ }
9+
10+ html_filters.push 'jinja/entries', 'sphinx/clean_html'
11+
12+ options[:container] = '.body > .section'
13+ options[:skip] = %w(integration/ switching/ faq/ changelog/ search/ genindex/)
14+
15+ options[:attribution] = <<-HTML
16+ &copy; 2007&ndash;2020 Pallets<br>
17+ Licensed under the BSD 3-clause License.
18+ HTML
19+
20+ version '2.11' do
21+ self.release = '2.11.x'
22+ self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
23+ end
24+
25+ version '2.10' do
26+ self.release = '2.10.x'
27+ self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
28+ end
29+
30+ version '2.9' do
31+ self.release = '2.9.x'
32+ self.base_url = "https://jinja.palletsprojects.com/en/#{self.release}/"
33+ end
34+
35+ def get_latest_version(opts)
36+ get_latest_github_release('pallets', 'jinja', opts)
37+ end
38+ end
39+end
lib/docs/scrapers/werkzeug.rb+39−0
@@ -0,0 +1,39 @@
1+module Docs
2+ class Werkzeug < UrlScraper
3+ self.type = 'sphinx'
4+ self.root_path = 'index.html'
5+ self.links = {
6+ home: 'https://palletsprojects.com/p/werkzeug/',
7+ code: 'https://github.com/pallets/werkzeug'
8+ }
9+
10+ html_filters.push 'werkzeug/entries', 'sphinx/clean_html'
11+
12+ options[:container] = '.body > .section'
13+ options[:skip] = %w(changes/)
14+
15+ options[:attribution] = <<-HTML
16+ &copy; 2007&ndash;2020 Pallets<br>
17+ Licensed under the BSD 3-clause License.
18+ HTML
19+
20+ version '1.0' do
21+ self.release = '1.0.x'
22+ self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
23+ end
24+
25+ version '0.16' do
26+ self.release = '0.16.x'
27+ self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
28+ end
29+
30+ version '0.15' do
31+ self.release = '0.15.x'
32+ self.base_url = "https://werkzeug.palletsprojects.com/en/#{self.release}/"
33+ end
34+
35+ def get_latest_version(opts)
36+ get_latest_github_release('pallets', 'werkzeug', opts)
37+ end
38+ end
39+end
public/icons/docs/flask/16.png+0−0

Binary file not shown.

public/icons/docs/flask/16@2x.png+0−0

Binary file not shown.

public/icons/docs/flask/SOURCE+1−0
@@ -0,0 +1 @@
1+https://flask.palletsprojects.com/en/1.1.x/_static/flask-icon.png
public/icons/docs/jinja/16.png+0−0

Binary file not shown.

public/icons/docs/jinja/16@2x.png+0−0

Binary file not shown.

public/icons/docs/jinja/SOURCE+1−0
@@ -0,0 +1 @@
1+https://jinja.palletsprojects.com/en/2.11.x/_static/jinja-logo-sidebar.png
public/icons/docs/werkzeug/16.png+0−0

Binary file not shown.

public/icons/docs/werkzeug/16@2x.png+0−0

Binary file not shown.

public/icons/docs/werkzeug/SOURCE+1−0
@@ -0,0 +1 @@
1+https://werkzeug.palletsprojects.com/en/1.0.x/_static/favicon.ico