This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkeyword.js
51 lines (44 loc) · 1.47 KB
/
keyword.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Define classes for managing keyword documentation
//
// KeywordLibrary - a class which stores the documentation for
// the keywords in a robot library
// Keyword - a class which stores the documentation for
// one particular keyword
define(function(require, exports, module) {
'use strict';
function KeywordLibrary(name, path) {
this.name = name;
this.path = path;
this._keywords = []
};
KeywordLibrary.prototype.contains = function(keyword) {
keyword = keyword.trim().toLowerCase();
for (var i = 0; i < this._keywords.length; i++) {
if (this._keywords[i].name.toLowerCase() === keyword) {
return true;
}
}
return false;
};
KeywordLibrary.prototype.keywords = function(pattern /* optional */) {
var result = [];
for (var i = 0; i < this._keywords.length; i++) {
var name = this._keywords[i].name
if (pattern && (! name.match(pattern))) {
continue
}
result.push(name);
}
return result;
};
KeywordLibrary.prototype.add_keyword = function(name, args, doc) {
this._keywords.push(new Keyword(name, args, doc));
};
function Keyword(name, args, doc) {
this.name = name.trim();
this.args = args;
this.doc = doc;
};
exports.KeywordLibrary = KeywordLibrary;
exports.Keyword = Keyword;
});