Skip to content

Commit f7f767f

Browse files
committed
Update ids in tests
1 parent bbd9e5e commit f7f767f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

sphinxarg/ext.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def print_action_groups(
113113
# Every action group is composed of a section, holding
114114
# a title, the description, and the option group (members)
115115
title_as_id = action_group['title'].replace(' ', '-').lower()
116-
section = nodes.section(ids=[f'{id_prefix}-{title_as_id}'])
116+
if id_prefix:
117+
title_as_id = f'{id_prefix}-{title_as_id}'
118+
section = nodes.section(ids=[title_as_id])
117119
section += nodes.title(action_group['title'], action_group['title'])
118120

119121
desc = []
@@ -575,7 +577,7 @@ def run(self):
575577
nested_content,
576578
markdown_help,
577579
settings=self.state.document.settings,
578-
id_prefix=(f'{module_name}-' if module_name else '') + attr_name,
580+
id_prefix=f'{module_name}-{attr_name}' if module_name else attr_name,
579581
)
580582
)
581583
if 'nosubcommands' not in self.options:

test/test_default_html.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ def get_text(node):
5656
('.//h1', 'blah-blah', False),
5757
(".//div[@class='highlight']//span", 'usage'),
5858
('.//h2', 'Positional Arguments'),
59-
(".//section[@id='positional-arguments']", ''),
60-
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'foo2 metavar'),
61-
(".//section[@id='named-arguments']", ''),
62-
(".//section[@id='named-arguments']/dl/dt[1]/kbd", '--foo'),
63-
(".//section[@id='bar-options']", ''),
64-
(".//section[@id='bar-options']/dl/dt[1]/kbd", '--bar'),
59+
(".//section[@id='get_parser-positional-arguments']", ''),
60+
(
61+
".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd",
62+
'foo2 metavar',
63+
),
64+
(".//section[@id='get_parser-named-arguments']", ''),
65+
(".//section[@id='get_parser-named-arguments']/dl/dt[1]/kbd", '--foo'),
66+
(".//section[@id='get_parser-bar-options']", ''),
67+
(".//section[@id='get_parser-bar-options']/dl/dt[1]/kbd", '--bar'),
6568
],
6669
),
6770
(
@@ -71,8 +74,8 @@ def get_text(node):
7174
('.//h1', 'Command A'),
7275
(".//div[@class='highlight']//span", 'usage'),
7376
('.//h2', 'Positional Arguments'),
74-
(".//section[@id='positional-arguments']", ''),
75-
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'baz'),
77+
(".//section[@id='get_parser-positional-arguments']", ''),
78+
(".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd", 'baz'),
7679
],
7780
),
7881
(

0 commit comments

Comments
 (0)