10000 Ensure indentation is preserved with nested directives. · python-formate/snippet-fmt@3cfd499 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3cfd499

Browse files
committed
Ensure indentation is preserved with nested directives.
1 parent f83ecab commit 3cfd499

File tree

120 files changed

+1325
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+1325
-1
lines changed

snippet_fmt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def process_match(self, match: Match[str]) -> str:
167167
with syntaxerror_for_file(self.filename):
168168
code = formatter(code, **lang_config)
169169

170-
code = textwrap.indent(code, match["body_indent"])
170+
code = textwrap.indent(code, match["indent"] + match["body_indent"])
171171
return f'{match["before"]}{code.rstrip()}{trailing_ws}'
172172

173173
def get_diff(self) -> str:

tests/example.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_custom_entry_point_example_rst_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,14 @@
119119
120120
name: my-project
121121
version: 1.2.3
122+
123+
.. a-directive::
124+
125+
.. code-block:: json
126+
127+
{"key": "value", "key2": "value2"}
128+
129+
.. code-block:: bash
130+
131+
$ conda config --add channels https://conda.anaconda.org/conda-forge
132+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_0_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_1_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_2_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_3_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_4_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_5_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_6_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_empty_7_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_0_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_1_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_2_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_3_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_4_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_5_.rst

Lines changed: 11 additions & 0 deletions
Original file line n 10000 umberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_6_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_7_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_0_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_1_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_2_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_3_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_4_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_5_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_6_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

tests/test_snippet_fmt_/test_snippet_fmt_example_rst_ini_caps_7_.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,14 @@
130130
131131
name: my-project
132132
version: 1.2.3
133+
134+
.. a-directive::
135+
136+
.. code-block:: json
137+
138+
{"key": "value", "key2": "value2"}
139+
140+
.. code-block:: bash
141+
142+
$ conda config --add channels https://conda.anaconda.org/conda-forge
143+
$ conda config --add channels https://conda.anaconda.org/domdfcoding

0 commit comments

Comments
 (0)
0