Skip to content

Commit

Permalink
Update ids in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 17, 2024
1 parent bbd9e5e commit f7f767f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 4 additions & 2 deletions sphinxarg/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def print_action_groups(
# Every action group is composed of a section, holding
# a title, the description, and the option group (members)
title_as_id = action_group['title'].replace(' ', '-').lower()
section = nodes.section(ids=[f'{id_prefix}-{title_as_id}'])
if id_prefix:
title_as_id = f'{id_prefix}-{title_as_id}'
section = nodes.section(ids=[title_as_id])
section += nodes.title(action_group['title'], action_group['title'])

desc = []
Expand Down Expand Up @@ -575,7 +577,7 @@ def run(self):
nested_content,
markdown_help,
settings=self.state.document.settings,
id_prefix=(f'{module_name}-' if module_name else '') + attr_name,
id_prefix=f'{module_name}-{attr_name}' if module_name else attr_name,
)
)
if 'nosubcommands' not in self.options:
Expand Down
19 changes: 11 additions & 8 deletions test/test_default_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ def get_text(node):
('.//h1', 'blah-blah', False),
(".//div[@class='highlight']//span", 'usage'),
('.//h2', 'Positional Arguments'),
(".//section[@id='positional-arguments']", ''),
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'foo2 metavar'),
(".//section[@id='named-arguments']", ''),
(".//section[@id='named-arguments']/dl/dt[1]/kbd", '--foo'),
(".//section[@id='bar-options']", ''),
(".//section[@id='bar-options']/dl/dt[1]/kbd", '--bar'),
(".//section[@id='get_parser-positional-arguments']", ''),
(
".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd",
'foo2 metavar',
),
(".//section[@id='get_parser-named-arguments']", ''),
(".//section[@id='get_parser-named-arguments']/dl/dt[1]/kbd", '--foo'),
(".//section[@id='get_parser-bar-options']", ''),
(".//section[@id='get_parser-bar-options']/dl/dt[1]/kbd", '--bar'),
],
),
(
Expand All @@ -71,8 +74,8 @@ def get_text(node):
('.//h1', 'Command A'),
(".//div[@class='highlight']//span", 'usage'),
('.//h2', 'Positional Arguments'),
(".//section[@id='positional-arguments']", ''),
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'baz'),
(".//section[@id='get_parser-positional-arguments']", ''),
(".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd", 'baz'),
],
),
(
Expand Down

0 comments on commit f7f767f

Please sign in to comment.