├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── fixtures ├── first_line_match │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.txt │ ├── 6.txt │ ├── 7.txt │ └── 8.txt ├── robot.txt ├── test.robot ├── test_bdd.robot └── test_comment.robot ├── grammars └── robottxt.cson ├── package.json ├── settings └── robottxt.cson ├── snippets └── language-robot-framework.cson └── spec ├── fixtures └── test_separate_keyword_and_value.robot ├── robot-framework-spec.coffee └── robot-framework-txt-spec.coffee /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | node_modules 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | notifications: 2 | email: 3 | on_success: never 4 | on_failure: change 5 | 6 | script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' 7 | 8 | git: 9 | depth: 10 10 | 11 | sudo: false 12 | 13 | os: 14 | - linux 15 | - osx 16 | 17 | env: 18 | global: 19 | - APM_TEST_PACKAGES="" 20 | 21 | matrix: 22 | - ATOM_CHANNEL=stable 23 | - ATOM_CHANNEL=beta 24 | 25 | addons: 26 | apt: 27 | packages: 28 | - build-essential 29 | - git 30 | - libgnome-keyring-dev 31 | - fakeroot 32 | 33 | branches: 34 | only: 35 | - master 36 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.7.0 2 | * Fix [#8](https://github.com/wingyplus/language-robot-framework/issues/8) - Failed to activate the language-robot-framework package 3 | 4 | ## 0.6.0 5 | * Add snippets Documentation and Tags 6 | * Fix It's comment if the # is the first symbol in the cell. 7 | 8 | ## 0.5.0 9 | * Refactor some test. 10 | 11 | ## 0.4.0 12 | * Support "And" keyword highlight 13 | 14 | ## 0.3.0 15 | * Add Robot Framework Selenium2Library Snippet verson 1.0.0 16 | 17 | ## 0.2.0 18 | * Support syntax highlight for keyword "Given", "When" and "Then" 19 | 20 | ## 0.1.0 - First Release 21 | * Add Robot Framework syntax highlight (convert from TextMate bundle) 22 | * Auto change to Robot Framework syntax when extension file is "robot" 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | language-robot-framework package 2 | ================================ 3 | 4 | [![Build Status](https://travis-ci.org/wingyplus/language-robot-framework.svg)](https://travis-ci.org/wingyplus/language-robot-framework) 5 | 6 | Adds syntax highlighting and snippets to [Robot Framework](https://github.com/robotframework/robotframework) files in Atom. 7 | 8 | Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc. 9 | 10 | Thanks 11 | ------ 12 | [@roongr2k7 (Pitsanu Swangpheaw)](https://github.com/roongr2k7) 13 | [@kenben (Quentin Nerden)](https://github.com/kenden) 14 | -------------------------------------------------------------------------------- /fixtures/first_line_match/1.txt: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/2.txt: -------------------------------------------------------------------------------- 1 | *** Keywords *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/3.txt: -------------------------------------------------------------------------------- 1 | *** Variables *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/4.txt: -------------------------------------------------------------------------------- 1 | *** settings *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/5.txt: -------------------------------------------------------------------------------- 1 | *** keywords *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/6.txt: -------------------------------------------------------------------------------- 1 | *** variables *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/7.txt: -------------------------------------------------------------------------------- 1 | *** Test Cases *** 2 | -------------------------------------------------------------------------------- /fixtures/first_line_match/8.txt: -------------------------------------------------------------------------------- 1 | *** test cases *** 2 | -------------------------------------------------------------------------------- /fixtures/robot.txt: -------------------------------------------------------------------------------- 1 | *** Test Cases *** 2 | Test given keyword should show color 3 | Given Mark as same test case color 4 | It should be mark Given keyword at start step only 5 | 6 | Test when keyword should show color 7 | When Mark as same test case color 8 | It should be mark When keyword at start step only 9 | 10 | Test then keyword should show color 11 | Then Mark as same test case color 12 | It should be mark Then keyword at start step only 13 | 14 | Test and keyword should show color 15 | And Mark as same test case color 16 | It should be mark And keyword at start step only 17 | -------------------------------------------------------------------------------- /fixtures/test.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library Selenium2Library 3 | 4 | 5 | *** Test Cases *** 6 | Test a Syntax Highlight for ".robot" extension 7 | Open Browser http://localhost:8000/ browser=${browser} 8 | -------------------------------------------------------------------------------- /fixtures/test_bdd.robot: -------------------------------------------------------------------------------- 1 | *** Test Cases *** 2 | Test given keyword should show color 3 | [Documentation] 4 | Given Mark as same test case color 5 | It should be mark Given keyword at start step only 6 | 7 | Test when keyword should show color 8 | When Mark as same test case color 9 | It should be mark When keyword at start step only 10 | 11 | Test then keyword should show color 12 | Then Mark as same test case color 13 | It should be mark Then keyword at start step only 14 | 15 | Test and keyword should show color 16 | And Mark as same test case color 17 | It should be mark And keyword at start step only 18 | 19 | Test and keyword should show color 20 | But Mark as same test case color 21 | It should be mark And keyword at start step only 22 | -------------------------------------------------------------------------------- /fixtures/test_comment.robot: -------------------------------------------------------------------------------- 1 | *** Test Cases *** 2 | #Comment 3 | # This is comment 4 | # comment after space 5 | This is not comment #hello 6 | -------------------------------------------------------------------------------- /grammars/robottxt.cson: -------------------------------------------------------------------------------- 1 | 'comment': '\n\tRobot Framework syntax highlighting for txt format.\t\n\t' 2 | 'fileTypes': [ 3 | 'robot' 4 | ] 5 | 'name': 'Robot Framework' 6 | 'firstLineMatch': '\\*{3} (?i:Settings|Keywords|Variables|Test Cases) \\*{3}' 7 | 'patterns': [ 8 | { 9 | 'match': '(^\\*\\*\\*.*?\\*\\*\\*)|((?<=^\\|)\\s+\\*\\*\\*.*?\\*\\*\\*)' 10 | 'name': 'string.robot.header' 11 | } 12 | { 13 | 'include': '#tag' 14 | } 15 | { 16 | 'include': '#variables' 17 | } 18 | { 19 | 'include': '#comment' 20 | } 21 | { 22 | 'include': '#keyword' 23 | } 24 | { 25 | 'begin': '^(?![ \\t\\n\\*\\|])' 26 | 'contentName': 'keyword.control.robot' 27 | 'end': '\\s{2,}|\\t|$' 28 | 'patterns': [ 29 | { 30 | 'include': '#variables' 31 | } 32 | ] 33 | } 34 | { 35 | 'begin': '^([ \\t]+)(?=[a-zA-Z])' 36 | 'contentName': 'keyword.control.robot' 37 | 'end': '\\s{2,}|\\t|$' 38 | 'patterns': [ 39 | { 40 | 'include': '#variables' 41 | } 42 | ] 43 | } 44 | { 45 | 'match': '(?:^[\\s\\t]+)(Given|When|And|Then|But)' 46 | 'captures': 47 | '1': 48 | 'name': 'keyword.control.robot' 49 | } 50 | ] 51 | 'repository': 52 | 'variables': 53 | 'begin': '([\\$@&]{)' 54 | 'beginCaptures': 55 | '0': 56 | 'name': 'punctuation.section.embedded.begin.robot' 57 | '1': 58 | 'name': 'text.robot' 59 | 'end': '(})' 60 | 'contentName': 'variable.control.robot' 61 | 'endCaptures': 62 | '0': 63 | 'name': 'punctuation.section.embedded.end.robot' 64 | '1': 65 | 'name': 'text.robot' 66 | 'comment': 67 | 'match': '(?:^[\\s\\t]*)(#.*)$' 68 | 'captures': 69 | '1': 70 | 'name': 'comment.line.robot' 71 | 'tag': 72 | 'match': '^[\\s\\t]*(\\[.+\\])' 73 | 'captures': 74 | '0': 75 | 'name': 'entity.tag.name.robot' 76 | '1': 77 | 'name': 'text.robot' 78 | 'keyword': 79 | 'begin': '\\=(\\s{2,}|\\t)' 80 | 'contentName': 'keyword.control.robot' 81 | 'end': '\\s{2,}|\\t|$' 82 | 'scopeName': 'text.robot' 83 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-robot-framework", 3 | "version": "2.4.0", 4 | "description": "Robot Framework syntax highlight for Atom", 5 | "repository": "https://github.com/wingyplus/language-robot-framework", 6 | "license": "MIT", 7 | "engines": { 8 | "atom": ">0.50.0" 9 | }, 10 | "dependencies": {}, 11 | "devDependencies": { 12 | "atom-grammar-test": "^0.6.2", 13 | "coffeelint": "^1.10.0" 14 | }, 15 | "scripts": { 16 | "all": "npm run lint && npm run test", 17 | "test": "apm test", 18 | "lint": "./node_modules/.bin/coffeelint spec" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /settings/robottxt.cson: -------------------------------------------------------------------------------- 1 | '.text.robot': 2 | 'editor': 3 | 'commentStart': '# ' 4 | -------------------------------------------------------------------------------- /snippets/language-robot-framework.cson: -------------------------------------------------------------------------------- 1 | '.text.robot': 2 | 'Hello world': 3 | 'prefix': 'hello' 4 | 'body': ''' 5 | *** Test Cases *** 6 | Example test 7 | Log Hello world 8 | ''' 9 | 'Keywords': 10 | 'prefix': '*k' 11 | 'body': '*** Keywords ***' 12 | 'Settings': 13 | 'prefix': '*s' 14 | 'body': '*** Settings ***' 15 | 'Test Cases': 16 | 'prefix': '*t' 17 | 'body': '*** Test Cases ***' 18 | 'Variables': 19 | 'prefix': '*v' 20 | 'body': '*** Variables ***' 21 | 'Documentation': 22 | 'prefix': ':doc' 23 | 'body': '[Documentation] ${1:description}' 24 | 'Tags': 25 | 'prefix': ':tags' 26 | 'body': '[Tags] ${1:tag}' 27 | -------------------------------------------------------------------------------- /spec/fixtures/test_separate_keyword_and_value.robot: -------------------------------------------------------------------------------- 1 | // SYNTAX TEST "text.robot" 2 | *** Settings *** 3 | Library Selenium2Library 4 | # <- text.robot keyword.control.robot 5 | # ^ text.robot -------------------------------------------------------------------------------- /spec/robot-framework-spec.coffee: -------------------------------------------------------------------------------- 1 | path = require 'path' 2 | grammarTest = require 'atom-grammar-test' 3 | 4 | describe 'Robot Framework grammar', -> 5 | grammar = null 6 | 7 | beforeEach -> 8 | waitsForPromise -> 9 | atom.packages.activatePackage('language-robot-framework') 10 | 11 | runs -> 12 | grammar = atom.grammars.grammarForScopeName('text.robot') 13 | 14 | it 'parse the grammar', -> 15 | expect(grammar).toBeTruthy() 16 | 17 | describe 'comment', -> 18 | it "tokenizes when comment keyword is at the start of line", -> 19 | {tokens} = grammar.tokenizeLine '# Test Case' 20 | 21 | expect(tokens[0].value).toEqual '# Test Case' 22 | expect(tokens[0].scopes).toEqual ['text.robot', 'comment.line.robot'] 23 | 24 | it 'tokenizes when have spaces before comment keyword', -> 25 | {tokens} = grammar.tokenizeLine ' # Step' 26 | 27 | expect(tokens[0].value).toEqual ' ' 28 | expect(tokens[1].value).toEqual '# Step' 29 | expect(tokens[1].scopes).toEqual ['text.robot', 'comment.line.robot'] 30 | 31 | it 'tokenizes oneline of comment', -> 32 | {tokens} = grammar.tokenizeLine '# Test Case\n Step' 33 | 34 | expect(tokens[0].value).toEqual '# Test Case' 35 | expect(tokens[0].scopes).toEqual ['text.robot', 'comment.line.robot'] 36 | expect(tokens[1].value).toEqual '\n' 37 | expect(tokens[2].value).toEqual ' ' 38 | expect(tokens[3].value).toEqual 'Step' 39 | expect(tokens[3].scopes).toEqual ['text.robot', 'keyword.control.robot'] 40 | 41 | it 'does not tokenizes comment', -> 42 | {tokens} = grammar.tokenizeLine ' This is step #id' 43 | 44 | expect(tokens[0].value).toEqual ' ' 45 | expect(tokens[1].value).toEqual 'This is step' 46 | expect(tokens[1].scopes).toEqual ['text.robot', 'keyword.control.robot'] 47 | expect(tokens[2].value).toEqual ' ' 48 | expect(tokens[3].value).toEqual '#id' 49 | expect(tokens[3].scopes).toEqual ['text.robot'] 50 | 51 | describe 'variable', -> 52 | 53 | describe 'captures', -> 54 | tokens = null 55 | 56 | beforeEach -> {tokens} = grammar.tokenizeLine '${var}' 57 | 58 | afterEach -> tokens = null 59 | 60 | it 'tokenizes ${ as a begin punctuation', -> 61 | expect(tokens[0].value).toEqual '${' 62 | expect(tokens[0].scopes).toEqual [ 63 | 'text.robot', 64 | 'punctuation.section.embedded.begin.robot', 65 | 'text.robot' 66 | ] 67 | 68 | it 'tokenizes var as a robot variable', -> 69 | expect(tokens[1].value).toEqual 'var' 70 | expect(tokens[1].scopes).toEqual [ 71 | 'text.robot', 72 | 'variable.control.robot' 73 | ] 74 | 75 | it 'tokenizes } as a end punctuation', -> 76 | expect(tokens[2].value).toEqual '}' 77 | expect(tokens[2].scopes).toEqual [ 78 | 'text.robot', 79 | 'punctuation.section.embedded.end.robot', 80 | 'text.robot' 81 | ] 82 | 83 | describe 'list', -> 84 | 85 | it 'tokenizes @{ as a begin punctuation', -> 86 | {tokens} = grammar.tokenizeLine '@{var}' 87 | expect(tokens[0].value).toEqual '@{' 88 | expect(tokens[0].scopes).toEqual [ 89 | 'text.robot', 90 | 'punctuation.section.embedded.begin.robot', 91 | 'text.robot' 92 | ] 93 | 94 | describe 'dict', -> 95 | 96 | it 'tokenizes &{ as a begin punctuation', -> 97 | {tokens} = grammar.tokenizeLine '&{var}' 98 | expect(tokens[0].value).toEqual '&{' 99 | expect(tokens[0].scopes).toEqual [ 100 | 'text.robot', 101 | 'punctuation.section.embedded.begin.robot', 102 | 'text.robot' 103 | ] 104 | 105 | describe 'bdd style', -> 106 | 107 | expectedScopes = ['text.robot', 'keyword.control.robot'] 108 | 109 | it 'tokenizes Given', -> 110 | {tokens} = grammar.tokenizeLine ' Given Do Something' 111 | 112 | expect(tokens[1].scopes).toEqual expectedScopes 113 | expect(tokens[1].value).toEqual 'Given Do Something' 114 | 115 | it 'tokenizes When', -> 116 | {tokens} = grammar.tokenizeLine ' When Do Something' 117 | 118 | expect(tokens[1].scopes).toEqual expectedScopes 119 | expect(tokens[1].value).toEqual 'When Do Something' 120 | 121 | it 'tokenizes Then', -> 122 | {tokens} = grammar.tokenizeLine ' Then Do Something' 123 | 124 | expect(tokens[1].scopes).toEqual expectedScopes 125 | expect(tokens[1].value).toEqual 'Then Do Something' 126 | 127 | it 'tokenizes And', -> 128 | {tokens} = grammar.tokenizeLine ' And Do Something' 129 | 130 | expect(tokens[1].scopes).toEqual expectedScopes 131 | expect(tokens[1].value).toEqual 'And Do Something' 132 | 133 | it 'tokenizes But', -> 134 | {tokens} = grammar.tokenizeLine ' But Do Something' 135 | 136 | expect(tokens[1].scopes).toEqual expectedScopes 137 | expect(tokens[1].value).toEqual 'But Do Something' 138 | 139 | describe 'issue 12', -> 140 | 141 | it "should not tokenize 'And' when it isn't at the start of a keyword", -> 142 | {tokens} = grammar.tokenizeLine ' Press And Hold The Button' 143 | 144 | expect(tokens.length).toEqual 2 145 | expect(tokens[1].value).toEqual 'Press And Hold The Button' 146 | 147 | describe 'testcase', -> 148 | 149 | it 'tokenizes as a keyword.control.robot', -> 150 | samples = [ 151 | 'Do', 152 | 'Do Something', 153 | 'Do 9', 154 | 'Do "something"' 155 | ].forEach (line) -> 156 | {tokens} = grammar.tokenizeLine line 157 | 158 | expect(tokens.length).toEqual 1 159 | expect(tokens[0].value).toEqual line 160 | expect(tokens[0].scopes).toEqual ['text.robot', 'keyword.control.robot'] 161 | 162 | it 'tokenizes variable in keyword', -> 163 | {tokens} = grammar.tokenizeLine 'Test Keyword ${myvar}' 164 | 165 | expect(tokens.length).toEqual 4 166 | expect(tokens[0].value).toEqual 'Test Keyword ' 167 | expect(tokens[0].scopes).toEqual ['text.robot', 'keyword.control.robot'] 168 | 169 | expect(tokens[1].value).toEqual '${' 170 | expect(tokens[1].scopes).toEqual [ 171 | 'text.robot', 172 | 'keyword.control.robot', 173 | 'punctuation.section.embedded.begin.robot', 174 | 'text.robot' 175 | ] 176 | 177 | expect(tokens[2].value).toEqual 'myvar' 178 | expect(tokens[2].scopes).toEqual [ 179 | 'text.robot', 180 | 'keyword.control.robot', 181 | 'variable.control.robot' 182 | ] 183 | 184 | expect(tokens[3].value).toEqual '}' 185 | expect(tokens[3].scopes).toEqual [ 186 | 'text.robot', 187 | 'keyword.control.robot', 188 | 'punctuation.section.embedded.end.robot', 189 | 'text.robot' 190 | ] 191 | 192 | {tokens} = grammar.tokenizeLine 'Test Keyword ${myvar} Awesome' 193 | 194 | expect(tokens[0].value).toEqual 'Test Keyword ' 195 | expect(tokens[1].value).toEqual '${' 196 | expect(tokens[2].value).toEqual 'myvar' 197 | expect(tokens[3].value).toEqual '}' 198 | expect(tokens[4].value).toEqual ' Awesome' 199 | expect(tokens[4].scopes).toEqual ['text.robot', 'keyword.control.robot'] 200 | 201 | 202 | describe 'tag', -> 203 | it 'tokenizes []', -> 204 | {tokens} = grammar.tokenizeLine ' [Documentation]' 205 | expect(tokens.length).toEqual(2) 206 | expect(tokens[1].value).toEqual '[Documentation]' 207 | expect(tokens[1].scopes).toEqual [ 208 | 'text.robot', 'entity.tag.name.robot', 'text.robot'] 209 | 210 | it 'does not tokenizes css selector', -> 211 | {tokens} = grammar.tokenizeLine ' Somebody css=input[name=value]' 212 | expect(tokens.length).toEqual(4) 213 | expect(tokens[3].value).toEqual 'css=input[name=value]' 214 | expect(tokens[3].scopes).toEqual ['text.robot'] 215 | 216 | grammarTest( 217 | path.join(__dirname, "fixtures", "test_separate_keyword_and_value.robot")) 218 | -------------------------------------------------------------------------------- /spec/robot-framework-txt-spec.coffee: -------------------------------------------------------------------------------- 1 | xdescribe 'Robot Framework on .txt', -> 2 | 3 | it 'should change grammar to text.robot when first line has robot header', -> 4 | waitsForPromise -> 5 | atom.packages.activatePackage 'language-robot-framework' 6 | 7 | workspace = atom.workspace 8 | [ 9 | '../fixtures/first_line_match/1.txt' 10 | '../fixtures/first_line_match/2.txt' 11 | '../fixtures/first_line_match/3.txt' 12 | '../fixtures/first_line_match/4.txt' 13 | '../fixtures/first_line_match/5.txt' 14 | '../fixtures/first_line_match/6.txt' 15 | '../fixtures/first_line_match/7.txt' 16 | '../fixtures/first_line_match/8.txt' 17 | ].forEach (file) -> 18 | waitsForPromise -> 19 | workspace.open(file).then (editor) -> 20 | expect(editor.getGrammar().scopeName).toEqual 'text.robot' 21 | --------------------------------------------------------------------------------