[devdocsgjs/main: 1037/1867] Improve React docs
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 1037/1867] Improve React docs
- Date: Fri, 19 Nov 2021 23:47:40 +0000 (UTC)
commit 038869aa675511c4f0625bd4e45ed59f8af2973f
Author: Jed Fox <git twopointzero us>
Date: Wed Jan 29 20:19:14 2020 -0500
Improve React docs
lib/docs/filters/react/clean_html.rb | 7 ++++++-
lib/docs/filters/react/entries.rb | 22 +++++++++++++++++-----
2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/lib/docs/filters/react/clean_html.rb b/lib/docs/filters/react/clean_html.rb
index 274bc550..ec40dbe0 100644
--- a/lib/docs/filters/react/clean_html.rb
+++ b/lib/docs/filters/react/clean_html.rb
@@ -8,7 +8,7 @@ module Docs
at_css('h1').content = 'React Documentation'
end
- css('header', 'div[class^="css-"]', '.gatsby-resp-image-link span').each do |node|
+ css('header', 'div[class^="css-"]', '.gatsby-resp-image-link span', 'div.scary').each do |node|
node.before(node.children).remove
end
@@ -24,6 +24,11 @@ module Docs
css('a').remove_attr('rel').remove_attr('target').remove_attr('class').remove_attr('style')
css('img').remove_attr('style').remove_attr('srcset').remove_attr('sizes').remove_attr('class')
+ css('[class*="css-"]').each do |node|
+ node['class'] = node['class'].sub(/css-[^ ]+(\b|$)/, '')
+ node.delete 'class' if node['class'] == ''
+ end
+
doc
end
end
diff --git a/lib/docs/filters/react/entries.rb b/lib/docs/filters/react/entries.rb
index 975f171b..d2c54826 100644
--- a/lib/docs/filters/react/entries.rb
+++ b/lib/docs/filters/react/entries.rb
@@ -2,22 +2,30 @@ module Docs
class React
class EntriesFilter < Docs::EntriesFilter
def get_name
- at_css('article h1').content
+ at_css('article h1').content.sub(' (Experimental)', '')
end
def get_type
+ return 'API Reference' if slug == 'legacy-context'
+ return 'Glossary' if slug == 'glossary'
link = css("nav a[href='#{result[:path].split('/').last}']").last
return 'Miscellaneous' unless link
type = link.ancestors('ul').last.previous_element.content
type.remove! %r{\s*\(.*\)}
- type
+ if type == 'Concurrent Mode'
+ type + ' (Experimental)' # TODO: Remove when CM is stable
+ else
+ type
+ end
end
def additional_entries
entries = []
- css('article h3 code, article h4 code').each do |node|
- next if node.previous.try(:content).present?
+ is_glossary = slug == 'glossary'
+ css(is_glossary ? 'article h2, article h3' : 'article h3 code, article h4 code').each do |node|
+ next if !is_glossary && node.previous.try(:content).present?
+ next if slug == 'testing-recipes'
name = node.content.strip
# name.remove! %r{[#\(\)]}
# name.remove! %r{\w+\:}
@@ -29,10 +37,14 @@ module Docs
'Reference: React'
elsif slug == 'hooks-reference'
'Hooks'
+ elsif slug == 'test-utils'
+ 'Reference: Test Utilities'
+ elsif slug == 'glossary'
+ 'Glossary'
else
'Reference'
end
- entries << [name, node.parent['id'], type]
+ entries << [name, node['id'] || node.ancestors('[id]').first['id'], type]
end
entries
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]