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 CleanHtmlFilter < Filter
def call
# css('header').remove
# css('aside').remove
css('footer').remove
css('h1 a, h2 a').remove
doc

@ -26,15 +26,26 @@ module Docs
def additional_entries
entries = []
type = ""
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 name != "Command Reference"
if "#{self.base_url}" == "https://www.nushell.sh/book/" && !self.root_page?
active_items = css("a.sidebar-item.active")
if active_items.length > 0
type = active_items[0].text.strip()
name = active_items[-1].text.strip()
id = "_"
entries << [name, id, type]
end
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]
end
end

@ -3,8 +3,12 @@ module Docs
class Nushell
class FixLinksFilter < Filter
def call
css('header').remove
css('aside').remove
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
doc
end

@ -14,7 +14,7 @@ module Docs
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[:title] = "Nushell"
options[:attribution] = <<-HTML
@ -26,7 +26,7 @@ module Docs
version do
self.release = "0.84.0"
self.base_urls = [
# "https://www.nushell.sh/book/",
"https://www.nushell.sh/book/",
"https://www.nushell.sh/commands/"
]
end

Loading…
Cancel
Save