mirror of https://github.com/freeCodeCamp/devdocs
commit
08fc2200b3
@ -0,0 +1,58 @@
|
||||
module Docs
|
||||
class Click
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
TYPE_BY_SLUG = {}
|
||||
|
||||
def call
|
||||
if root_page?
|
||||
css('section').each do |node|
|
||||
next if ['documentation', 'api-reference'].include?(node['id'])
|
||||
type = node.at_css('h2').content.strip
|
||||
node.css('li > a').each do |toclink|
|
||||
slug = toclink['href'].split('/')[-2]
|
||||
TYPE_BY_SLUG[slug] = type
|
||||
end
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def get_name
|
||||
return at_css('h1').content.strip
|
||||
end
|
||||
|
||||
def get_type
|
||||
TYPE_BY_SLUG[slug.split('/').first] || at_css('h1').content.strip
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
TYPE_BY_SLUG.include?(slug.split('/').first)
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] if root_page? || TYPE_BY_SLUG.include?(slug.split('/').first)
|
||||
|
||||
if slug == 'api/'
|
||||
entries = []
|
||||
doc.css('> section').each do |section|
|
||||
title = section.at_css('h2').content.strip
|
||||
section.css('dl.py > dt[id]').each do |dt|
|
||||
name = dt['id'].split('.')[1..].join('.')
|
||||
name << '()' if dt.parent.classes.intersect?(['function', 'method', 'classmethod', 'staticmethod'])
|
||||
entries << [name, dt['id'], title]
|
||||
end
|
||||
end
|
||||
return entries
|
||||
end
|
||||
|
||||
(doc.css('> section') || []).map do |section|
|
||||
title = section.at_css('h2').content.strip
|
||||
[title, section['id']]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
module Docs
|
||||
class Click
|
||||
class PreCleanHtmlFilter < Filter
|
||||
def call
|
||||
# Remove ¶ character from headers
|
||||
css('.headerlink').remove
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
module Docs
|
||||
class Nextjs
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('.prose')
|
||||
|
||||
css('.zola-anchor').remove
|
||||
doc.prepend_child("<h1>NextJS2</h1>") if root_page?
|
||||
css('div:contains("NEWS:")').remove
|
||||
css('h2:contains("sponsors"), #sponsor-table').remove
|
||||
css('div.sticky').remove #remove the floating menu
|
||||
css('div.-mt-4').remove #remove the navigation line
|
||||
css('footer').remove
|
||||
css('div.feedback_inlineTriggerWrapper__o7yUx').remove
|
||||
css('header').remove #remove links from the top of the page
|
||||
css('nav').remove
|
||||
|
||||
css('h1, h2, h3, h4').each { |node| node.content = node.content }
|
||||
|
||||
css('pre > code').each do |node|
|
||||
node.parent['data-language'] = 'typescript'
|
||||
node.parent.content = node.parent.content
|
||||
end
|
||||
css('div[class^="code-block_header"]').remove
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,43 @@
|
||||
module Docs
|
||||
class Nextjs
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
name.strip!
|
||||
#name
|
||||
subpath_items = subpath.split('/', -1)
|
||||
if subpath_items.length >= 5
|
||||
subpath_items[3].capitalize + ': ' + name # e.g. Routing: Defining Routes
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
if slug.start_with?('architecture')
|
||||
'Architecture'
|
||||
elsif slug.start_with?('community')
|
||||
'Community'
|
||||
elsif slug.start_with?('getting-started')
|
||||
'Getting Started'
|
||||
elsif slug.start_with?('messages')
|
||||
'Messages'
|
||||
elsif slug.start_with?('app/building-your-application')
|
||||
'Using App Router: Building your application'
|
||||
elsif slug.start_with?('app/api-reference')
|
||||
'Using App Router: api-reference'
|
||||
elsif slug.start_with?('app')
|
||||
'Using App Router'
|
||||
elsif slug.start_with?('pages/building-your-application')
|
||||
'Using Pages Router: Building your application'
|
||||
elsif slug.start_with?('pages/api-reference')
|
||||
'Using Pages Router: api-reference'
|
||||
elsif slug.start_with?('pages')
|
||||
'Using Pages Router'
|
||||
else
|
||||
get_name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
module Docs
|
||||
class Click < UrlScraper
|
||||
self.name = 'click'
|
||||
self.type = 'sphinx'
|
||||
self.root_path = 'index.html'
|
||||
self.links = {
|
||||
home: 'https://click.palletsprojects.com/',
|
||||
code: 'https://github.com/pallets/click'
|
||||
}
|
||||
|
||||
html_filters.push 'click/pre_clean_html', 'click/entries', 'sphinx/clean_html'
|
||||
|
||||
options[:container] = '.body > section'
|
||||
options[:skip] = ['changes/', 'genindex/', 'py-modindex/']
|
||||
options[:title] = false
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Copyright 2014 Pallets.<br>
|
||||
Licensed under the BSD 3-Clause License.<br>
|
||||
We are not supported nor endorsed by Pallets.
|
||||
HTML
|
||||
|
||||
self.release = '8.1.x'
|
||||
self.base_url = "https://click.palletsprojects.com/en/#{self.release}/"
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_latest_github_release('pallets', 'click', opts)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
module Docs
|
||||
class Nextjs < UrlScraper
|
||||
self.name = 'Next.js'
|
||||
self.slug = 'nextjs'
|
||||
self.type = 'simple'
|
||||
self.release = '14.2.4'
|
||||
self.base_url = 'https://nextjs.org/docs'
|
||||
self.initial_paths = %w(reference/)
|
||||
self.links = {
|
||||
home: 'https://www.nextjs.org/',
|
||||
code: 'https://github.com/vercel/next.js'
|
||||
}
|
||||
|
||||
html_filters.push 'nextjs/entries', 'nextjs/clean_html'
|
||||
options[:download_images] = false
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2024 Vercel, Inc.<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_npm_version('next', opts)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "devdocs",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
After Width: | Height: | Size: 641 B |
After Width: | Height: | Size: 797 B |
@ -0,0 +1 @@
|
||||
https://github.com/pallets/click/blob/main/docs/_static/click-icon.png
|
After Width: | Height: | Size: 537 B |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,2 @@
|
||||
https://assets.vercel.com/image/upload/v1662130559/nextjs/Icon_dark_background.png
|
||||
https://github.com/vercel/next.js/blob/canary/examples/cms-enterspeed/public/favicon/favicon.ico
|
Loading…
Reference in new issue