-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Procfile Lexer * add unit tests for ProcfileLexer * add Procfile lexer author * Document Procfile as supported language * add Procfile.output file * merge Profile files; update output file * Add versionadded info * Fix typo (processus -> processes) * detect Integer only * split Text from Whitespace
- Loading branch information
Showing
7 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
pygments.lexers.procfile | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Lexer for Procfile file format. | ||
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
|
||
from pygments.lexer import RegexLexer, bygroups | ||
from pygments.token import Name, Number, String, Text, Punctuation | ||
|
||
__all__ = ["ProcfileLexer"] | ||
|
||
|
||
class ProcfileLexer(RegexLexer): | ||
""" | ||
Lexer for Procfile file format. | ||
The format is used to run processes on Heroku or is used by Foreman or | ||
Honcho tools. | ||
For more information about the definition of the format, see: | ||
https://devcenter.heroku.com/articles/procfile#procfile-format | ||
.. versionadded:: 2.10 | ||
""" | ||
name = 'Procfile' | ||
aliases = ['procfile'] | ||
filenames = ['Procfile'] | ||
|
||
tokens = { | ||
'root': [ | ||
(r'^([a-z]+)(:)', bygroups(Name.Label, Punctuation)), | ||
(r'\s+', Text.Whitespace), | ||
(r'"[^"]*"', String), | ||
(r"'[^']*'", String), | ||
(r'[0-9]+', Number.Integer), | ||
(r'\$[a-zA-Z_][\w]*', Name.Variable), | ||
(r'(\w+)(=)(\w+)', bygroups(Name.Variable, Punctuation, String)), | ||
(r'([\w\-\./]+)', Text), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
db: runzeo -C zeoserver.config | ||
web: bundle exec rails server -p $PORT | ||
stuff: env FLASK_ENV=development run -p 9 --stuff 'foobar' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Basic ProcfileLexer Test | ||
~~~~~~~~~~~~~~~~~~~~ | ||
:copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
|
||
import pytest | ||
|
||
from pygments.token import Name, Punctuation, Text | ||
from pygments.lexers.procfile import ProcfileLexer | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def lexer(): | ||
yield ProcfileLexer() | ||
|
||
|
||
def test_basic_line(lexer): | ||
text = 'task: executable --options' | ||
|
||
tokens = lexer.get_tokens(text) | ||
|
||
for index, token in enumerate(tokens): | ||
if index == 0: | ||
assert token == (Name.Label, 'task') | ||
elif index == 1: | ||
assert token == (Punctuation, ':') | ||
else: | ||
assert token[0] in (Text, Text.Whitespace) | ||
|
||
|
||
def test_environment_variable(lexer): | ||
text = '$XDG_SESSION_PATH' | ||
|
||
token = list(lexer.get_tokens(text))[0] | ||
|
||
assert token == (Name.Variable, text) |