Skip to content

Commit 369ad32

Browse files
committed
fix tests
1 parent 5bdea83 commit 369ad32

File tree

3 files changed

+82
-25
lines changed

3 files changed

+82
-25
lines changed

sphinx_click/ext.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ def _format_command(
372372

373373
lines = list(_format_options(ctx))
374374
if lines:
375-
# we use rubric to provide some separation without exploding the table
376-
# of contents
377-
yield '.. rubric:: Options'
375+
yield '.. rubric:: Optionz'
378376
yield ''
379377

380378
for line in lines:

tests/test_extension.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ def test_basics(make_app, rootdir):
2020
# section:
2121
# title:
2222
# paragraph:
23+
# rubric: (Usage)
2324
# literal_block:
24-
# rubric:
25+
# rubric: (Commands)
2526
# index:
2627
# desc:
2728
# desc_signature:
@@ -38,16 +39,18 @@ def test_basics(make_app, rootdir):
3839
assert section[0].astext() == 'greet'
3940
assert isinstance(section[1], nodes.paragraph)
4041
assert section[1].astext() == 'A sample command group.'
41-
assert isinstance(section[2], nodes.literal_block)
42+
assert isinstance(section[2], nodes.rubric)
43+
assert section[2].astext() == 'Usage'
44+
assert isinstance(section[3], nodes.literal_block)
4245

43-
assert isinstance(section[3], nodes.rubric)
44-
assert section[3].astext() == 'Commands'
45-
assert isinstance(section[4], sphinx_nodes.index)
46-
assert isinstance(section[5], sphinx_nodes.desc)
47-
assert section[5].astext() == 'hello\n\nGreet a user.'
48-
assert isinstance(section[6], sphinx_nodes.index)
49-
assert isinstance(section[7], sphinx_nodes.desc)
50-
assert section[7].astext() == 'world\n\nGreet the world.'
46+
assert isinstance(section[4], nodes.rubric)
47+
assert section[4].astext() == 'Commands'
48+
assert isinstance(section[5], sphinx_nodes.index)
49+
assert isinstance(section[6], sphinx_nodes.desc)
50+
assert section[6].astext() == 'hello\n\nGreet a user.'
51+
assert isinstance(section[7], sphinx_nodes.index)
52+
assert isinstance(section[8], sphinx_nodes.desc)
53+
assert section[8].astext() == 'world\n\nGreet the world.'
5154

5255

5356
def test_commands(make_app, rootdir):
@@ -66,8 +69,9 @@ def test_commands(make_app, rootdir):
6669
# section:
6770
# title:
6871
# paragraph:
72+
# rubric: (Usage)
6973
# literal_block:
70-
# rubric:
74+
# rubric: (Commands)
7175
# index:
7276
# desc:
7377
# desc_signature:
@@ -80,14 +84,16 @@ def test_commands(make_app, rootdir):
8084
assert section[0].astext() == 'greet'
8185
assert isinstance(section[1], nodes.paragraph)
8286
assert section[1].astext() == 'A sample command group.'
83-
assert isinstance(section[2], nodes.literal_block)
87+
assert isinstance(section[2], nodes.rubric)
88+
assert section[2].astext() == 'Usage'
89+
assert isinstance(section[3], nodes.literal_block)
8490

8591
# we should only show a single command, 'world'
86-
assert isinstance(section[3], nodes.rubric)
87-
assert section[3].astext() == 'Commands'
88-
assert isinstance(section[4], sphinx_nodes.index)
89-
assert isinstance(section[5], sphinx_nodes.desc)
90-
assert section[5].astext() == 'world\n\nGreet the world.'
92+
assert isinstance(section[4], nodes.rubric)
93+
assert section[4].astext() == 'Commands'
94+
assert isinstance(section[5], sphinx_nodes.index)
95+
assert isinstance(section[6], sphinx_nodes.desc)
96+
assert section[6].astext() == 'world\n\nGreet the world.'
9197

9298

9399
def test_nested_full(make_app, rootdir):
@@ -106,15 +112,18 @@ def test_nested_full(make_app, rootdir):
106112
# section:
107113
# title:
108114
# paragraph:
115+
# rubric: (Usage)
109116
# literal_block:
110117
# section:
111118
# title
112119
# paragraph
120+
# rubric: (Usage)
113121
# literal_block
114122
# ...
115123
# section:
116124
# title
117125
# paragraph
126+
# rubric: (Usage)
118127
# literal_block
119128

120129
section = content[0][1]
@@ -124,23 +133,29 @@ def test_nested_full(make_app, rootdir):
124133
assert section[0].astext() == 'greet'
125134
assert isinstance(section[1], nodes.paragraph)
126135
assert section[1].astext() == 'A sample command group.'
127-
assert isinstance(section[2], nodes.literal_block)
136+
assert isinstance(section[2], nodes.rubric)
137+
assert section[2].astext() == 'Usage'
138+
assert isinstance(section[3], nodes.literal_block)
128139

129-
subsection_a = section[3]
140+
subsection_a = section[4]
130141
assert isinstance(subsection_a, nodes.section)
131142

132143
assert isinstance(subsection_a[0], nodes.title)
133144
assert subsection_a[0].astext() == 'hello'
134145
assert isinstance(subsection_a[1], nodes.paragraph)
135146
assert subsection_a[1].astext() == 'Greet a user.'
136-
assert isinstance(subsection_a[2], nodes.literal_block)
147+
assert isinstance(subsection_a[2], nodes.rubric)
148+
assert subsection_a[2].astext() == 'Usage'
149+
assert isinstance(subsection_a[3], nodes.literal_block)
137150
# we don't need to verify the rest of this: that's done elsewhere
138151

139-
subsection_b = section[4]
152+
subsection_b = section[5]
140153
assert isinstance(subsection_b, nodes.section)
141154

142155
assert isinstance(subsection_b[0], nodes.title)
143156
assert subsection_b[0].astext() == 'world'
144157
assert isinstance(subsection_b[1], nodes.paragraph)
145158
assert subsection_b[1].astext() == 'Greet the world.'
146-
assert isinstance(subsection_b[2], nodes.literal_block)
159+
assert isinstance(subsection_b[2], nodes.rubric)
160+
assert subsection_b[2].astext() == 'Usage'
161+
assert isinstance(subsection_b[3], nodes.literal_block)

tests/test_formatter.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def foobar():
3131
A sample command.
3232
3333
.. program:: foobar
34+
.. rubric:: Usage
35+
3436
.. code-block:: shell
3537
3638
foobar [OPTIONS]
@@ -79,6 +81,8 @@ def foobar(bar):
7981
A sample command.
8082
8183
.. program:: foobar
84+
.. rubric:: Usage
85+
8286
.. code-block:: shell
8387
8488
foobar [OPTIONS] ARG
@@ -152,6 +156,8 @@ def foobar(bar):
152156
A sample command.
153157
154158
.. program:: foobar
159+
.. rubric:: Usage
160+
155161
.. code-block:: shell
156162
157163
foobar [OPTIONS]
@@ -197,6 +203,8 @@ def foobar(bar):
197203
A sample command.
198204
199205
.. program:: foobar
206+
.. rubric:: Usage
207+
200208
.. code-block:: shell
201209
202210
foobar [OPTIONS] ARG ARG_NO_HELP
@@ -261,6 +269,8 @@ def foobar(bar):
261269
A sample command.
262270
263271
.. program:: foobar
272+
.. rubric:: Usage
273+
264274
.. code-block:: shell
265275
266276
foobar [OPTIONS]
@@ -313,6 +323,8 @@ def foobar():
313323
A sample command.
314324
315325
.. program:: foobar
326+
.. rubric:: Usage
327+
316328
.. code-block:: shell
317329
318330
foobar [OPTIONS]
@@ -374,6 +386,8 @@ def hello(name):
374386
my_cli hello --name "Jack"
375387
376388
.. program:: hello
389+
.. rubric:: Usage
390+
377391
.. code-block:: shell
378392
379393
hello [OPTIONS]
@@ -428,6 +442,8 @@ def foobar():
428442
dash of bold and even some underlined words.
429443
430444
.. program:: foobar
445+
.. rubric:: Usage
446+
431447
.. code-block:: shell
432448
433449
foobar [OPTIONS]
@@ -495,6 +511,8 @@ def cli():
495511
:param click.core.Context ctx: Click context.
496512
497513
.. program:: cli
514+
.. rubric:: Usage
515+
498516
.. code-block:: shell
499517
500518
cli [OPTIONS]
@@ -564,6 +582,8 @@ def cli():
564582
that will be rewrapped again.
565583
566584
.. program:: cli
585+
.. rubric:: Usage
586+
567587
.. code-block:: shell
568588
569589
cli [OPTIONS]
@@ -621,6 +641,8 @@ def cli():
621641
A sample command group.
622642
623643
.. program:: cli
644+
.. rubric:: Usage
645+
624646
.. code-block:: shell
625647
626648
cli [OPTIONS] COMMAND [ARGS]...
@@ -652,6 +674,8 @@ def cli():
652674
A sample command group.
653675
654676
.. program:: cli
677+
.. rubric:: Usage
678+
655679
.. code-block:: shell
656680
657681
cli [OPTIONS] ARG COMMAND [ARGS]...
@@ -724,6 +748,8 @@ def test_nested_short(self):
724748
A sample command group.
725749
726750
.. program:: cli
751+
.. rubric:: Usage
752+
727753
.. code-block:: shell
728754
729755
cli [OPTIONS] COMMAND [ARGS]...
@@ -753,6 +779,8 @@ def test_nested_full(self):
753779
A sample command group.
754780
755781
.. program:: cli
782+
.. rubric:: Usage
783+
756784
.. code-block:: shell
757785
758786
cli [OPTIONS] COMMAND [ARGS]...
@@ -776,6 +804,8 @@ def test_nested_none(self):
776804
A sample command group.
777805
778806
.. program:: cli
807+
.. rubric:: Usage
808+
779809
.. code-block:: shell
780810
781811
cli [OPTIONS] COMMAND [ARGS]...
@@ -818,6 +848,8 @@ def test_no_commands(self):
818848
A sample command group.
819849
820850
.. program:: cli
851+
.. rubric:: Usage
852+
821853
.. code-block:: shell
822854
823855
cli [OPTIONS] COMMAND [ARGS]...
@@ -840,6 +872,8 @@ def test_order_of_commands(self):
840872
A sample command group.
841873
842874
.. program:: cli
875+
.. rubric:: Usage
876+
843877
.. code-block:: shell
844878
845879
cli [OPTIONS] COMMAND [ARGS]...
@@ -902,6 +936,8 @@ def get_command(self, ctx, name):
902936
A sample custom multicommand.
903937
904938
.. program:: cli
939+
.. rubric:: Usage
940+
905941
.. code-block:: shell
906942
907943
cli [OPTIONS] COMMAND [ARGS]...
@@ -960,6 +996,8 @@ def get_command(self, ctx, name):
960996
A sample custom multicommand.
961997
962998
.. program:: cli
999+
.. rubric:: Usage
1000+
9631001
.. code-block:: shell
9641002
9651003
cli [OPTIONS] COMMAND [ARGS]...
@@ -1017,6 +1055,8 @@ def world():
10171055
A simple CommandCollection.
10181056
10191057
.. program:: cli
1058+
.. rubric:: Usage
1059+
10201060
.. code-block:: shell
10211061
10221062
cli [OPTIONS] COMMAND [ARGS]...
@@ -1033,6 +1073,8 @@ def world():
10331073
A simple CommandCollection.
10341074
10351075
.. program:: cli
1076+
.. rubric:: Usage
1077+
10361078
.. code-block:: shell
10371079
10381080
cli [OPTIONS] COMMAND [ARGS]...
@@ -1083,6 +1125,8 @@ def cli_with_auto_envvars():
10831125
A simple CLI with auto-env vars .
10841126
10851127
.. program:: cli
1128+
.. rubric:: Usage
1129+
10861130
.. code-block:: shell
10871131
10881132
cli [OPTIONS]

0 commit comments

Comments
 (0)