swagr 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Rakefile +20 -0
  2. data/bin/swagr +37 -9
  3. data/examples/examples01/app.rb +5 -1
  4. data/examples/examples01/views/edit.slim +31 -0
  5. data/examples/examples01/views/footer.slim +1 -1
  6. data/examples/examples01/views/layout.slim +23 -5
  7. data/examples/examples01/views/navbar.slim +17 -16
  8. data/lib/swagr/version.rb +3 -1
  9. data/templates/app.rb +5 -1
  10. data/templates/static/js/codemirror/keymap/vim.js +279 -66
  11. data/templates/static/js/codemirror/lib/codemirror.css +10 -9
  12. data/templates/static/js/codemirror/lib/codemirror.js +385 -152
  13. data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
  14. data/templates/static/js/codemirror/mode/apl/index.html +61 -0
  15. data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
  16. data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
  17. data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
  18. data/templates/static/js/codemirror/mode/clike/index.html +1 -1
  19. data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
  20. data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
  21. data/templates/static/js/codemirror/mode/css/css.js +2 -2
  22. data/templates/static/js/codemirror/mode/css/test.js +76 -471
  23. data/templates/static/js/codemirror/mode/d/d.js +205 -0
  24. data/templates/static/js/codemirror/mode/d/index.html +262 -0
  25. data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
  26. data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
  27. data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
  28. data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
  29. data/templates/static/js/codemirror/mode/go/index.html +1 -1
  30. data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
  31. data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
  32. data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
  33. data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
  34. data/templates/static/js/codemirror/mode/less/index.html +1 -1
  35. data/templates/static/js/codemirror/mode/lua/index.html +1 -1
  36. data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
  37. data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
  38. data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
  39. data/templates/static/js/codemirror/mode/meta.js +71 -0
  40. data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
  41. data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
  42. data/templates/static/js/codemirror/mode/php/index.html +1 -1
  43. data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
  44. data/templates/static/js/codemirror/mode/python/index.html +1 -1
  45. data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
  46. data/templates/static/js/codemirror/mode/sass/index.html +54 -0
  47. data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
  48. data/templates/static/js/codemirror/mode/shell/index.html +1 -1
  49. data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
  50. data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
  51. data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
  52. data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
  53. data/templates/static/js/codemirror/mode/sql/index.html +68 -0
  54. data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
  55. data/templates/static/js/codemirror/mode/stex/test.js +104 -343
  56. data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
  57. data/templates/static/js/codemirror/mode/vb/index.html +1 -1
  58. data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
  59. data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
  60. data/templates/static/js/crossfilter.min.js +1 -0
  61. data/templates/views/edit.slim +31 -0
  62. data/templates/views/footer.slim +1 -1
  63. data/templates/views/layout.slim +23 -5
  64. data/templates/views/navbar.slim +17 -16
  65. metadata +16 -30
  66. data/examples/examples01/static/css/codemirror.css +0 -1247
  67. data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
  68. data/examples/examples01/views/about.slim +0 -15
  69. data/examples/examples01/views/application.slim +0 -0
  70. data/examples/examples01/views/layout_cm.slim +0 -17
  71. data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
  72. data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
  73. data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
  74. data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
  75. data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
  76. data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
  77. data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
  78. data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
  79. data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
  80. data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
  81. data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
  82. data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
  83. data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
  84. data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
  85. data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
  86. data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
  87. data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
  88. data/templates/static/js/codemirror/lib/util/search.js +0 -119
  89. data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
  90. data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
  91. data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
  92. data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
  93. data/templates/views/about.slim +0 -15
@@ -0,0 +1,205 @@
1
+ CodeMirror.defineMode("d", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
4
+ keywords = parserConfig.keywords || {},
5
+ builtin = parserConfig.builtin || {},
6
+ blockKeywords = parserConfig.blockKeywords || {},
7
+ atoms = parserConfig.atoms || {},
8
+ hooks = parserConfig.hooks || {},
9
+ multiLineStrings = parserConfig.multiLineStrings;
10
+ var isOperatorChar = /[+\-*&%=<>!?|\/]/;
11
+
12
+ var curPunc;
13
+
14
+ function tokenBase(stream, state) {
15
+ var ch = stream.next();
16
+ if (hooks[ch]) {
17
+ var result = hooks[ch](stream, state);
18
+ if (result !== false) return result;
19
+ }
20
+ if (ch == '"' || ch == "'" || ch == "`") {
21
+ state.tokenize = tokenString(ch);
22
+ return state.tokenize(stream, state);
23
+ }
24
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
25
+ curPunc = ch;
26
+ return null;
27
+ }
28
+ if (/\d/.test(ch)) {
29
+ stream.eatWhile(/[\w\.]/);
30
+ return "number";
31
+ }
32
+ if (ch == "/") {
33
+ if (stream.eat("+")) {
34
+ state.tokenize = tokenComment;
35
+ return tokenNestedComment(stream, state);
36
+ }
37
+ if (stream.eat("*")) {
38
+ state.tokenize = tokenComment;
39
+ return tokenComment(stream, state);
40
+ }
41
+ if (stream.eat("/")) {
42
+ stream.skipToEnd();
43
+ return "comment";
44
+ }
45
+ }
46
+ if (isOperatorChar.test(ch)) {
47
+ stream.eatWhile(isOperatorChar);
48
+ return "operator";
49
+ }
50
+ stream.eatWhile(/[\w\$_]/);
51
+ var cur = stream.current();
52
+ if (keywords.propertyIsEnumerable(cur)) {
53
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
54
+ return "keyword";
55
+ }
56
+ if (builtin.propertyIsEnumerable(cur)) {
57
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
58
+ return "builtin";
59
+ }
60
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
61
+ return "variable";
62
+ }
63
+
64
+ function tokenString(quote) {
65
+ return function(stream, state) {
66
+ var escaped = false, next, end = false;
67
+ while ((next = stream.next()) != null) {
68
+ if (next == quote && !escaped) {end = true; break;}
69
+ escaped = !escaped && next == "\\";
70
+ }
71
+ if (end || !(escaped || multiLineStrings))
72
+ state.tokenize = null;
73
+ return "string";
74
+ };
75
+ }
76
+
77
+ function tokenComment(stream, state) {
78
+ var maybeEnd = false, ch;
79
+ while (ch = stream.next()) {
80
+ if (ch == "/" && maybeEnd) {
81
+ state.tokenize = null;
82
+ break;
83
+ }
84
+ maybeEnd = (ch == "*");
85
+ }
86
+ return "comment";
87
+ }
88
+
89
+ function tokenNestedComment(stream, state) {
90
+ var maybeEnd = false, ch;
91
+ while (ch = stream.next()) {
92
+ if (ch == "/" && maybeEnd) {
93
+ state.tokenize = null;
94
+ break;
95
+ }
96
+ maybeEnd = (ch == "+");
97
+ }
98
+ return "comment";
99
+ }
100
+
101
+ function Context(indented, column, type, align, prev) {
102
+ this.indented = indented;
103
+ this.column = column;
104
+ this.type = type;
105
+ this.align = align;
106
+ this.prev = prev;
107
+ }
108
+ function pushContext(state, col, type) {
109
+ var indent = state.indented;
110
+ if (state.context && state.context.type == "statement")
111
+ indent = state.context.indented;
112
+ return state.context = new Context(indent, col, type, null, state.context);
113
+ }
114
+ function popContext(state) {
115
+ var t = state.context.type;
116
+ if (t == ")" || t == "]" || t == "}")
117
+ state.indented = state.context.indented;
118
+ return state.context = state.context.prev;
119
+ }
120
+
121
+ // Interface
122
+
123
+ return {
124
+ startState: function(basecolumn) {
125
+ return {
126
+ tokenize: null,
127
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
128
+ indented: 0,
129
+ startOfLine: true
130
+ };
131
+ },
132
+
133
+ token: function(stream, state) {
134
+ var ctx = state.context;
135
+ if (stream.sol()) {
136
+ if (ctx.align == null) ctx.align = false;
137
+ state.indented = stream.indentation();
138
+ state.startOfLine = true;
139
+ }
140
+ if (stream.eatSpace()) return null;
141
+ curPunc = null;
142
+ var style = (state.tokenize || tokenBase)(stream, state);
143
+ if (style == "comment" || style == "meta") return style;
144
+ if (ctx.align == null) ctx.align = true;
145
+
146
+ if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
147
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
148
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
149
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
150
+ else if (curPunc == "}") {
151
+ while (ctx.type == "statement") ctx = popContext(state);
152
+ if (ctx.type == "}") ctx = popContext(state);
153
+ while (ctx.type == "statement") ctx = popContext(state);
154
+ }
155
+ else if (curPunc == ctx.type) popContext(state);
156
+ else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
157
+ pushContext(state, stream.column(), "statement");
158
+ state.startOfLine = false;
159
+ return style;
160
+ },
161
+
162
+ indent: function(state, textAfter) {
163
+ if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
164
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
165
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
166
+ var closing = firstChar == ctx.type;
167
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
168
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
169
+ else return ctx.indented + (closing ? 0 : indentUnit);
170
+ },
171
+
172
+ electricChars: "{}"
173
+ };
174
+ });
175
+
176
+ (function() {
177
+ function words(str) {
178
+ var obj = {}, words = str.split(" ");
179
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
180
+ return obj;
181
+ }
182
+
183
+ var blockKeywords = "body catch class do else enum for foreach foreach_reverse if in interface mixin " +
184
+ "out scope struct switch try union unittest version while with";
185
+
186
+ CodeMirror.defineMIME("text/x-d", {
187
+ name: "d",
188
+ keywords: words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue " +
189
+ "debug default delegate delete deprecated export extern final finally function goto immutable " +
190
+ "import inout invariant is lazy macro module new nothrow override package pragma private " +
191
+ "protected public pure ref return shared short static super synchronized template this " +
192
+ "throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters " +
193
+ blockKeywords),
194
+ blockKeywords: words(blockKeywords),
195
+ builtin: words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte " +
196
+ "ucent uint ulong ushort wchar wstring void size_t sizediff_t"),
197
+ atoms: words("exit failure success true false null"),
198
+ hooks: {
199
+ "@": function(stream, _state) {
200
+ stream.eatWhile(/[\w\$_]/);
201
+ return "meta";
202
+ }
203
+ }
204
+ });
205
+ }());
@@ -0,0 +1,262 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: D mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <script src="../../lib/codemirror.js"></script>
8
+ <script src="../../addon/edit/matchbrackets.js"></script>
9
+ <script src="d.js"></script>
10
+ <link rel="stylesheet" href="../../doc/docs.css">
11
+ <style>.CodeMirror {border: 2px inset #dee;}</style>
12
+ </head>
13
+ <body>
14
+ <h1>CodeMirror: D mode</h1>
15
+
16
+ <form><textarea id="code" name="code">
17
+ /* D demo code // copied from phobos/sd/metastrings.d */
18
+ // Written in the D programming language.
19
+
20
+ /**
21
+ Templates with which to do compile-time manipulation of strings.
22
+
23
+ Macros:
24
+ WIKI = Phobos/StdMetastrings
25
+
26
+ Copyright: Copyright Digital Mars 2007 - 2009.
27
+ License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
28
+ Authors: $(WEB digitalmars.com, Walter Bright),
29
+ Don Clugston
30
+ Source: $(PHOBOSSRC std/_metastrings.d)
31
+ */
32
+ /*
33
+ Copyright Digital Mars 2007 - 2009.
34
+ Distributed under the Boost Software License, Version 1.0.
35
+ (See accompanying file LICENSE_1_0.txt or copy at
36
+ http://www.boost.org/LICENSE_1_0.txt)
37
+ */
38
+ module std.metastrings;
39
+
40
+ /**
41
+ Formats constants into a string at compile time. Analogous to $(XREF
42
+ string,format).
43
+
44
+ Parameters:
45
+
46
+ A = tuple of constants, which can be strings, characters, or integral
47
+ values.
48
+
49
+ Formats:
50
+ * The formats supported are %s for strings, and %%
51
+ * for the % character.
52
+ Example:
53
+ ---
54
+ import std.metastrings;
55
+ import std.stdio;
56
+
57
+ void main()
58
+ {
59
+ string s = Format!("Arg %s = %s", "foo", 27);
60
+ writefln(s); // "Arg foo = 27"
61
+ }
62
+ * ---
63
+ */
64
+
65
+ template Format(A...)
66
+ {
67
+ static if (A.length == 0)
68
+ enum Format = "";
69
+ else static if (is(typeof(A[0]) : const(char)[]))
70
+ enum Format = FormatString!(A[0], A[1..$]);
71
+ else
72
+ enum Format = toStringNow!(A[0]) ~ Format!(A[1..$]);
73
+ }
74
+
75
+ template FormatString(const(char)[] F, A...)
76
+ {
77
+ static if (F.length == 0)
78
+ enum FormatString = Format!(A);
79
+ else static if (F.length == 1)
80
+ enum FormatString = F[0] ~ Format!(A);
81
+ else static if (F[0..2] == "%s")
82
+ enum FormatString
83
+ = toStringNow!(A[0]) ~ FormatString!(F[2..$],A[1..$]);
84
+ else static if (F[0..2] == "%%")
85
+ enum FormatString = "%" ~ FormatString!(F[2..$],A);
86
+ else
87
+ {
88
+ static assert(F[0] != '%', "unrecognized format %" ~ F[1]);
89
+ enum FormatString = F[0] ~ FormatString!(F[1..$],A);
90
+ }
91
+ }
92
+
93
+ unittest
94
+ {
95
+ auto s = Format!("hel%slo", "world", -138, 'c', true);
96
+ assert(s == "helworldlo-138ctrue", "[" ~ s ~ "]");
97
+ }
98
+
99
+ /**
100
+ * Convert constant argument to a string.
101
+ */
102
+
103
+ template toStringNow(ulong v)
104
+ {
105
+ static if (v < 10)
106
+ enum toStringNow = "" ~ cast(char)(v + '0');
107
+ else
108
+ enum toStringNow = toStringNow!(v / 10) ~ toStringNow!(v % 10);
109
+ }
110
+
111
+ unittest
112
+ {
113
+ static assert(toStringNow!(1uL << 62) == "4611686018427387904");
114
+ }
115
+
116
+ /// ditto
117
+ template toStringNow(long v)
118
+ {
119
+ static if (v < 0)
120
+ enum toStringNow = "-" ~ toStringNow!(cast(ulong) -v);
121
+ else
122
+ enum toStringNow = toStringNow!(cast(ulong) v);
123
+ }
124
+
125
+ unittest
126
+ {
127
+ static assert(toStringNow!(0x100000000) == "4294967296");
128
+ static assert(toStringNow!(-138L) == "-138");
129
+ }
130
+
131
+ /// ditto
132
+ template toStringNow(uint U)
133
+ {
134
+ enum toStringNow = toStringNow!(cast(ulong)U);
135
+ }
136
+
137
+ /// ditto
138
+ template toStringNow(int I)
139
+ {
140
+ enum toStringNow = toStringNow!(cast(long)I);
141
+ }
142
+
143
+ /// ditto
144
+ template toStringNow(bool B)
145
+ {
146
+ enum toStringNow = B ? "true" : "false";
147
+ }
148
+
149
+ /// ditto
150
+ template toStringNow(string S)
151
+ {
152
+ enum toStringNow = S;
153
+ }
154
+
155
+ /// ditto
156
+ template toStringNow(char C)
157
+ {
158
+ enum toStringNow = "" ~ C;
159
+ }
160
+
161
+
162
+ /********
163
+ * Parse unsigned integer literal from the start of string s.
164
+ * returns:
165
+ * .value = the integer literal as a string,
166
+ * .rest = the string following the integer literal
167
+ * Otherwise:
168
+ * .value = null,
169
+ * .rest = s
170
+ */
171
+
172
+ template parseUinteger(const(char)[] s)
173
+ {
174
+ static if (s.length == 0)
175
+ {
176
+ enum value = "";
177
+ enum rest = "";
178
+ }
179
+ else static if (s[0] >= '0' && s[0] <= '9')
180
+ {
181
+ enum value = s[0] ~ parseUinteger!(s[1..$]).value;
182
+ enum rest = parseUinteger!(s[1..$]).rest;
183
+ }
184
+ else
185
+ {
186
+ enum value = "";
187
+ enum rest = s;
188
+ }
189
+ }
190
+
191
+ /********
192
+ Parse integer literal optionally preceded by $(D '-') from the start
193
+ of string $(D s).
194
+
195
+ Returns:
196
+ .value = the integer literal as a string,
197
+ .rest = the string following the integer literal
198
+
199
+ Otherwise:
200
+ .value = null,
201
+ .rest = s
202
+ */
203
+
204
+ template parseInteger(const(char)[] s)
205
+ {
206
+ static if (s.length == 0)
207
+ {
208
+ enum value = "";
209
+ enum rest = "";
210
+ }
211
+ else static if (s[0] >= '0' && s[0] <= '9')
212
+ {
213
+ enum value = s[0] ~ parseUinteger!(s[1..$]).value;
214
+ enum rest = parseUinteger!(s[1..$]).rest;
215
+ }
216
+ else static if (s.length >= 2 &&
217
+ s[0] == '-' && s[1] >= '0' && s[1] <= '9')
218
+ {
219
+ enum value = s[0..2] ~ parseUinteger!(s[2..$]).value;
220
+ enum rest = parseUinteger!(s[2..$]).rest;
221
+ }
222
+ else
223
+ {
224
+ enum value = "";
225
+ enum rest = s;
226
+ }
227
+ }
228
+
229
+ unittest
230
+ {
231
+ assert(parseUinteger!("1234abc").value == "1234");
232
+ assert(parseUinteger!("1234abc").rest == "abc");
233
+ assert(parseInteger!("-1234abc").value == "-1234");
234
+ assert(parseInteger!("-1234abc").rest == "abc");
235
+ }
236
+
237
+ /**
238
+ Deprecated aliases held for backward compatibility.
239
+ */
240
+ deprecated alias toStringNow ToString;
241
+ /// Ditto
242
+ deprecated alias parseUinteger ParseUinteger;
243
+ /// Ditto
244
+ deprecated alias parseUinteger ParseInteger;
245
+
246
+ </textarea></form>
247
+
248
+ <script>
249
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
250
+ lineNumbers: true,
251
+ matchBrackets: true,
252
+ indentUnit: 4,
253
+ mode: "text/x-d"
254
+ });
255
+ </script>
256
+
257
+ <p>Simple mode that handle D-Syntax (<a href="http://www.dlang.org">DLang Homepage</a>).</p>
258
+
259
+ <p><strong>MIME types defined:</strong> <code>text/x-d</code>
260
+ .</p>
261
+ </body>
262
+ </html>