Skip to content

Commit

Permalink
Merge pull request #102 from sloria/black
Browse files Browse the repository at this point in the history
Use black and pre-commit
  • Loading branch information
sloria committed Dec 23, 2018
2 parents bf03778 + 8fbee8e commit 1d6409b
Show file tree
Hide file tree
Showing 24 changed files with 962 additions and 745 deletions.
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.9b0
hooks:
- id: black
exclude: docopt.py
language_version: python3.6
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/blacken-docs
rev: v0.3.0
hooks:
- id: blacken-docs
additional_dependencies: [black==18.9b0]
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

## Setting up for development

* Create and activate a new virtual environment
* `pip install -e '.[dev]'`
* (Optional but recommended) If you're using a Python 3.6 virtual
environment, install the pre-commit hooks, which will
format and lint your git staged files:


```
# The pre-commit CLI was installed above
pre-commit install
```

* To run tests:

```
pytest
```

* To run syntax checks:

```
tox -e lint
```

* To build the docs:

```
tox -e watch-docs
```

* (Optional) To run tests on Python 2.7, 3.5, 3.6, and 3.7 virtual environments (must have each interpreter installed):

```
tox
```
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ doitlive
:alt: travis-ci status
:target: https://travis-ci.org/sloria/doitlive

.. image:: https://badgen.net/badge/code%20style/black/000
:target: https://github.com/ambv/black
:alt: Code style: Black


`doitlive` is a tool for live presentations in the terminal. It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.

Expand Down
149 changes: 76 additions & 73 deletions docs/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
from pygments.token import (
Keyword,
Name,
Comment,
String,
Error,
Number,
Operator,
Generic,
Whitespace,
Punctuation,
Other,
Literal,
)


class FlaskyStyle(Style):
Expand All @@ -10,77 +22,68 @@ class FlaskyStyle(Style):

styles = {
# No corresponding class for the following:
#Text: "", # class: ''
Whitespace: "underline #f8f8f8", # class: 'w'
Error: "#a40000 border:#ef2929", # class: 'err'
Other: "#000000", # class 'x'

Comment: "italic #8f5902", # class: 'c'
Comment.Preproc: "noitalic", # class: 'cp'

Keyword: "bold #004461", # class: 'k'
Keyword.Constant: "bold #004461", # class: 'kc'
Keyword.Declaration: "bold #004461", # class: 'kd'
Keyword.Namespace: "bold #004461", # class: 'kn'
Keyword.Pseudo: "bold #004461", # class: 'kp'
Keyword.Reserved: "bold #004461", # class: 'kr'
Keyword.Type: "bold #004461", # class: 'kt'

Operator: "#582800", # class: 'o'
Operator.Word: "bold #004461", # class: 'ow' - like keywords

Punctuation: "bold #000000", # class: 'p'

# Text: "", # class: ''
Whitespace: "underline #f8f8f8", # class: 'w'
Error: "#a40000 border:#ef2929", # class: 'err'
Other: "#000000", # class 'x'
Comment: "italic #8f5902", # class: 'c'
Comment.Preproc: "noitalic", # class: 'cp'
Keyword: "bold #004461", # class: 'k'
Keyword.Constant: "bold #004461", # class: 'kc'
Keyword.Declaration: "bold #004461", # class: 'kd'
Keyword.Namespace: "bold #004461", # class: 'kn'
Keyword.Pseudo: "bold #004461", # class: 'kp'
Keyword.Reserved: "bold #004461", # class: 'kr'
Keyword.Type: "bold #004461", # class: 'kt'
Operator: "#582800", # class: 'o'
Operator.Word: "bold #004461", # class: 'ow' - like keywords
Punctuation: "bold #000000", # class: 'p'
# because special names such as Name.Class, Name.Function, etc.
# are not recognized as such later in the parsing, we choose them
# to look the same as ordinary variables.
Name: "#000000", # class: 'n'
Name.Attribute: "#c4a000", # class: 'na' - to be revised
Name.Builtin: "#004461", # class: 'nb'
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
Name.Class: "#000000", # class: 'nc' - to be revised
Name.Constant: "#000000", # class: 'no' - to be revised
Name.Decorator: "#888", # class: 'nd' - to be revised
Name.Entity: "#ce5c00", # class: 'ni'
Name.Exception: "bold #cc0000", # class: 'ne'
Name.Function: "#000000", # class: 'nf'
Name.Property: "#000000", # class: 'py'
Name.Label: "#f57900", # class: 'nl'
Name.Namespace: "#000000", # class: 'nn' - to be revised
Name.Other: "#000000", # class: 'nx'
Name.Tag: "bold #004461", # class: 'nt' - like a keyword
Name.Variable: "#000000", # class: 'nv' - to be revised
Name.Variable.Class: "#000000", # class: 'vc' - to be revised
Name.Variable.Global: "#000000", # class: 'vg' - to be revised
Name.Variable.Instance: "#000000", # class: 'vi' - to be revised

Number: "#990000", # class: 'm'

Literal: "#000000", # class: 'l'
Literal.Date: "#000000", # class: 'ld'

String: "#4e9a06", # class: 's'
String.Backtick: "#4e9a06", # class: 'sb'
String.Char: "#4e9a06", # class: 'sc'
String.Doc: "italic #8f5902", # class: 'sd' - like a comment
String.Double: "#4e9a06", # class: 's2'
String.Escape: "#4e9a06", # class: 'se'
String.Heredoc: "#4e9a06", # class: 'sh'
String.Interpol: "#4e9a06", # class: 'si'
String.Other: "#4e9a06", # class: 'sx'
String.Regex: "#4e9a06", # class: 'sr'
String.Single: "#4e9a06", # class: 's1'
String.Symbol: "#4e9a06", # class: 'ss'

Generic: "#000000", # class: 'g'
Generic.Deleted: "#a40000", # class: 'gd'
Generic.Emph: "italic #000000", # class: 'ge'
Generic.Error: "#ef2929", # class: 'gr'
Generic.Heading: "bold #000080", # class: 'gh'
Generic.Inserted: "#00A000", # class: 'gi'
Generic.Output: "#888", # class: 'go'
Generic.Prompt: "#745334", # class: 'gp'
Generic.Strong: "bold #000000", # class: 'gs'
Generic.Subheading: "bold #800080", # class: 'gu'
Generic.Traceback: "bold #a40000", # class: 'gt'
}
Name: "#000000", # class: 'n'
Name.Attribute: "#c4a000", # class: 'na' - to be revised
Name.Builtin: "#004461", # class: 'nb'
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
Name.Class: "#000000", # class: 'nc' - to be revised
Name.Constant: "#000000", # class: 'no' - to be revised
Name.Decorator: "#888", # class: 'nd' - to be revised
Name.Entity: "#ce5c00", # class: 'ni'
Name.Exception: "bold #cc0000", # class: 'ne'
Name.Function: "#000000", # class: 'nf'
Name.Property: "#000000", # class: 'py'
Name.Label: "#f57900", # class: 'nl'
Name.Namespace: "#000000", # class: 'nn' - to be revised
Name.Other: "#000000", # class: 'nx'
Name.Tag: "bold #004461", # class: 'nt' - like a keyword
Name.Variable: "#000000", # class: 'nv' - to be revised
Name.Variable.Class: "#000000", # class: 'vc' - to be revised
Name.Variable.Global: "#000000", # class: 'vg' - to be revised
Name.Variable.Instance: "#000000", # class: 'vi' - to be revised
Number: "#990000", # class: 'm'
Literal: "#000000", # class: 'l'
Literal.Date: "#000000", # class: 'ld'
String: "#4e9a06", # class: 's'
String.Backtick: "#4e9a06", # class: 'sb'
String.Char: "#4e9a06", # class: 'sc'
String.Doc: "italic #8f5902", # class: 'sd' - like a comment
String.Double: "#4e9a06", # class: 's2'
String.Escape: "#4e9a06", # class: 'se'
String.Heredoc: "#4e9a06", # class: 'sh'
String.Interpol: "#4e9a06", # class: 'si'
String.Other: "#4e9a06", # class: 'sx'
String.Regex: "#4e9a06", # class: 'sr'
String.Single: "#4e9a06", # class: 's1'
String.Symbol: "#4e9a06", # class: 'ss'
Generic: "#000000", # class: 'g'
Generic.Deleted: "#a40000", # class: 'gd'
Generic.Emph: "italic #000000", # class: 'ge'
Generic.Error: "#ef2929", # class: 'gr'
Generic.Heading: "bold #000080", # class: 'gh'
Generic.Inserted: "#00A000", # class: 'gi'
Generic.Output: "#888", # class: 'go'
Generic.Prompt: "#745334", # class: 'gp'
Generic.Strong: "bold #000000", # class: 'gs'
Generic.Subheading: "bold #800080", # class: 'gu'
Generic.Traceback: "bold #a40000", # class: 'gt'
}
37 changes: 18 additions & 19 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@
import os
import datetime as dt

sys.path.insert(0, os.path.abspath('..'))
import doitlive # flake8: noqa
sys.path.insert(0, os.path.abspath(".."))
import doitlive # noqa: E402

sys.path.append(os.path.abspath("_themes"))

extensions = [
'sphinx_issues'
]
extensions = ["sphinx_issues"]

issues_github_path = 'sloria/doitlive'
issues_github_path = "sloria/doitlive"

templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'doitlive'
copyright = u'2014-{0:%Y}'.format(dt.datetime.utcnow())
project = u"doitlive"
copyright = u"2014-{0:%Y}".format(dt.datetime.utcnow())

version = release = doitlive.__version__

exclude_patterns = ['_build']
pygments_style = 'flask_theme_support.FlaskyStyle'
html_theme = 'kr_small'
exclude_patterns = ["_build"]
pygments_style = "flask_theme_support.FlaskyStyle"
html_theme = "kr_small"

html_theme_options = {
'index_logo': 'doitlive-logo.png',
'index_logo_height': '200px',
'github_fork': 'sloria/doitlive'
"index_logo": "doitlive-logo.png",
"index_logo_height": "200px",
"github_fork": "sloria/doitlive",
}

html_theme_path = ['_themes']
html_static_path = ['_static']
html_theme_path = ["_themes"]
html_static_path = ["_static"]
56 changes: 30 additions & 26 deletions doitlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,39 @@
from .python_consoles import PythonRecorderConsole, PythonPlayerConsole
from .styling import THEMES, Style, TermString, TTY, echo, echo_prompt, format_prompt
from .keyboard import wait_for, magictype, magicrun, ESC, BACKSPACE, CTRLC, RETURNS
from .version_control import get_current_git_branch, get_current_hg_branch, get_current_vcs_branch
from .version_control import (
get_current_git_branch,
get_current_hg_branch,
get_current_vcs_branch,
)
from .exceptions import DoItLiveError, ConfigurationError, SessionError
from .__version__ import __version__

__author__ = 'Steven Loria'
__license__ = 'MIT'
__author__ = "Steven Loria"
__license__ = "MIT"
__version__ = __version__
__all__ = [
'SessionState',
'PythonRecorderConsole',
'PythonPlayerConsole',
'THEMES',
'Style',
'TermString',
'TTY',
'echo',
'echo_prompt',
'format_prompt',
'wait_for',
'magictype',
'magicrun',
'ESC',
'BACKSPACE',
'CTRLC',
'RETURNS',
'get_current_git_branch',
'get_current_hg_branch',
'get_current_vcs_branch',
'DoItLiveError',
'ConfigurationError',
'SessionError',
"SessionState",
"PythonRecorderConsole",
"PythonPlayerConsole",
"THEMES",
"Style",
"TermString",
"TTY",
"echo",
"echo_prompt",
"format_prompt",
"wait_for",
"magictype",
"magicrun",
"ESC",
"BACKSPACE",
"CTRLC",
"RETURNS",
"get_current_git_branch",
"get_current_hg_branch",
"get_current_vcs_branch",
"DoItLiveError",
"ConfigurationError",
"SessionError",
]
2 changes: 1 addition & 1 deletion doitlive/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.2.1'
__version__ = "4.2.1"

0 comments on commit 1d6409b

Please sign in to comment.