overpass-doc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -0
  3. data/Rakefile +27 -0
  4. data/bin/overpass-doc +12 -0
  5. data/lib/overpass-doc.rb +9 -0
  6. data/lib/overpass-doc/assets/bootstrap.min.css +7 -0
  7. data/lib/overpass-doc/assets/bootstrap.min.js +7 -0
  8. data/lib/overpass-doc/assets/codemirror.css +176 -0
  9. data/lib/overpass-doc/assets/codemirror.js +3190 -0
  10. data/lib/overpass-doc/assets/jquery.js +2 -0
  11. data/lib/overpass-doc/assets/mode/clike/clike.js +303 -0
  12. data/lib/overpass-doc/assets/mode/clike/index.html +102 -0
  13. data/lib/overpass-doc/assets/mode/clike/scala.html +766 -0
  14. data/lib/overpass-doc/assets/mode/clike/test.js +165 -0
  15. data/lib/overpass-doc/assets/util/closetag.js +165 -0
  16. data/lib/overpass-doc/assets/util/continuecomment.js +36 -0
  17. data/lib/overpass-doc/assets/util/continuelist.js +29 -0
  18. data/lib/overpass-doc/assets/util/dialog.css +32 -0
  19. data/lib/overpass-doc/assets/util/dialog.js +76 -0
  20. data/lib/overpass-doc/assets/util/foldcode.js +196 -0
  21. data/lib/overpass-doc/assets/util/formatting.js +108 -0
  22. data/lib/overpass-doc/assets/util/javascript-hint.js +138 -0
  23. data/lib/overpass-doc/assets/util/loadmode.js +51 -0
  24. data/lib/overpass-doc/assets/util/match-highlighter.js +44 -0
  25. data/lib/overpass-doc/assets/util/multiplex.js +95 -0
  26. data/lib/overpass-doc/assets/util/overlay.js +59 -0
  27. data/lib/overpass-doc/assets/util/pig-hint.js +123 -0
  28. data/lib/overpass-doc/assets/util/runmode-standalone.js +90 -0
  29. data/lib/overpass-doc/assets/util/runmode.js +53 -0
  30. data/lib/overpass-doc/assets/util/search.js +118 -0
  31. data/lib/overpass-doc/assets/util/searchcursor.js +119 -0
  32. data/lib/overpass-doc/assets/util/simple-hint.css +16 -0
  33. data/lib/overpass-doc/assets/util/simple-hint.js +102 -0
  34. data/lib/overpass-doc/assets/util/xml-hint.js +131 -0
  35. data/lib/overpass-doc/generator.rb +122 -0
  36. data/lib/overpass-doc/query.rb +119 -0
  37. data/lib/overpass-doc/views/extra.erb +4 -0
  38. data/lib/overpass-doc/views/index.erb +37 -0
  39. data/lib/overpass-doc/views/layout.erb +80 -0
  40. data/lib/overpass-doc/views/query.erb +115 -0
  41. metadata +144 -0
@@ -0,0 +1,165 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: https://codemirror.net/LICENSE
3
+
4
+ (function() {
5
+ var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
6
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7
+
8
+ MT("indent",
9
+ "[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
10
+ " [type int] [variable c] [operator =] [variable b] [operator +]",
11
+ " [number 1];",
12
+ " [keyword return] [operator *][variable a];",
13
+ "}");
14
+
15
+ MT("indent_switch",
16
+ "[keyword switch] ([variable x]) {",
17
+ " [keyword case] [number 10]:",
18
+ " [keyword return] [number 20];",
19
+ " [keyword default]:",
20
+ " [variable printf]([string \"foo %c\"], [variable x]);",
21
+ "}");
22
+
23
+ MT("def",
24
+ "[type void] [def foo]() {}",
25
+ "[keyword struct] [def bar]{}",
26
+ "[keyword enum] [def zot]{}",
27
+ "[keyword union] [def ugh]{}",
28
+ "[type int] [type *][def baz]() {}");
29
+
30
+ MT("def_new_line",
31
+ "::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
32
+ "[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
33
+
34
+ MT("double_block",
35
+ "[keyword for] (;;)",
36
+ " [keyword for] (;;)",
37
+ " [variable x][operator ++];",
38
+ "[keyword return];");
39
+
40
+ MT("preprocessor",
41
+ "[meta #define FOO 3]",
42
+ "[type int] [variable foo];",
43
+ "[meta #define BAR\\]",
44
+ "[meta 4]",
45
+ "[type unsigned] [type int] [variable bar] [operator =] [number 8];",
46
+ "[meta #include <baz> ][comment // comment]")
47
+
48
+ MT("c_underscores",
49
+ "[builtin __FOO];",
50
+ "[builtin _Complex];",
51
+ "[builtin __aName];",
52
+ "[variable _aName];");
53
+
54
+ MT("c_types",
55
+ "[type int];",
56
+ "[type long];",
57
+ "[type char];",
58
+ "[type short];",
59
+ "[type double];",
60
+ "[type float];",
61
+ "[type unsigned];",
62
+ "[type signed];",
63
+ "[type void];",
64
+ "[type bool];",
65
+ "[type foo_t];",
66
+ "[variable foo_T];",
67
+ "[variable _t];");
68
+
69
+ var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
70
+ function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
71
+
72
+ MTCPP("cpp14_literal",
73
+ "[number 10'000];",
74
+ "[number 0b10'000];",
75
+ "[number 0x10'000];",
76
+ "[string '100000'];");
77
+
78
+ MTCPP("ctor_dtor",
79
+ "[def Foo::Foo]() {}",
80
+ "[def Foo::~Foo]() {}");
81
+
82
+ MTCPP("cpp_underscores",
83
+ "[builtin __FOO];",
84
+ "[builtin _Complex];",
85
+ "[builtin __aName];",
86
+ "[variable _aName];");
87
+
88
+ var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
89
+ function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
90
+
91
+ MTOBJC("objc_underscores",
92
+ "[builtin __FOO];",
93
+ "[builtin _Complex];",
94
+ "[builtin __aName];",
95
+ "[variable _aName];");
96
+
97
+ MTOBJC("objc_interface",
98
+ "[keyword @interface] [def foo] {",
99
+ " [type int] [variable bar];",
100
+ "}",
101
+ "[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
102
+ "[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
103
+ "[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
104
+ "[builtin NS_DESIGNATED_INITIALIZER];",
105
+ "[keyword @end]");
106
+
107
+ MTOBJC("objc_implementation",
108
+ "[keyword @implementation] [def foo] {",
109
+ " [type int] [variable bar];",
110
+ "}",
111
+ "[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
112
+ "[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
113
+ " [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
114
+ " [keyword return] [keyword self];",
115
+ "}",
116
+ "[keyword @end]");
117
+
118
+ MTOBJC("objc_types",
119
+ "[type int];",
120
+ "[type foo_t];",
121
+ "[variable foo_T];",
122
+ "[type id];",
123
+ "[type SEL];",
124
+ "[type instancetype];",
125
+ "[type Class];",
126
+ "[type Protocol];",
127
+ "[type BOOL];"
128
+ );
129
+
130
+ var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
131
+ function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
132
+ MTSCALA("nested_comments",
133
+ "[comment /*]",
134
+ "[comment But wait /* this is a nested comment */ for real]",
135
+ "[comment /**** let * me * show * you ****/]",
136
+ "[comment ///// let / me / show / you /////]",
137
+ "[comment */]");
138
+
139
+ var mode_java = CodeMirror.getMode({indentUnit: 2}, "text/x-java");
140
+ function MTJAVA(name) { test.mode("java_" + name, mode_java, Array.prototype.slice.call(arguments, 1)); }
141
+ MTJAVA("types",
142
+ "[type byte];",
143
+ "[type short];",
144
+ "[type int];",
145
+ "[type long];",
146
+ "[type float];",
147
+ "[type double];",
148
+ "[type boolean];",
149
+ "[type char];",
150
+ "[type void];",
151
+ "[type Boolean];",
152
+ "[type Byte];",
153
+ "[type Character];",
154
+ "[type Double];",
155
+ "[type Float];",
156
+ "[type Integer];",
157
+ "[type Long];",
158
+ "[type Number];",
159
+ "[type Object];",
160
+ "[type Short];",
161
+ "[type String];",
162
+ "[type StringBuffer];",
163
+ "[type StringBuilder];",
164
+ "[type Void];");
165
+ })();
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Tag-closer extension for CodeMirror.
3
+ *
4
+ * This extension adds a "closeTag" utility function that can be used with key bindings to
5
+ * insert a matching end tag after the ">" character of a start tag has been typed. It can
6
+ * also complete "</" if a matching start tag is found. It will correctly ignore signal
7
+ * characters for empty tags, comments, CDATA, etc.
8
+ *
9
+ * The function depends on internal parser state to identify tags. It is compatible with the
10
+ * following CodeMirror modes and will ignore all others:
11
+ * - htmlmixed
12
+ * - xml
13
+ *
14
+ * See demos/closetag.html for a usage example.
15
+ *
16
+ * @author Nathan Williams <nathan@nlwillia.net>
17
+ * Contributed under the same license terms as CodeMirror.
18
+ */
19
+ (function() {
20
+ /** Option that allows tag closing behavior to be toggled. Default is true. */
21
+ CodeMirror.defaults['closeTagEnabled'] = true;
22
+
23
+ /** Array of tag names to add indentation after the start tag for. Default is the list of block-level html tags. */
24
+ CodeMirror.defaults['closeTagIndent'] = ['applet', 'blockquote', 'body', 'button', 'div', 'dl', 'fieldset', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html', 'iframe', 'layer', 'legend', 'object', 'ol', 'p', 'select', 'table', 'ul'];
25
+
26
+ /** Array of tag names where an end tag is forbidden. */
27
+ CodeMirror.defaults['closeTagVoid'] = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
28
+
29
+ function innerXMLState(cm, state) {
30
+ var inner = CodeMirror.innerMode(cm.getMode(), state);
31
+ if (inner.mode.name == "xml") return inner.state;
32
+ }
33
+
34
+
35
+ /**
36
+ * Call during key processing to close tags. Handles the key event if the tag is closed, otherwise throws CodeMirror.Pass.
37
+ * - cm: The editor instance.
38
+ * - ch: The character being processed.
39
+ * - indent: Optional. An array of tag names to indent when closing. Omit or pass true to use the default indentation tag list defined in the 'closeTagIndent' option.
40
+ * Pass false to disable indentation. Pass an array to override the default list of tag names.
41
+ * - vd: Optional. An array of tag names that should not be closed. Omit to use the default void (end tag forbidden) tag list defined in the 'closeTagVoid' option. Ignored in xml mode.
42
+ */
43
+ CodeMirror.defineExtension("closeTag", function(cm, ch, indent, vd) {
44
+ if (!cm.getOption('closeTagEnabled')) {
45
+ throw CodeMirror.Pass;
46
+ }
47
+
48
+ /*
49
+ * Relevant structure of token:
50
+ *
51
+ * htmlmixed
52
+ * className
53
+ * state
54
+ * htmlState
55
+ * type
56
+ * tagName
57
+ * context
58
+ * tagName
59
+ * mode
60
+ *
61
+ * xml
62
+ * className
63
+ * state
64
+ * tagName
65
+ * type
66
+ */
67
+
68
+ var pos = cm.getCursor();
69
+ var tok = cm.getTokenAt(pos);
70
+ var state = innerXMLState(cm, tok.state);
71
+
72
+ if (state) {
73
+
74
+ if (ch == '>') {
75
+ var type = state.type;
76
+
77
+ if (tok.className == 'tag' && type == 'closeTag') {
78
+ throw CodeMirror.Pass; // Don't process the '>' at the end of an end-tag.
79
+ }
80
+
81
+ cm.replaceSelection('>'); // Mode state won't update until we finish the tag.
82
+ pos = {line: pos.line, ch: pos.ch + 1};
83
+ cm.setCursor(pos);
84
+
85
+ tok = cm.getTokenAt(cm.getCursor());
86
+ state = innerXMLState(cm, tok.state);
87
+ if (!state) throw CodeMirror.Pass;
88
+ var type = state.type;
89
+
90
+ if (tok.className == 'tag' && type != 'selfcloseTag') {
91
+ var tagName = state.tagName;
92
+ if (tagName.length > 0 && shouldClose(cm, vd, tagName)) {
93
+ insertEndTag(cm, indent, pos, tagName);
94
+ }
95
+ return;
96
+ }
97
+
98
+ // Undo the '>' insert and allow cm to handle the key instead.
99
+ cm.setSelection({line: pos.line, ch: pos.ch - 1}, pos);
100
+ cm.replaceSelection("");
101
+
102
+ } else if (ch == '/') {
103
+ if (tok.className == 'tag' && tok.string == '<') {
104
+ var ctx = state.context, tagName = ctx ? ctx.tagName : '';
105
+ if (tagName.length > 0) {
106
+ completeEndTag(cm, pos, tagName);
107
+ return;
108
+ }
109
+ }
110
+ }
111
+
112
+ }
113
+
114
+ throw CodeMirror.Pass; // Bubble if not handled
115
+ });
116
+
117
+ function insertEndTag(cm, indent, pos, tagName) {
118
+ if (shouldIndent(cm, indent, tagName)) {
119
+ cm.replaceSelection('\n\n</' + tagName + '>', 'end');
120
+ cm.indentLine(pos.line + 1);
121
+ cm.indentLine(pos.line + 2);
122
+ cm.setCursor({line: pos.line + 1, ch: cm.getLine(pos.line + 1).length});
123
+ } else {
124
+ cm.replaceSelection('</' + tagName + '>');
125
+ cm.setCursor(pos);
126
+ }
127
+ }
128
+
129
+ function shouldIndent(cm, indent, tagName) {
130
+ if (typeof indent == 'undefined' || indent == null || indent == true) {
131
+ indent = cm.getOption('closeTagIndent');
132
+ }
133
+ if (!indent) {
134
+ indent = [];
135
+ }
136
+ return indexOf(indent, tagName.toLowerCase()) != -1;
137
+ }
138
+
139
+ function shouldClose(cm, vd, tagName) {
140
+ if (cm.getOption('mode') == 'xml') {
141
+ return true; // always close xml tags
142
+ }
143
+ if (typeof vd == 'undefined' || vd == null) {
144
+ vd = cm.getOption('closeTagVoid');
145
+ }
146
+ if (!vd) {
147
+ vd = [];
148
+ }
149
+ return indexOf(vd, tagName.toLowerCase()) == -1;
150
+ }
151
+
152
+ // C&P from codemirror.js...would be nice if this were visible to utilities.
153
+ function indexOf(collection, elt) {
154
+ if (collection.indexOf) return collection.indexOf(elt);
155
+ for (var i = 0, e = collection.length; i < e; ++i)
156
+ if (collection[i] == elt) return i;
157
+ return -1;
158
+ }
159
+
160
+ function completeEndTag(cm, pos, tagName) {
161
+ cm.replaceSelection('/' + tagName + '>');
162
+ cm.setCursor({line: pos.line, ch: pos.ch + tagName.length + 2 });
163
+ }
164
+
165
+ })();
@@ -0,0 +1,36 @@
1
+ (function() {
2
+ var modes = ["clike", "css", "javascript"];
3
+ for (var i = 0; i < modes.length; ++i)
4
+ CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
5
+ blockCommentEnd: "*/",
6
+ blockCommentContinue: " * "});
7
+
8
+ CodeMirror.commands.newlineAndIndentContinueComment = function(cm) {
9
+ var pos = cm.getCursor(), token = cm.getTokenAt(pos);
10
+ var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
11
+ var space;
12
+
13
+ if (token.className == "comment" && mode.blockCommentStart) {
14
+ var end = token.string.indexOf(mode.blockCommentEnd);
15
+ var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end}), found;
16
+ if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
17
+ // Comment ended, don't continue it
18
+ } else if (token.string.indexOf(mode.blockCommentStart) == 0) {
19
+ space = full.slice(0, token.start);
20
+ if (!/^\s*$/.test(space)) {
21
+ space = "";
22
+ for (var i = 0; i < token.start; ++i) space += " ";
23
+ }
24
+ } else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
25
+ found + mode.blockCommentContinue.length > token.start &&
26
+ /^\s*$/.test(full.slice(0, found))) {
27
+ space = full.slice(0, found);
28
+ }
29
+ }
30
+
31
+ if (space != null)
32
+ cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
33
+ else
34
+ cm.execCommand("newlineAndIndent");
35
+ };
36
+ })();
@@ -0,0 +1,29 @@
1
+ (function() {
2
+ CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
3
+ var pos = cm.getCursor(), token = cm.getTokenAt(pos);
4
+ var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
5
+ var space;
6
+ if (token.className == "string") {
7
+ var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
8
+ var listStart = /\*|\d+\./, listContinue;
9
+ if (token.string.search(listStart) == 0) {
10
+ var reg = /^[\W]*(\d+)\./g;
11
+ var matches = reg.exec(full);
12
+ if(matches)
13
+ listContinue = (parseInt(matches[1]) + 1) + ". ";
14
+ else
15
+ listContinue = "* ";
16
+ space = full.slice(0, token.start);
17
+ if (!/^\s*$/.test(space)) {
18
+ space = "";
19
+ for (var i = 0; i < token.start; ++i) space += " ";
20
+ }
21
+ }
22
+ }
23
+
24
+ if (space != null)
25
+ cm.replaceSelection("\n" + space + listContinue, "end");
26
+ else
27
+ cm.execCommand("newlineAndIndent");
28
+ };
29
+ })();
@@ -0,0 +1,32 @@
1
+ .CodeMirror-dialog {
2
+ position: absolute;
3
+ left: 0; right: 0;
4
+ background: white;
5
+ z-index: 15;
6
+ padding: .1em .8em;
7
+ overflow: hidden;
8
+ color: #333;
9
+ }
10
+
11
+ .CodeMirror-dialog-top {
12
+ border-bottom: 1px solid #eee;
13
+ top: 0;
14
+ }
15
+
16
+ .CodeMirror-dialog-bottom {
17
+ border-top: 1px solid #eee;
18
+ bottom: 0;
19
+ }
20
+
21
+ .CodeMirror-dialog input {
22
+ border: none;
23
+ outline: none;
24
+ background: transparent;
25
+ width: 20em;
26
+ color: inherit;
27
+ font-family: monospace;
28
+ }
29
+
30
+ .CodeMirror-dialog button {
31
+ font-size: 70%;
32
+ }
@@ -0,0 +1,76 @@
1
+ // Open simple dialogs on top of an editor. Relies on dialog.css.
2
+
3
+ (function() {
4
+ function dialogDiv(cm, template, bottom) {
5
+ var wrap = cm.getWrapperElement();
6
+ var dialog;
7
+ dialog = wrap.appendChild(document.createElement("div"));
8
+ if (bottom) {
9
+ dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
10
+ } else {
11
+ dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
12
+ }
13
+ dialog.innerHTML = template;
14
+ return dialog;
15
+ }
16
+
17
+ CodeMirror.defineExtension("openDialog", function(template, callback, options) {
18
+ var dialog = dialogDiv(this, template, options && options.bottom);
19
+ var closed = false, me = this;
20
+ function close() {
21
+ if (closed) return;
22
+ closed = true;
23
+ dialog.parentNode.removeChild(dialog);
24
+ }
25
+ var inp = dialog.getElementsByTagName("input")[0], button;
26
+ if (inp) {
27
+ CodeMirror.connect(inp, "keydown", function(e) {
28
+ if (e.keyCode == 13 || e.keyCode == 27) {
29
+ CodeMirror.e_stop(e);
30
+ close();
31
+ me.focus();
32
+ if (e.keyCode == 13) callback(inp.value);
33
+ }
34
+ });
35
+ if (options && options.value) inp.value = options.value;
36
+ inp.focus();
37
+ CodeMirror.connect(inp, "blur", close);
38
+ } else if (button = dialog.getElementsByTagName("button")[0]) {
39
+ CodeMirror.connect(button, "click", function() {
40
+ close();
41
+ me.focus();
42
+ });
43
+ button.focus();
44
+ CodeMirror.connect(button, "blur", close);
45
+ }
46
+ return close;
47
+ });
48
+
49
+ CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
50
+ var dialog = dialogDiv(this, template, options && options.bottom);
51
+ var buttons = dialog.getElementsByTagName("button");
52
+ var closed = false, me = this, blurring = 1;
53
+ function close() {
54
+ if (closed) return;
55
+ closed = true;
56
+ dialog.parentNode.removeChild(dialog);
57
+ me.focus();
58
+ }
59
+ buttons[0].focus();
60
+ for (var i = 0; i < buttons.length; ++i) {
61
+ var b = buttons[i];
62
+ (function(callback) {
63
+ CodeMirror.connect(b, "click", function(e) {
64
+ CodeMirror.e_preventDefault(e);
65
+ close();
66
+ if (callback) callback(me);
67
+ });
68
+ })(callbacks[i]);
69
+ CodeMirror.connect(b, "blur", function() {
70
+ --blurring;
71
+ setTimeout(function() { if (blurring <= 0) close(); }, 200);
72
+ });
73
+ CodeMirror.connect(b, "focus", function() { ++blurring; });
74
+ }
75
+ });
76
+ })();