feat(nushell): add book

pull/2050/head
Jan Christoph Ebersbach 1 year ago
parent 74c7f624b1
commit 693d051c8f
No known key found for this signature in database
GPG Key ID: 444912B0B381009F

@ -3,8 +3,6 @@ module Docs
class Nushell class Nushell
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
# css('header').remove
# css('aside').remove
css('footer').remove css('footer').remove
css('h1 a, h2 a').remove css('h1 a, h2 a').remove
doc doc

@ -26,15 +26,26 @@ module Docs
def additional_entries def additional_entries
entries = [] entries = []
type = "" type = ""
css("h1").each do |node| if "#{self.base_url}" == "https://www.nushell.sh/book/" && !self.root_page?
name = node.at_css("code") ? active_items = css("a.sidebar-item.active")
node.at_css("code").text : node.text if active_items.length > 0
type = node.children.length >= 3 ? type = active_items[0].text.strip()
node.children[2].text.sub(" for ", "").capitalize : name = active_items[-1].text.strip()
node.text id = "_"
# id = type.downcase.gsub(" ", "-") entries << [name, id, type]
id = "_" end
if name != "Command Reference" else
css("h1").each do |node|
name = node.at_css("code") ?
node.at_css("code").text : node.text
type = node.children.length >= 3 ?
node.children[2].text.sub(" for ", "").capitalize :
node.text
# id = type.downcase.gsub(" ", "-")
id = "_"
if self.root_page?
id = "#{self.base_url}".split('/')[-1]
end
entries << [name, id, type] entries << [name, id, type]
end end
end end

@ -3,8 +3,12 @@ module Docs
class Nushell class Nushell
class FixLinksFilter < Filter class FixLinksFilter < Filter
def call def call
css('header').remove
css('aside').remove
css('a').each do |node| css('a').each do |node|
node["href"] = "#{node["href"]}#_" if !(node["href"].starts_with?("https://") || node["href"].starts_with?("http://"))
node["href"] = "#{node["href"]}#_"
end
end end
doc doc
end end

@ -14,7 +14,7 @@ module Docs
html_filters.push "nushell/clean_html", "nushell/entries", "nushell/fix_links" html_filters.push "nushell/clean_html", "nushell/entries", "nushell/fix_links"
options[:container] = '.theme-default-content' options[:container] = '.theme-container'
options[:follow_links] = true options[:follow_links] = true
options[:title] = "Nushell" options[:title] = "Nushell"
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
@ -26,7 +26,7 @@ module Docs
version do version do
self.release = "0.84.0" self.release = "0.84.0"
self.base_urls = [ self.base_urls = [
# "https://www.nushell.sh/book/", "https://www.nushell.sh/book/",
"https://www.nushell.sh/commands/" "https://www.nushell.sh/commands/"
] ]
end end

Loading…
Cancel
Save