Skip to content

Commit 2f9fb91

Browse files
committed
Update ids in tests
1 parent bbd9e5e commit 2f9fb91

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-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

+8-8
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ 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+
(".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd", 'foo2 metavar'),
61+
(".//section[@id='get_parser-named-arguments']", ''),
62+
(".//section[@id='get_parser-named-arguments']/dl/dt[1]/kbd", '--foo'),
63+
(".//section[@id='get_parser-bar-options']", ''),
64+
(".//section[@id='get_parser-bar-options']/dl/dt[1]/kbd", '--bar'),
6565
],
6666
),
6767
(
@@ -71,8 +71,8 @@ def get_text(node):
7171
('.//h1', 'Command A'),
7272
(".//div[@class='highlight']//span", 'usage'),
7373
('.//h2', 'Positional Arguments'),
74-
(".//section[@id='positional-arguments']", ''),
75-
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'baz'),
74+
(".//section[@id='get_parser-positional-arguments']", ''),
75+
(".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd", 'baz'),
7676
],
7777
),
7878
(

0 commit comments

Comments
 (0)