diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index f34f861f..2a20f48a 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -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', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 8a6221b6..e7a725e7 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -58,6 +58,7 @@ 'pages/ember', 'pages/erlang', 'pages/express', + 'pages/fastapi', 'pages/git', 'pages/github', 'pages/gnuplot', diff --git a/assets/stylesheets/pages/_fastapi.scss b/assets/stylesheets/pages/_fastapi.scss new file mode 100644 index 00000000..5f56c1ce --- /dev/null +++ b/assets/stylesheets/pages/_fastapi.scss @@ -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); + } +} diff --git a/lib/docs/filters/fastapi/clean_html.rb b/lib/docs/filters/fastapi/clean_html.rb new file mode 100644 index 00000000..f9fc7cdb --- /dev/null +++ b/lib/docs/filters/fastapi/clean_html.rb @@ -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 diff --git a/lib/docs/filters/fastapi/container.rb b/lib/docs/filters/fastapi/container.rb new file mode 100644 index 00000000..418015c3 --- /dev/null +++ b/lib/docs/filters/fastapi/container.rb @@ -0,0 +1,9 @@ +module Docs + class Fastapi + class ContainerFilter < Filter + def call + at_css '.md-content > .md-content__inner' + end + end + end +end diff --git a/lib/docs/filters/fastapi/entries.rb b/lib/docs/filters/fastapi/entries.rb new file mode 100644 index 00000000..d2923bf8 --- /dev/null +++ b/lib/docs/filters/fastapi/entries.rb @@ -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 diff --git a/lib/docs/scrapers/fastapi.rb b/lib/docs/scrapers/fastapi.rb new file mode 100644 index 00000000..b0749776 --- /dev/null +++ b/lib/docs/scrapers/fastapi.rb @@ -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 diff --git a/public/icons/docs/fastapi/16.png b/public/icons/docs/fastapi/16.png new file mode 100644 index 00000000..34d06370 Binary files /dev/null and b/public/icons/docs/fastapi/16.png differ diff --git a/public/icons/docs/fastapi/16@2x.png b/public/icons/docs/fastapi/16@2x.png new file mode 100644 index 00000000..79505801 Binary files /dev/null and b/public/icons/docs/fastapi/16@2x.png differ diff --git a/public/icons/docs/fastapi/SOURCE b/public/icons/docs/fastapi/SOURCE new file mode 100644 index 00000000..255202ba --- /dev/null +++ b/public/icons/docs/fastapi/SOURCE @@ -0,0 +1 @@ +https://fastapi.tiangolo.com/img/favicon.png