mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-09-29 05:36:48 +02:00
Add FastAPI (0.85.0) documentation
This commit is contained in:
parent
77d7e2ea77
commit
fcbdddc741
10 changed files with 155 additions and 0 deletions
|
@ -326,6 +326,11 @@ credits = [
|
|||
'2019 by Falcon contributors',
|
||||
'Apache',
|
||||
'https://raw.githubusercontent.com/falconry/falcon/master/LICENSE'
|
||||
], [
|
||||
'FastAPI',
|
||||
'2018 Sebastián Ramírez',
|
||||
'MIT',
|
||||
'https://github.com/tiangolo/fastapi/blob/master/LICENSE'
|
||||
], [
|
||||
'Fish',
|
||||
'2005–2009 Axel Liljencrantz, 2009–2022 fish-shell contributors',
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
'pages/ember',
|
||||
'pages/erlang',
|
||||
'pages/express',
|
||||
'pages/fastapi',
|
||||
'pages/git',
|
||||
'pages/github',
|
||||
'pages/gnuplot',
|
||||
|
|
22
assets/stylesheets/pages/_fastapi.scss
Normal file
22
assets/stylesheets/pages/_fastapi.scss
Normal file
|
@ -0,0 +1,22 @@
|
|||
._fastapi {
|
||||
> h2 { @extend %block-heading; }
|
||||
> h3 { @extend %block-label, %label-blue; }
|
||||
|
||||
code { @extend %label; }
|
||||
|
||||
.tabbed-block {
|
||||
border: 1px dashed black;
|
||||
padding: 0.5rem 1rem 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.tabbed-block label {
|
||||
font-weight: var(--bolderFontWeight);
|
||||
}
|
||||
|
||||
.admonition { @extend %note; }
|
||||
.admonition.tip { @extend %note-green; }
|
||||
.admonition.note { @extend %note-blue; }
|
||||
.admonition-title {
|
||||
font-weight: var(--bolderFontWeight);
|
||||
}
|
||||
}
|
32
lib/docs/filters/fastapi/clean_html.rb
Normal file
32
lib/docs/filters/fastapi/clean_html.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Docs
|
||||
class Fastapi
|
||||
class CleanHtmlFilter < Filter
|
||||
|
||||
def call
|
||||
doc.css('.headerlink').each do |node|
|
||||
node.remove
|
||||
end
|
||||
|
||||
doc.css('.tabbed-set').each do |node|
|
||||
labels = node.css('.tabbed-labels label')
|
||||
blocks = node.css('.tabbed-content .tabbed-block')
|
||||
|
||||
blocks.each_with_index do |block_node, i|
|
||||
block_node.prepend_child(labels[i]) if labels[i]
|
||||
end
|
||||
|
||||
node.css('> input, .tabbed-labels').remove
|
||||
end
|
||||
|
||||
doc.css('pre').each do |node|
|
||||
node['class'] = "language-python"
|
||||
node['data-language'] = "python"
|
||||
node.content = node.at_css('code').content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
9
lib/docs/filters/fastapi/container.rb
Normal file
9
lib/docs/filters/fastapi/container.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Docs
|
||||
class Fastapi
|
||||
class ContainerFilter < Filter
|
||||
def call
|
||||
at_css '.md-content > .md-content__inner'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
55
lib/docs/filters/fastapi/entries.rb
Normal file
55
lib/docs/filters/fastapi/entries.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
module Docs
|
||||
class Fastapi
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def sanitized_path
|
||||
path.gsub(/index$/, "")
|
||||
end
|
||||
|
||||
def path_parts
|
||||
sanitized_path.split("/")
|
||||
end
|
||||
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_name_other
|
||||
header = at_css('h1')
|
||||
if header
|
||||
header.content
|
||||
else
|
||||
path_parts.last.titleize
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
if path_parts.length <= 1
|
||||
data = at_css('h1').content
|
||||
else
|
||||
data = path_parts[0...path_parts.length-1].join(": ").titleize + ": " + at_css('h1').content
|
||||
end
|
||||
|
||||
data
|
||||
end
|
||||
|
||||
def path_count
|
||||
path_parts.length
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
type = get_type
|
||||
|
||||
css('h2').each do |node|
|
||||
name = node.content
|
||||
id = path + "#" + node['id']
|
||||
entries << [name, id, type]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
30
lib/docs/scrapers/fastapi.rb
Normal file
30
lib/docs/scrapers/fastapi.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Docs
|
||||
class Fastapi < UrlScraper
|
||||
self.name = 'Fastapi'
|
||||
self.type = 'fastapi'
|
||||
self.release = '0.85.0'
|
||||
self.base_url = 'https://fastapi.tiangolo.com/'
|
||||
self.root_path = '/'
|
||||
self.links = {
|
||||
home: 'https://fastapi.tiangolo.com/',
|
||||
code: 'https://github.com/tiangolo/fastapi'
|
||||
}
|
||||
|
||||
options[:only_patterns] = [
|
||||
/\Afeatures\//, /\Apython-types\//,
|
||||
/\Atutorial\//, /\Aadvanced\//, /\Aasync\//,
|
||||
/\Adeployment\//, /\Aproject-generation\//
|
||||
]
|
||||
|
||||
html_filters.push 'fastapi/container', 'fastapi/clean_html', 'fastapi/entries'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© This project is licensed under the terms of the MIT license.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_latest_github_release('tiangolo', 'fastapi', opts)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
BIN
public/icons/docs/fastapi/16.png
Normal file
BIN
public/icons/docs/fastapi/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
public/icons/docs/fastapi/16@2x.png
Normal file
BIN
public/icons/docs/fastapi/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
1
public/icons/docs/fastapi/SOURCE
Normal file
1
public/icons/docs/fastapi/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://fastapi.tiangolo.com/img/favicon.png
|
Loading…
Reference in a new issue