Skip to content

Commit

Permalink
Use console syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jul 15, 2018
1 parent 936aeb3 commit b9be63a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Get it now
macOS with `Homebrew <http://brew.sh/>`_:
*****************************************

.. code-block:: bash
.. code-block:: console
$ brew update
$ brew install doitlive
With pip:
*********

.. code-block:: bash
.. code-block:: console
$ pip install doitlive
Expand All @@ -49,7 +49,7 @@ Quickstart
1. Create a file called ``session.sh``. Fill it with bash commands.
2. Run ``doitlive play session.sh``.

.. code-block:: bash
.. code-block:: console
$ doitlive play session.sh
Expand Down
16 changes: 8 additions & 8 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Get it now
macOS with `Homebrew <http://brew.sh/>`_:
*****************************************

.. code-block:: bash
.. code-block:: console
$ brew update
$ brew install doitlive
With pip:
*********

.. code-block:: bash
.. code-block:: console
$ pip install doitlive
Expand All @@ -45,7 +45,7 @@ Quickstart
1. Create a file called ``session.sh``. Fill it with bash commands.
2. Run ``doitlive play session.sh``.

.. code-block:: bash
.. code-block:: console
$ doitlive play session.sh
Expand All @@ -56,7 +56,7 @@ Quickstart
Examples
--------

.. code-block:: bash
.. code-block:: console
# Use the "sorin" prompt theme
$ doitlive play session.sh -p sorin
Expand All @@ -72,7 +72,7 @@ Using the recorder

You can record session files using the built-in recorder command.

.. code-block:: bash
.. code-block:: console
$ doitlive record
Expand All @@ -86,7 +86,7 @@ Themes

doitlive comes with many prompt themes. To use a theme:

.. code-block:: bash
.. code-block:: console
$ doitlive play session.sh -p <theme_name>
Expand Down Expand Up @@ -272,14 +272,14 @@ More
For more options, run
.. code-block:: bash
.. code-block:: console
$ doitlive --help
You can also get help with subcommands.
.. code-block:: bash
.. code-block:: console
$ doitlive play --help
Expand Down
36 changes: 30 additions & 6 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,40 @@ def clean(ctx):

@task
def clean_docs(ctx):
ctx.run("rm -rf %s" % build_dir)
ctx.run('rm -rf %s' % build_dir, echo=True)

@task
def browse_docs(ctx):
ctx.run("open %s" % os.path.join(build_dir, 'index.html'))
path = os.path.join(build_dir, 'index.html')
webbrowser.open_new_tab(path)

def build_docs(ctx, browse):
ctx.run('sphinx-build %s %s' % (docs_dir, build_dir), echo=True)
if browse:
browse_docs(ctx)

@task
def docs(ctx, clean=False, browse=False):
def docs(ctx, clean=False, browse=False, watch=False):
"""Build the docs."""
if clean:
clean_docs(ctx)
ctx.run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
if browse:
browse_docs(ctx)
if watch:
watch_docs(ctx, browse=browse)
else:
build_docs(ctx, browse=browse)

@task
def watch_docs(ctx, browse=False):
"""Run build the docs when a file changes."""
try:
import sphinx_autobuild # noqa
except ImportError:
print('ERROR: watch task requires the sphinx_autobuild package.')
print('Install it with:')
print(' pip install sphinx-autobuild')
sys.exit(1)
ctx.run(
'sphinx-autobuild {0} {1} {2} -z doitlive'.format(
'--open-browser' if browse else '', docs_dir, build_dir,
), echo=True, pty=True,
)

0 comments on commit b9be63a

Please sign in to comment.