Add FastAPI (0.85.0) documentation

This commit is contained in:
Tim Lim 2022-10-06 21:56:31 +08:00
parent 77d7e2ea77
commit fcbdddc741
10 changed files with 155 additions and 0 deletions

View file

@ -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',
'20052009 Axel Liljencrantz, 20092022 fish-shell contributors',

View file

@ -58,6 +58,7 @@
'pages/ember',
'pages/erlang',
'pages/express',
'pages/fastapi',
'pages/git',
'pages/github',
'pages/gnuplot',

View 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);
}
}

View 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

View 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

View 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

View 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
&copy; 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1 @@
https://fastapi.tiangolo.com/img/favicon.png