History

fix tables to work everywhere, add comments

Romeo Van Snick committed 12 years ago

Commit de0e3ab1 parent 219772f3 files · +115 −37Browse files

Unified · Split

3 files
  1. assets/stylesheets/pages/_haskell.scss +54 −5
  2. lib/docs/filters/haskell/clean_html.rb +60 −19
  3. lib/docs/filters/haskell/entries.rb +1 −13
assets/stylesheets/pages/_haskell.scss+54−5
@@ -4,12 +4,36 @@ · 3 unmodified lines
4 background-repeat: no-repeat;4 background-repeat: no-repeat;
5}5}
6 6
7.empty-table .empty {
8 display: none;
9}
10
11.arguments td.src {
12 background: #faf9e2;
13 width: 30%;
14}
15
16th.src,
7td.src {17td.src {
8 font-family: $monoFont;18 font-family: $monoFont;
9 font-weight: normal;19 font-weight: normal;
10 font-style: normal;20 font-style: normal;
11 background: #f8f8f8;21 background: #f8f8f8;
12 width: 20%;22}
23
24caption {
25 font-weight: bold;
26 text-align: left;
27 font-style: italic;
28 font-size: 1.1em;
29}
30
31// remove margin in descript listing
32dd > pre {
33 @extend %pre;
34 margin: 0;
35 background: #faf9e2;
36 border-color: #dddaaa #dddaaa #d7d7a9;
13}37}
14 38
15// warnings are red39// warnings are red
@@ -44,18 +68,43 @@ td.src { · 28 unmodified lines
44 order: 1;68 order: 1;
45}69}
46 70
71// add box type to "since: ..."
47.added {72.added {
48 @extend %note;73 @extend %note;
49 @extend %note-gold;74 @extend %note-gold;
50}75}
51 76
52.top {77.added-cell {
53 margin-bottom: 3em;78 @extend %note-gold;
79}
80
81.fields h3 {
82 display: none;
83}
84
85// separate types more
86.src {
87 margin-top: 2.5em;
88}
89
90h1 + .top .src,
91h2 + .top .src,
92h3 + .top .src,
93.caption + .top .src {
94 margin-top: 0;
95}
96
97// but not for first type
98h1 + .top,
99h2 + .top,
100h3 + .top,
101h4 + .top {
102 margin-top: 0;
54}103}
55 104
105// change color of example code
56.example {106.example {
57 -webkit-flex: none;
58 background: #faf9e2;
59 border: 1px solid;107 border: 1px solid;
108 background: #faf9e2;
60 border-color: #dddaaa #dddaaa #d7d7a9;109 border-color: #dddaaa #dddaaa #d7d7a9;
61}110}
lib/docs/filters/haskell/clean_html.rb+60−19
@@ -4,11 +4,7 @@ module Docs · 3 unmodified lines
4 def call4 def call
5 5
6 # remove unwanted elements6 # remove unwanted elements
7 css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.show .empty', '.package').remove7 css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.package').remove
8
9 css('pre').each do |node|
10 node.add_css_class('example')
11 end
12 8
13 # cpations in tables are h39 # cpations in tables are h3
14 css('table .caption').each do |node|10 css('table .caption').each do |node|
@@ -20,6 +16,7 @@ module Docs · 5 unmodified lines
20 node.name = 'h1'16 node.name = 'h1'
21 end17 end
22 18
19 # section
23 css('.top > .caption').each do |node|20 css('.top > .caption').each do |node|
24 node.name = 'h2'21 node.name = 'h2'
25 end22 end
@@ -34,39 +31,79 @@ module Docs · 8 unmodified lines
34 node.name = 'h4'31 node.name = 'h4'
35 end32 end
36 33
34 # ...
37 css('.top > .subs > .subs > .subs > .caption').each do |node|35 css('.top > .subs > .subs > .subs > .caption').each do |node|
38 node.name = 'h5'36 node.name = 'h5'
39 end37 end
40 38
39 # ......
41 css('.top > .subs > .subs > .subs > .subs > .caption').each do |node|40 css('.top > .subs > .subs > .subs > .subs > .caption').each do |node|
42 node.name = 'h6'41 node.name = 'h6'
43 end42 end
44 43
44 # all pre's are examples
45 css('pre').each do |node|
46 node.add_css_class('example')
47 end
48
45 # turn source listing in to pre49 # turn source listing in to pre
46 css('.src').each do |node|50 css('.src').each do |node|
47 if node.name == "td"51 if node.name != "td"
48 # pre = doc.create_element 'pre'
49 # pre.children = node.children
50 # node.children = [pre]
51 else
52 node.name = 'pre'52 node.name = 'pre'
53 end53 end
54 end54 end
55 55
56 if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries'56 # check if second column of table is totally empty.
57 css('h1').remove57 # and remove it if it is
58 css('table').each do |table|
59 empty = true
60 table.css('td + td').each do |snd|
61 empty = empty && snd['class'] =~ /empty/
62 end
63 if empty
64 # remove empty column
65 table.css('td + td').remove
66 end
58 end67 end
59 68
69 # move table captions into the tables
70 css(".caption + table").each do |table|
71 caption = table.previous
72 caption.name = "caption"
73 caption.parent = table
74 end
75
76 css(".caption + .show table").each do |table|
77 caption = table.parent.parent.css('.caption')[0]
78 caption.name = 'caption'
79 caption.parent = table
80 end
81
82 # better arguments display:
83 css('.src + .arguments table').each do |table|
84 src = table.parent.previous # the function name
85 row = doc.document.create_element('tr')
86 table.css('tr')[0].before(row)
87 src.parent = row
88 src.name = "th"
89 src['colspan'] = 2
90 end
91
92 # remove root page title
93 if root_page?
94 at_css('h1').remove
95 end
96
97 # add id to links (based on name)
60 css('a').each do |node|98 css('a').each do |node|
61 if node['name']99 if node['name']
62 node['id'] = node['name']100 node['id'] = node['name']
63 end101 end
64 end102 end
65 103
66 css('.caption').each do |node|104 # make code in description into proper pre
67 if node.content == 'Arguments'105 css('dd > code').each do |node|
68 node.remove106 node.name = 'pre'
69 end
70 end107 end
71 108
72 # add some informational boxes109 # add some informational boxes
@@ -86,8 +123,8 @@ module Docs · 13 unmodified lines
86 # </p>123 # </p>
87 if node.previous == nil124 if node.previous == nil
88 node.add_css_class('complexity') # add css class125 node.add_css_class('complexity') # add css class
89 node.name="span" # just make it div126 node.name="span" # just make it div
90 node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em127 node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em
91 node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em128 node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em
92 129
93 # reparent the nodes130 # reparent the nodes
@@ -100,7 +137,11 @@ module Docs · 6 unmodified lines
100 end137 end
101 elsif node.content =~ /Since: .*/138 elsif node.content =~ /Since: .*/
102 # add box to 'Since:' annotations139 # add box to 'Since:' annotations
103 node.add_css_class('added')140 if node.parent.parent.name == "td"
141 node.parent.parent.add_css_class('added-cell')
142 else
143 node.add_css_class('added')
144 end
104 end145 end
105 end146 end
106 147
lib/docs/filters/haskell/entries.rb+1−13
@@ -10,6 +10,7 @@ module Docs · 9 unmodified lines
10 # Array > [Array, nil]10 # Array > [Array, nil]
11 def get_name_and_type11 def get_name_and_type
12 if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries'12 if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries'
13 puts 'ok'
13 name = 'Haskell'14 name = 'Haskell'
14 type = nil15 type = nil
15 else16 else
@@ -50,19 +51,6 @@ module Docs · 34 unmodified lines
50 n, t = get_name_and_type()51 n, t = get_name_and_type()
51 t52 t
52 end53 end
53
54 # def additional_entries
55 # css('a').inject [] do |entries, node|
56 # name = node.content
57 # id = node['name']
58 # if id
59 # puts id
60 # entries << [name, id, nil]
61 # end
62 # entries
63 # end
64 # end
65
66 end54 end
67 end55 end
68end56end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t