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
44 background-repeat: no-repeat;
55 }
66
7+.empty-table .empty {
8+ display: none;
9+}
10+
11+.arguments td.src {
12+ background: #faf9e2;
13+ width: 30%;
14+}
15+
16+th.src,
717 td.src {
818 font-family: $monoFont;
919 font-weight: normal;
1020 font-style: normal;
1121 background: #f8f8f8;
12− width: 20%;
22+}
23+
24+caption {
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
32+dd > pre {
33+ @extend %pre;
34+ margin: 0;
35+ background: #faf9e2;
36+ border-color: #dddaaa #dddaaa #d7d7a9;
1337 }
1438
1539 // warnings are red
@@ -44,18 +68,43 @@ td.src { · 28 unmodified lines
4468 order: 1;
4569 }
4670
71+// add box type to "since: ..."
4772 .added {
4873 @extend %note;
4974 @extend %note-gold;
5075 }
5176
52−.top {
53− margin-bottom: 3em;
77+.added-cell {
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+
90+h1 + .top .src,
91+h2 + .top .src,
92+h3 + .top .src,
93+.caption + .top .src {
94+ margin-top: 0;
95+}
96+
97+// but not for first type
98+h1 + .top,
99+h2 + .top,
100+h3 + .top,
101+h4 + .top {
102+ margin-top: 0;
54103 }
55104
105+// change color of example code
56106 .example {
57− -webkit-flex: none;
58− background: #faf9e2;
59107 border: 1px solid;
108+ background: #faf9e2;
60109 border-color: #dddaaa #dddaaa #d7d7a9;
61110 }
lib/docs/filters/haskell/clean_html.rb+60−19
@@ -4,11 +4,7 @@ module Docs · 3 unmodified lines
44 def call
55
66 # remove unwanted elements
7− css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.show .empty', '.package').remove
8−
9− css('pre').each do |node|
10− node.add_css_class('example')
11− end
7+ css('#footer', '#package-header', '#module-header', '#synopsis', '.link', '#table-of-contents', '.package').remove
128
139 # cpations in tables are h3
1410 css('table .caption').each do |node|
@@ -20,6 +16,7 @@ module Docs · 5 unmodified lines
2016 node.name = 'h1'
2117 end
2218
19+ # section
2320 css('.top > .caption').each do |node|
2421 node.name = 'h2'
2522 end
@@ -34,39 +31,79 @@ module Docs · 8 unmodified lines
3431 node.name = 'h4'
3532 end
3633
34+ # ...
3735 css('.top > .subs > .subs > .subs > .caption').each do |node|
3836 node.name = 'h5'
3937 end
4038
39+ # ......
4140 css('.top > .subs > .subs > .subs > .subs > .caption').each do |node|
4241 node.name = 'h6'
4342 end
4443
44+ # all pre's are examples
45+ css('pre').each do |node|
46+ node.add_css_class('example')
47+ end
48+
4549 # turn source listing in to pre
4650 css('.src').each do |node|
47− if node.name == "td"
48− # pre = doc.create_element 'pre'
49− # pre.children = node.children
50− # node.children = [pre]
51− else
51+ if node.name != "td"
5252 node.name = 'pre'
5353 end
5454 end
5555
56− if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries'
57− css('h1').remove
56+ # check if second column of table is totally empty.
57+ # 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
5867 end
5968
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)
6098 css('a').each do |node|
6199 if node['name']
62100 node['id'] = node['name']
63101 end
64102 end
65103
66− css('.caption').each do |node|
67− if node.content == 'Arguments'
68− node.remove
69− end
104+ # make code in description into proper pre
105+ css('dd > code').each do |node|
106+ node.name = 'pre'
70107 end
71108
72109 # add some informational boxes
@@ -86,8 +123,8 @@ module Docs · 13 unmodified lines
86123 # </p>
87124 if node.previous == nil
88125 node.add_css_class('complexity') # add css class
89− node.name="span" # just make it div
90− node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em
126+ node.name="span" # just make it div
127+ node.next.content = node.next.content.gsub(/^. /, "") # remove . if directly after em
91128 node.content = node.content.gsub(/\.$/, "") # remove trailing . if it's inside em
92129
93130 # reparent the nodes
@@ -100,7 +137,11 @@ module Docs · 6 unmodified lines
100137 end
101138 elsif node.content =~ /Since: .*/
102139 # 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
104145 end
105146 end
106147
lib/docs/filters/haskell/entries.rb+1−13
@@ -10,6 +10,7 @@ module Docs · 9 unmodified lines
1010 # Array > [Array, nil]
1111 def get_name_and_type
1212 if at_css('h1') && at_css('h1').content == 'Haskell Hierarchical Libraries'
13+ puts 'ok'
1314 name = 'Haskell'
1415 type = nil
1516 else
@@ -50,19 +51,6 @@ module Docs · 34 unmodified lines
5051 n, t = get_name_and_type()
5152 t
5253 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−
6654 end
6755 end
6856 end

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