History

Merge pull request #1834 from thewheat/fastapi

Add FastAPI (0.85.0) documentation

Simon Legner committed 4 years ago

Commit 22ee6b42 parents 4c70959 add806d11 files · +145 −-2Browse files

Unified · Split

11 files
  1. assets/javascripts/news.json +4 −0
  2. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  3. assets/stylesheets/application.css.scss +1 −0
  4. assets/stylesheets/pages/_fastapi.scss +22 −0
  5. lib/docs/filters/fastapi/clean_html.rb +34 −0
  6. lib/docs/filters/fastapi/container.rb +9 −0
  7. lib/docs/filters/fastapi/entries.rb +40 −0
  8. lib/docs/scrapers/fastapi.rb +31 −0
  9. public/icons/docs/fastapi/16.png +0 −0
  10. public/icons/docs/fastapi/16@2x.png +0 −0
  11. public/icons/docs/fastapi/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2022-10-09",
4+ "New documentation: <a href=\"/fastapi/\">FastAPI</a>"
5+ ],
26 [
37 "2022-10-02",
48 "New documentation: <a href=\"/svelte/\">Svelte</a>"
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -326,6 +326,11 @@ credits = [ · 325 unmodified lines
326326 '2019 by Falcon contributors',
327327 'Apache',
328328 'https://raw.githubusercontent.com/falconry/falcon/master/LICENSE'
329+ ], [
330+ 'FastAPI',
331+ '2018 Sebastián Ramírez',
332+ 'MIT',
333+ 'https://github.com/tiangolo/fastapi/blob/master/LICENSE'
329334 ], [
330335 'Fish',
331336 '2005–2009 Axel Liljencrantz, 2009–2022 fish-shell contributors',
assets/stylesheets/application.css.scss+1−0
@@ -58,6 +58,7 @@ · 57 unmodified lines
5858 'pages/ember',
5959 'pages/erlang',
6060 'pages/express',
61+ 'pages/fastapi',
6162 'pages/git',
6263 'pages/github',
6364 'pages/gnuplot',
assets/stylesheets/pages/_fastapi.scss+22−0
@@ -0,0 +1,22 @@
1+._fastapi {
2+ > h2 { @extend %block-heading; }
3+ > h3 { @extend %block-label, %label-blue; }
4+
5+ code { @extend %label; }
6+
7+ .tabbed-block {
8+ border: 1px dashed black;
9+ padding: 0.5rem 1rem 0;
10+ margin-bottom: 1rem;
11+ }
12+ .tabbed-block label {
13+ font-weight: var(--bolderFontWeight);
14+ }
15+
16+ .admonition { @extend %note; }
17+ .admonition.tip { @extend %note-green; }
18+ .admonition.note { @extend %note-blue; }
19+ .admonition-title {
20+ font-weight: var(--bolderFontWeight);
21+ }
22+}
lib/docs/filters/fastapi/clean_html.rb+34−0
@@ -0,0 +1,34 @@
1+module Docs
2+ class Fastapi
3+ class CleanHtmlFilter < Filter
4+
5+ def call
6+ doc.css('.headerlink').remove
7+
8+ if root_page?
9+ doc.css('#sponsors ~ p', '#sponsors').remove
10+ end
11+
12+ doc.css('.tabbed-set').each do |node|
13+ labels = node.css('.tabbed-labels label')
14+ blocks = node.css('.tabbed-content .tabbed-block')
15+
16+ blocks.each_with_index do |block_node, i|
17+ block_node.prepend_child(labels[i]) if labels[i]
18+ end
19+
20+ node.css('> input, .tabbed-labels').remove
21+ end
22+
23+ doc.css('pre').each do |node|
24+ node['class'] = "language-python"
25+ node['data-language'] = "python"
26+ node.content = node.at_css('code').content
27+ end
28+
29+ doc
30+ end
31+
32+ end
33+ end
34+end
lib/docs/filters/fastapi/container.rb+9−0
@@ -0,0 +1,9 @@
1+module Docs
2+ class Fastapi
3+ class ContainerFilter < Filter
4+ def call
5+ at_css '.md-content > .md-content__inner'
6+ end
7+ end
8+ end
9+end
lib/docs/filters/fastapi/entries.rb+40−0
@@ -0,0 +1,40 @@
1+module Docs
2+ class Fastapi
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def sanitized_path
6+ path.gsub(/index$/, "")
7+ end
8+
9+ def path_parts
10+ sanitized_path.split("/")
11+ end
12+
13+ def get_name
14+ at_css('h1').content
15+ end
16+
17+ def get_type
18+ if path_parts.length <= 1
19+ at_css('h1').content
20+ else
21+ path_parts[0...-1].join(": ").titleize + ": " + at_css('h1').content
22+ end
23+ end
24+
25+ def additional_entries
26+ entries = []
27+ type = get_type
28+
29+ css('h2').each do |node|
30+ name = node.content
31+ id = path + "#" + node['id']
32+ entries << [name, id, type]
33+ end
34+
35+ entries
36+ end
37+
38+ end
39+ end
40+end
lib/docs/scrapers/fastapi.rb+31−0
@@ -0,0 +1,31 @@
1+module Docs
2+ class Fastapi < UrlScraper
3+ self.name = 'FastAPI'
4+ self.type = 'fastapi'
5+ self.release = '0.85.0'
6+ self.base_url = 'https://fastapi.tiangolo.com/'
7+ self.root_path = '/'
8+ self.links = {
9+ home: 'https://fastapi.tiangolo.com/',
10+ code: 'https://github.com/tiangolo/fastapi'
11+ }
12+
13+ options[:only_patterns] = [
14+ /\Afeatures\//, /\Apython-types\//,
15+ /\Atutorial\//, /\Aadvanced\//, /\Aasync\//,
16+ /\Adeployment\//, /\Aproject-generation\//
17+ ]
18+
19+ html_filters.push 'fastapi/container', 'fastapi/clean_html', 'fastapi/entries'
20+
21+ options[:attribution] = <<-HTML
22+ &copy; 2018 Sebastián Ramírez<br>
23+ Licensed under the MIT License.
24+ HTML
25+
26+ def get_latest_version(opts)
27+ get_latest_github_release('tiangolo', 'fastapi', opts)
28+ end
29+
30+ end
31+end
public/icons/docs/fastapi/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/fastapi/SOURCE+1−0
@@ -0,0 +1 @@
1+https://fastapi.tiangolo.com/img/favicon.png