From 60a39964e2070e65c701b92e9209ca731c386525 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Fri, 7 Apr 2017 12:10:42 -0500 Subject: [PATCH] Add sphinx-prompt --- docs/conf.py | 4 +++- docs/contributing.rst | 40 ++++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9fba867..e5b9917 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,6 @@ -extensions = [] +extensions = [ + 'sphinx-prompt', +] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' diff --git a/docs/contributing.rst b/docs/contributing.rst index cabd8b4..9aa2f0e 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -23,22 +23,22 @@ We recommend using a `virtualenv `_. 1. Clone the repository. If you're planning to make pull request, you should fork the repository on GitHub and clone your fork instead of the main repo: -.. code:: bash +.. prompt:: bash - $ git clone https://github.com/yourusername/cti-python-stix2.git + git clone https://github.com/yourusername/cti-python-stix2.git 2. Install develoment-related dependencies: -.. code:: bash +.. prompt:: bash - $ cd cti-python-stix2 - $ pip install -r requirements.txt + cd cti-python-stix2 + pip install -r requirements.txt 3. Install `pre-commit `_ git hooks: -.. code:: bash +.. prompt:: bash - $ pre-commit install + pre-commit install At this point you should be able to make changes to the code. @@ -65,15 +65,19 @@ or implements the features. Any code contributions to python-stix2 should come with new or updated tests. To run the tests in your current Python environment, use the ``pytest`` command -from the root project directory:: +from the root project directory: - $ pytest +.. prompt:: bash + + pytest This should show all of the tests that ran, along with their status. -You can run a specific test file by passing it on the command line:: +You can run a specific test file by passing it on the command line: - $ pytest stix2/test/test_.py +.. prompt:: bash + + pytest stix2/test/test_.py To ensure that the test you wrote is running, you can deliberately add an ``assert False`` statement at the beginning of the test. This is another benefit @@ -83,18 +87,22 @@ run) before making it pass. `tox `_ allows you to test a package across multiple versions of Python. Setting up multiple Python environments is beyond the scope of this guide, but feel free to ask for help setting them up. -Tox should be run from the root directory of the project::: +Tox should be run from the root directory of the project: - $ tox +.. prompt:: bash + + tox We aim for high test coverage, using the `coverage.py `_ library. Though it's not an absolute requirement to maintain 100% coverage, all code contributions must be accompanied by tests. To run coverage and look for untested lines of code, -run:: +run: - $ pytest --cov=stix2 - $ coverage html +.. prompt:: bash + + pytest --cov=stix2 + coverage html then look at the resulting report in ``htmlcov/index.html``.