Skip to content

Commit 545d84d

Browse files
authored
Merge branch 'master' into master
2 parents 4d692c0 + 821b71d commit 545d84d

File tree

12 files changed

+3284
-52
lines changed

12 files changed

+3284
-52
lines changed

.github/workflows/integration.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Set up Python 3.7
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v2
1515
with:
1616
python-version: 3.7
1717
- name: Install dependencies
@@ -35,7 +35,7 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v2
3737
- name: Use Node.js ${{ matrix.node-version }}
38-
uses: actions/setup-node@v1
38+
uses: actions/setup-node@v2
3939
with:
4040
node-version: ${{ matrix.node-version }}
4141
- run: npm ci
@@ -48,12 +48,12 @@ jobs:
4848
runs-on: ubuntu-latest
4949
strategy:
5050
matrix:
51-
python-version: [3.6, 3.7, 3.8]
51+
python-version: [3.6, 3.7, 3.8, 3.9]
5252

5353
steps:
5454
- uses: actions/checkout@v2
5555
- name: Set up Python ${{ matrix.python-version }}
56-
uses: actions/setup-python@v1
56+
uses: actions/setup-python@v2
5757
with:
5858
python-version: ${{ matrix.python-version }}
5959
- name: Install dependencies
@@ -78,7 +78,7 @@ jobs:
7878
- name: Checkout source
7979
uses: actions/checkout@v2
8080
- name: Set up Python 3.7
81-
uses: actions/setup-python@v1
81+
uses: actions/setup-python@v2
8282
with:
8383
python-version: 3.7
8484
- name: Build package
@@ -87,7 +87,7 @@ jobs:
8787
git submodule update --init
8888
python setup.py sdist bdist_wheel
8989
- name: Publish
90-
uses: pypa/gh-action-pypi-publish@v1.1.0
90+
uses: pypa/gh-action-pypi-publish@v1.4.2
9191
with:
9292
user: __token__
9393
password: ${{ secrets.PYPI_KEY }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,5 @@ _build/
112112
node_modules/
113113

114114
.DS_Store
115+
116+
.idea

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ exclude: >
88
99
repos:
1010

11-
- repo: git://github.com/pre-commit/pre-commit-hooks
12-
rev: v2.2.3
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v3.4.0
1313
hooks:
1414
- id: check-json
1515
- id: check-yaml
1616
- id: end-of-file-fixer
1717
- id: trailing-whitespace
18+
19+
- repo: https://github.com/PyCQA/flake8
20+
rev: 3.9.2
21+
hooks:
1822
- id: flake8
1923

2024
- repo: https://github.com/psf/black
21-
rev: stable
25+
rev: 21.5b1
2226
hooks:
2327
- id: black

doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#
@@ -101,6 +100,8 @@
101100
# CopyButton configuration
102101
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
103102
copybutton_prompt_is_regexp = True
103+
copybutton_line_continuation_character = "\\"
104+
copybutton_here_doc_delimiter = "EOT"
104105
# Switches for testing but shouldn't be activated in the live docs
105106
# copybutton_only_copy_prompt_lines = False
106107
# copybutton_remove_prompts = False

doc/index.rst

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Installation
6060

6161
.. note::
6262

63-
``sphinx-copybutton`` only works on Python >= 3.4
63+
``sphinx-copybutton`` only works on Python >= 3.6
6464

6565
You can install ``sphinx-copybutton`` with ``pip``:
6666

@@ -268,6 +268,80 @@ strip the prompts), use the following configuration in ``conf.py``:
268268
269269
copybutton_remove_prompts = False
270270
271+
Configure whether *empty* lines are copied
272+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273+
274+
By default, sphinx-copybutton will also copy / pass through empty lines,
275+
determined by ``line.trim() === ''``.
276+
277+
To disable copying empty lines, use the following configuration in ``conf.py``:
278+
279+
.. code-block:: python
280+
281+
copybutton_copy_empty_lines = False
282+
283+
Honor line continuation characters when copying multline-snippets
284+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285+
286+
Sometimes you may wish to copy a code block like this one:
287+
288+
.. code-block:: bash
289+
290+
$ datalad download-url http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf \
291+
--dataset . \
292+
-m "add beginners guide on bash" \
293+
-O books/bash_guide.pdf
294+
295+
Assuming that you specified ``$`` as your prompt, sphinx-copybutton will only copy
296+
the first line by default.
297+
298+
To copy all lines above, you can use the following configuration:
299+
300+
.. code-block:: python
301+
302+
copybutton_line_continuation_character = "\\"
303+
304+
Note that if we want to define ``\`` as the line continuation character, we have to "escape"
305+
it with another ``\``, as with any Python string that should carry a literal ``\``.
306+
307+
Next, this configuration will make the code look for lines to copy based on the rules above,
308+
but if one of the lines to be copied contains a line continuation character,
309+
then the next line will be automatically copied, regardless of whether it matches the other
310+
rules.
311+
312+
Honor HERE-document syntax when copying multline-snippets
313+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314+
315+
`HERE-documents <https://en.wikipedia.org/wiki/Here_document>`_ are a form of multiline string literals
316+
in which line breaks and other whitespace (including indentation) is preserved.
317+
For example:
318+
319+
.. code-block:: bash
320+
321+
$ cat << EOT > notes.txt
322+
This is an example sentence.
323+
Put some indentation on this line.
324+
325+
EOT
326+
327+
Executing this codeblock in the terminal will create a file ``notes.txt`` with the exact
328+
text from line two of the codeblock until (but not including) the final line containing ``EOT``.
329+
330+
However, assuming that you specified ``$`` as your prompt, sphinx-copybutton will only copy
331+
the first line by default.
332+
333+
sphinx-copybutton can be configured to copy the whole "HERE-document" by using the following
334+
configuration:
335+
336+
.. code-block:: python
337+
338+
copybutton_here_doc_delimiter = "EOT"
339+
340+
This will continue to look for lines to copy based on the rules above,
341+
but if one of the lines to be copied contains the defined delimiter (here: ``EOT``),
342+
then all following lines will be copied literally until the next delimiter is
343+
encountered in a line.
344+
271345
Use a different copy button image
272346
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273347

0 commit comments

Comments
 (0)