History

switched to the simple styling option

Chaitanya Rahalkar committed 1 year ago

Commit 15fcdc21 parent 58d3d7d2 files · +6 −66Browse files

Unified · Split

2 files
  1. lib/docs/filters/threejs/clean_html.rb +5 −65
  2. lib/docs/scrapers/threejs.rb +1 −1
lib/docs/filters/threejs/clean_html.rb+5−65
@@ -4,71 +4,7 @@ module Docs · 3 unmodified lines
4 def call4 def call
5 # Remove unnecessary elements5 # Remove unnecessary elements
6 css('head, script, style').remove6 css('head, script, style').remove
7 7
8 # Add syntax highlighting CSS
9 style = doc.document.create_element('style')
10 style.content = <<-CSS
11 .highlight { background: #272b30; color: #e9ecef; border-radius: 4px; margin: 1em 0; }
12 .highlight pre { margin: 0; padding: 10px; }
13 .highlight .k { color: #cc7832; font-weight: bold; } /* Keyword */
14 .highlight .kd { color: #cc7832; font-weight: bold; } /* Keyword.Declaration */
15 .highlight .nb { color: #6897bb; } /* Name.Builtin */
16 .highlight .nx { color: #ffc66d; } /* Name.Other */
17 .highlight .nf { color: #ffc66d; } /* Name.Function */
18 .highlight .mi { color: #6897bb; } /* Literal.Number.Integer */
19 .highlight .s1 { color: #6a8759; } /* Literal.String.Single */
20 .highlight .s2 { color: #6a8759; } /* Literal.String.Double */
21 .highlight .c1 { color: #808080; font-style: italic; } /* Comment.Single */
22 .highlight .lineno { color: #606366; margin-right: 10px; -webkit-user-select: none; user-select: none; }
23 .highlight-javascript { padding: 0; }
24
25 /* Method signatures */
26 .sig { padding: 5px 10px; }
27 .sig-name { color: #ffc66d; }
28 .sig-param { color: #e9ecef; }
29 .sig-param .sig-type { color: #6897bb; }
30 .sig-returns { color: #cc7832; }
31 .sig-returns .sig-type { color: #6897bb; }
32 .sig-paren { color: #e9ecef; }
33 .property .pre { color: #cc7832; }
34
35 /* Inline code */
36 code.literal { background: #2b2b2b; padding: 2px 4px; border-radius: 3px; }
37 code.literal .pre { color: #e9ecef; }
38
39 /* Links */
40 .reference { color: #6897bb; text-decoration: none; }
41 .reference:hover { text-decoration: underline; }
42 .reference.external { color: #6a8759; }
43
44 /* Notes */
45 .admonition.note { background: #2b2b2b; padding: 12px 15px; border-left: 4px solid #6897bb; margin: 1em 0; }
46 .admonition-title { color: #6897bb; font-weight: bold; margin: 0 0 5px 0; }
47 CSS
48 doc.at_css('head') ? doc.at_css('head').add_child(style) : doc.add_child(style)
49
50 # Create a wrapper div for better styling
51 if root = at_css('body')
52 content = root.inner_html
53 else
54 content = doc.inner_html
55 end
56
57 # Create Django-like structure
58 content = <<-HTML
59 <div class="document">
60 <div class="documentwrapper">
61 <div class="bodywrapper">
62 <div class="body" role="main">
63 #{content}
64 </div>
65 </div>
66 </div>
67 </div>
68 HTML
69
70 doc.inner_html = content
71
72 # Handle source links8 # Handle source links
73 css('h2').each do |node|9 css('h2').each do |node|
74 if node.content.strip == 'Source'10 if node.content.strip == 'Source'
@@ -319,6 +255,10 @@ module Docs · 244 unmodified lines
319 end255 end
320 end256 end
321 257
258 # Remove the navigation arrows and links
259 css('.nav').remove if at_css('.nav')
260 # If the arrows are in a different container, adjust the selector accordingly
261
322 doc262 doc
323 end263 end
324 264
lib/docs/scrapers/threejs.rb+1−1
@@ -1,7 +1,7 @@
1module Docs1module Docs
2 class Threejs < FileScraper2 class Threejs < FileScraper
3 self.name = 'Three.js'3 self.name = 'Three.js'
4 self.type = 'threejs'4 self.type = 'simple'
5 self.slug = 'threejs'5 self.slug = 'threejs'
6 self.links = {6 self.links = {
7 home: 'https://threejs.org/',7 home: 'https://threejs.org/',