api_guides 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module ApiGuides
4
+ # This class models a <reference> element in a document.
5
+ # It will always be shown with the associated section.
6
+ # All references will be combined into an index.
7
+ #
8
+ # References can also be linked to using standard
9
+ # markdown syntax with some sugar provided by this
10
+ # library.
11
+ #
12
+ # Each reference has a title. The title is used for linking
13
+ # and descirbing each reference. You should markdown
14
+ # inside each reference to fill in your content
15
+ class Reference
16
+ attr_accessor :title, :content
17
+
18
+ def initialize(attributes = {})
19
+ attributes.each_pair do |attr, value|
20
+ send "#{attr}=", value
21
+ end
22
+ end
23
+
24
+ # Takes an XML representation and parse
25
+ # it into a Reference instance.
26
+ #
27
+ # Here is XML format expected:
28
+ #
29
+ # <reference title="Foo">
30
+ # <![CDATA[
31
+ # Insert your markdown here
32
+ # ]]>
33
+ # </reference>
34
+ #
35
+ # This would set `#title` to 'Foo'
36
+ # and #content to 'Insert your markdown here'
37
+ def self.from_xml(xml)
38
+ doc = Nokogiri::XML.parse(xml).at_xpath('//reference')
39
+ Reference.new :title => doc.attributes['title'].try(:value), :content => doc.content
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,258 @@
1
+ body {
2
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
3
+ font-size: 15px;
4
+ line-height: 22px;
5
+ color: #252519;
6
+ margin: 0; padding: 0;
7
+ }
8
+ a {
9
+ color: #0069D6;
10
+ text-decoration: none;
11
+ }
12
+ a:visited {
13
+ color: #0069D6;
14
+ }
15
+ p {
16
+ margin: 0 0 15px 0;
17
+ }
18
+ h1, h2, h3, h4, h5, h6 {
19
+ margin: 0px 0 15px 0;
20
+ }
21
+ #container {
22
+ position: relative;
23
+ }
24
+ #background {
25
+ position: fixed;
26
+ top: 0; left: 525px; right: 0; bottom: 0;
27
+ background: #f5f5ff;
28
+ border-left: 1px solid #e5e5ee;
29
+ z-index: -1;
30
+ }
31
+ #jump_to, #jump_page {
32
+ background: white;
33
+ -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
34
+ -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
35
+ font: 10px Arial;
36
+ text-transform: uppercase;
37
+ cursor: pointer;
38
+ text-align: right;
39
+ }
40
+ #jump_to, #jump_wrapper {
41
+ position: fixed;
42
+ right: 0; top: 0;
43
+ padding: 5px 10px;
44
+ }
45
+ #jump_wrapper {
46
+ padding: 0;
47
+ display: none;
48
+ }
49
+ #jump_to:hover #jump_wrapper {
50
+ display: block;
51
+ }
52
+ #jump_page {
53
+ padding: 5px 0 3px;
54
+ margin: 0 0 25px 25px;
55
+ }
56
+ #jump_page .source {
57
+ display: block;
58
+ padding: 5px 10px;
59
+ text-decoration: none;
60
+ border-top: 1px solid #eee;
61
+ }
62
+ #jump_page .source:hover {
63
+ background: #f5f5ff;
64
+ }
65
+ #jump_page .source:first-child {
66
+ }
67
+ table td {
68
+ border: 0;
69
+ outline: 0;
70
+ }
71
+ td.docs, th.docs {
72
+ max-width: 450px;
73
+ min-width: 450px;
74
+ min-height: 5px;
75
+ padding: 10px 25px 1px 50px;
76
+ overflow-x: hidden;
77
+ vertical-align: top;
78
+ text-align: left;
79
+ }
80
+ .docs pre {
81
+ margin: 15px 0 15px;
82
+ padding-left: 15px;
83
+ }
84
+ .docs p tt, .docs p code, .docs li code, .docs dd code {
85
+ background: #f8f8ff;
86
+ border: 1px solid #dedede;
87
+ font-size: 12px;
88
+ padding: 0 0.2em;
89
+ }
90
+ .pilwrap {
91
+ position: relative;
92
+ }
93
+ .pilcrow {
94
+ font: 12px Arial;
95
+ text-decoration: none;
96
+ color: #454545;
97
+ position: absolute;
98
+ top: 3px; left: -20px;
99
+ padding: 1px 2px;
100
+ opacity: 0;
101
+ -webkit-transition: opacity 0.2s linear;
102
+ }
103
+ td.docs:hover .pilcrow {
104
+ opacity: 1;
105
+ }
106
+ td.code, th.code {
107
+ padding: 14px 15px 16px 25px;
108
+ width: 100%;
109
+ vertical-align: top;
110
+ background: #f5f5ff;
111
+ border-left: 1px solid #e5e5ee;
112
+ }
113
+ pre, tt, code {
114
+ font-size: 12px; line-height: 18px;
115
+ font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
116
+ margin: 10px 0;
117
+ padding: 0;
118
+ }
119
+
120
+ td.code pre,
121
+ td.code tt,
122
+ td.code code,
123
+ th.code pre,
124
+ th.code tt,
125
+ th.code code {
126
+ font-size: 14px;
127
+ }
128
+
129
+
130
+ body {
131
+ padding-top: 50px;
132
+ }
133
+
134
+ #logo {
135
+ float: right;
136
+ position: relative;
137
+ top: 7px;
138
+ }
139
+
140
+ td.docs dl {
141
+ overflow: auto;
142
+ }
143
+
144
+ td.docs dt {
145
+ clear: both;
146
+ width: 35%;
147
+ float: left;
148
+ text-align: right;
149
+ font-weight: bold;
150
+ margin-top: 8px;
151
+ }
152
+
153
+ td.docs dd {
154
+ float: left;
155
+ width: 60%;
156
+ padding-left: 8px;
157
+ margin-left: 0;
158
+ margin-top: 8px;
159
+ }
160
+
161
+ #topbar a.brand {
162
+ float: left;
163
+ display: block;
164
+ padding: 8px 20px 12px;
165
+ margin-left: -20px;
166
+ color: white;
167
+ font-size: 20px;
168
+ font-weight: 200;
169
+ line-height: 1;
170
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
171
+ }
172
+
173
+ #topbar .nav {
174
+ display: block;
175
+ float: left;
176
+ margin: 0 10px 0 0;
177
+ position: relative;
178
+ left: 0;
179
+ list-style: none
180
+ }
181
+
182
+ #topbar .nav > li > a {
183
+ display: block;
184
+ float: none;
185
+ padding: 10px 10px 11px;
186
+ line-height: 19px;
187
+ text-decoration: none;
188
+ color: #BFBFBF;
189
+ font-size: 13px;
190
+ text-decoration: none;
191
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
192
+ }
193
+
194
+ #topbar .nav > li > a:hover,
195
+ #topbar a.brand:hover {
196
+ background-color: rgba(255, 255, 255, 0.05);
197
+ color: white;
198
+ text-decoration: none;
199
+ }
200
+
201
+ #toc:hover #table-of-contents {
202
+ display: block;
203
+ }
204
+
205
+ #table-of-contents {
206
+ display: none;
207
+ width: 960px;
208
+ margin-left: 50px;
209
+ border-left: 1px solid #BBB;
210
+ border-right: 1px solid #BBB;
211
+ border-bottom: 1px solid #BBB;
212
+ background-color: white;
213
+ overflow: auto;
214
+ position: absolute;
215
+ top: 40px;
216
+ padding: 20px 0;
217
+ z-index: 100;
218
+ }
219
+
220
+ #table-of-contents section {
221
+ width: 280px;
222
+ float: left;
223
+ margin-left: 20px;
224
+ }
225
+
226
+ #table-of-contents .sub-section a,
227
+ #table-of-contents .sub-section a:visited {
228
+ color: inherit;
229
+ }
230
+
231
+ #table-of-contents .header {
232
+ font-weight: bold;
233
+ font-size: 17px;
234
+ text-transform: uppercase;
235
+ }
236
+
237
+ #topbar {
238
+ height: 40px;
239
+ position: fixed;
240
+ top: 0;
241
+ left: 0;
242
+ right: 0;
243
+ z-index: 10000;
244
+ background-color: #222;
245
+ background-repeat: repeat-x;
246
+ background-image: -khtml-gradient(linear, left top, left bottom, from(#333333), to(#222222));
247
+ background-image: -moz-linear-gradient(top, #333333, #222222);
248
+ background-image: -ms-linear-gradient(top, #333333, #222222);
249
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #222222));
250
+ background-image: -webkit-linear-gradient(top, #333333, #222222);
251
+ background-image: -o-linear-gradient(top, #333333, #222222);
252
+ background-image: linear-gradient(top, #333333, #222222);
253
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
254
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
255
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
256
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
257
+ padding-left: 50px;
258
+ }
@@ -0,0 +1,64 @@
1
+ /*---------------------- Syntax Highlighting -----------------------------*/
2
+ td.linenos { background-color: #f0f0f0; padding-right: 10px; }
3
+ span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
4
+ body .hll { background-color: #ffffcc }
5
+ body .c { color: #408080; font-style: italic } /* Comment */
6
+ body .err { border: 1px solid #FF0000 } /* Error */
7
+ body .k { color: #954121 } /* Keyword */
8
+ body .o { color: #666666 } /* Operator */
9
+ body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
10
+ body .cp { color: #BC7A00 } /* Comment.Preproc */
11
+ body .c1 { color: #408080; font-style: italic } /* Comment.Single */
12
+ body .cs { color: #408080; font-style: italic } /* Comment.Special */
13
+ body .gd { color: #A00000 } /* Generic.Deleted */
14
+ body .ge { font-style: italic } /* Generic.Emph */
15
+ body .gr { color: #FF0000 } /* Generic.Error */
16
+ body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
17
+ body .gi { color: #00A000 } /* Generic.Inserted */
18
+ body .go { color: #808080 } /* Generic.Output */
19
+ body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
20
+ body .gs { font-weight: bold } /* Generic.Strong */
21
+ body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
22
+ body .gt { color: #0040D0 } /* Generic.Traceback */
23
+ body .kc { color: #954121 } /* Keyword.Constant */
24
+ body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
25
+ body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
26
+ body .kp { color: #954121 } /* Keyword.Pseudo */
27
+ body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
28
+ body .kt { color: #B00040 } /* Keyword.Type */
29
+ body .m { color: #666666 } /* Literal.Number */
30
+ body .s { color: #219161 } /* Literal.String */
31
+ body .na { color: #7D9029 } /* Name.Attribute */
32
+ body .nb { color: #954121 } /* Name.Builtin */
33
+ body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
34
+ body .no { color: #880000 } /* Name.Constant */
35
+ body .nd { color: #AA22FF } /* Name.Decorator */
36
+ body .ni { color: #999999; font-weight: bold } /* Name.Entity */
37
+ body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
38
+ body .nf { color: #0000FF } /* Name.Function */
39
+ body .nl { color: #A0A000 } /* Name.Label */
40
+ body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
41
+ body .nt { color: #954121; font-weight: bold } /* Name.Tag */
42
+ body .nv { color: #19469D } /* Name.Variable */
43
+ body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
44
+ body .w { color: #bbbbbb } /* Text.Whitespace */
45
+ body .mf { color: #666666 } /* Literal.Number.Float */
46
+ body .mh { color: #666666 } /* Literal.Number.Hex */
47
+ body .mi { color: #666666 } /* Literal.Number.Integer */
48
+ body .mo { color: #666666 } /* Literal.Number.Oct */
49
+ body .sb { color: #219161 } /* Literal.String.Backtick */
50
+ body .sc { color: #219161 } /* Literal.String.Char */
51
+ body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
52
+ body .s2 { color: #219161 } /* Literal.String.Double */
53
+ body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
54
+ body .sh { color: #219161 } /* Literal.String.Heredoc */
55
+ body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
56
+ body .sx { color: #954121 } /* Literal.String.Other */
57
+ body .sr { color: #BB6688 } /* Literal.String.Regex */
58
+ body .s1 { color: #219161 } /* Literal.String.Single */
59
+ body .ss { color: #19469D } /* Literal.String.Symbol */
60
+ body .bp { color: #954121 } /* Name.Builtin.Pseudo */
61
+ body .vc { color: #19469D } /* Name.Variable.Class */
62
+ body .vg { color: #19469D } /* Name.Variable.Global */
63
+ body .vi { color: #19469D } /* Name.Variable.Instance */
64
+ body .il { color: #666666 } /* Literal.Number.Integer.Long */
@@ -0,0 +1,65 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module ApiGuides
4
+ # This class is simply a structure to hold the docs
5
+ # and the examples.
6
+ #
7
+ # Sections require docs, but do not require
8
+ # any examples. Set examples when you want
9
+ # those on the right side of the docs.
10
+ #
11
+ # You never interact with this class directly.
12
+ class Section
13
+ attr_accessor :docs, :examples, :reference, :title
14
+
15
+ def initialize(attributes = {})
16
+ attributes.each_pair do |attr, value|
17
+ send "#{attr}=", value
18
+ end
19
+ end
20
+
21
+ # Takes an XML representation and parse
22
+ # it into a section instance.
23
+ #
24
+ # Here is XML format expected:
25
+ #
26
+ # <section title="Foo">
27
+ # <docs>
28
+ # <![CDATA[
29
+ # Insert your markdown here
30
+ # ]]>
31
+ # </docs>
32
+ # <reference title="Bar">
33
+ # <![CDATA[
34
+ # Insert your markdown here
35
+ # ]]>
36
+ # </reference>
37
+ # <examples>
38
+ # <example language="ruby">
39
+ # <![CDATA[
40
+ # Insert your markdown here>
41
+ # ]]>
42
+ # </example>
43
+ # </example>
44
+ # </section>
45
+ #
46
+ # It also loops instantiates the Reference
47
+ # and examples if they are given using their
48
+ # `from_xml` methods as well
49
+ def self.from_xml(xml)
50
+ doc = Nokogiri::XML.parse(xml).at_xpath('//section')
51
+ section = Section.new :title => doc.attributes['title'].try(:value)
52
+ section.docs = doc.at_xpath('./docs').content if doc.at_xpath('./docs')
53
+
54
+ if reference_xml = doc.at_xpath('./reference')
55
+ section.reference = Reference.from_xml(reference_xml.to_s)
56
+ end
57
+
58
+ section.examples = doc.xpath('//example').map do |example_xml|
59
+ Example.from_xml example_xml.to_s
60
+ end
61
+
62
+ section
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,80 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>{{ title }}</title>
6
+ <link rel="stylesheet" type="text/css" href="./syntax.css" />
7
+ <link rel="stylesheet" type="text/css" href="./style.css" />
8
+ </head>
9
+ <body>
10
+
11
+ <div id="topbar">
12
+ {{#logo}}
13
+ <img id="logo" src="{{ logo }}"/>
14
+ {{/logo}}
15
+
16
+ <a href="#" class="brand">{{ title }}</a>
17
+
18
+ <ul class="nav">
19
+ <li id="toc">
20
+ <a href="#">Table of Contents</a>
21
+ <div id="table-of-contents">
22
+ {{#documents}}
23
+ <section>
24
+ <a class="header" href="#{{id}}">{{title}}</a>
25
+ <ol>
26
+ {{#sections}}
27
+ {{#title}}
28
+ <li class="sub-section"><a href="#{{id}}">{{title}}</a></li>
29
+ {{/title}}
30
+ {{/sections}}
31
+ </ol>
32
+ </section>
33
+ {{/documents}}
34
+ </div>
35
+ </li>
36
+ {{#links}}
37
+ <li><a href="#{{href}}">{{name}}</a></li>
38
+ {{/links}}
39
+ </ul>
40
+ </div>
41
+
42
+
43
+ <div id="container">
44
+ <div id="background"></div>
45
+ {{#documents}}
46
+ <table cellspacing="0" cellpadding="0">
47
+ <thead>
48
+ <tr>
49
+ <th class="docs">
50
+ <h1 id="{{id}}">{{title}}</h1>
51
+ </th>
52
+ <th class="code">&nbsp;</th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ {{#sections}}
57
+ <tr>
58
+ <td class="docs">
59
+ <h2 id="{{id}}">{{title}}</h2>
60
+
61
+ {{{ docs }}}
62
+ </td>
63
+ <td class="code">
64
+ {{#reference}}
65
+ <h2 id="{{id}}">{{title}}</h2>
66
+ {{{ content }}}
67
+ {{/reference}}
68
+
69
+ {{#examples}}
70
+ {{{ content }}}
71
+ {{/examples}}
72
+ </td>
73
+ </tr>
74
+ {{/sections}}
75
+ <tbody>
76
+ </table>
77
+ {{/documents}}
78
+ </div>
79
+ </body>
80
+ </html>