History

Add FastAPI (0.85.0) documentation

Tim Lim committed 4 years ago

Commit fcbdddc1 parent 77d7e2e10 files · +153 −-2Browse files

Unified · Split

10 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. assets/stylesheets/application.css.scss +1 −0
  3. assets/stylesheets/pages/_fastapi.scss +22 −0
  4. lib/docs/filters/fastapi/clean_html.rb +32 −0
  5. lib/docs/filters/fastapi/container.rb +9 −0
  6. lib/docs/filters/fastapi/entries.rb +55 −0
  7. lib/docs/scrapers/fastapi.rb +30 −0
  8. public/icons/docs/fastapi/16.png +0 −0
  9. public/icons/docs/fastapi/16@2x.png +0 −0
  10. public/icons/docs/fastapi/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -326,6 +326,11 @@ credits = [ · 325 unmodified lines
326 '2019 by Falcon contributors',326 '2019 by Falcon contributors',
327 'Apache',327 'Apache',
328 'https://raw.githubusercontent.com/falconry/falcon/master/LICENSE'328 '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'
329 ], [334 ], [
330 'Fish',335 'Fish',
331 '2005–2009 Axel Liljencrantz, 2009–2022 fish-shell contributors',336 '2005–2009 Axel Liljencrantz, 2009–2022 fish-shell contributors',
assets/stylesheets/application.css.scss+1−0
@@ -58,6 +58,7 @@ · 57 unmodified lines
58 'pages/ember',58 'pages/ember',
59 'pages/erlang',59 'pages/erlang',
60 'pages/express',60 'pages/express',
61 'pages/fastapi',
61 'pages/git',62 'pages/git',
62 'pages/github',63 'pages/github',
63 'pages/gnuplot',64 '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+32−0
@@ -0,0 +1,32 @@
1module Docs
2 class Fastapi
3 class CleanHtmlFilter < Filter
4
5 def call
6 doc.css('.headerlink').each do |node|
7 node.remove
8 end
9
10 doc.css('.tabbed-set').each do |node|
11 labels = node.css('.tabbed-labels label')
12 blocks = node.css('.tabbed-content .tabbed-block')
13
14 blocks.each_with_index do |block_node, i|
15 block_node.prepend_child(labels[i]) if labels[i]
16 end
17
18 node.css('> input, .tabbed-labels').remove
19 end
20
21 doc.css('pre').each do |node|
22 node['class'] = "language-python"
23 node['data-language'] = "python"
24 node.content = node.at_css('code').content
25 end
26
27 doc
28 end
29
30 end
31 end
32end
lib/docs/filters/fastapi/container.rb+9−0
@@ -0,0 +1,9 @@
1module 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
9end
lib/docs/filters/fastapi/entries.rb+55−0
@@ -0,0 +1,55 @@
1module 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_name_other
18 header = at_css('h1')
19 if header
20 header.content
21 else
22 path_parts.last.titleize
23 end
24 end
25
26 def get_type
27 if path_parts.length <= 1
28 data = at_css('h1').content
29 else
30 data = path_parts[0...path_parts.length-1].join(": ").titleize + ": " + at_css('h1').content
31 end
32
33 data
34 end
35
36 def path_count
37 path_parts.length
38 end
39
40 def additional_entries
41 entries = []
42 type = get_type
43
44 css('h2').each do |node|
45 name = node.content
46 id = path + "#" + node['id']
47 entries << [name, id, type]
48 end
49
50 entries
51 end
52
53 end
54 end
55end
lib/docs/scrapers/fastapi.rb+30−0
@@ -0,0 +1,30 @@
1module 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; This project is licensed under the terms of the MIT license.
23 HTML
24
25 def get_latest_version(opts)
26 get_latest_github_release('tiangolo', 'fastapi', opts)
27 end
28
29 end
30end
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 @@
1https://fastapi.tiangolo.com/img/favicon.png