diff --git a/sphinxarg/ext.py b/sphinxarg/ext.py index 020aed2e..798d83eb 100644 --- a/sphinxarg/ext.py +++ b/sphinxarg/ext.py @@ -113,6 +113,8 @@ 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() + if data['name']: + title_as_id = f'{data["name"]}-{title_as_id}' if id_prefix: title_as_id = f'{id_prefix}-{title_as_id}' section = nodes.section(ids=[title_as_id]) diff --git a/test/test_default_html.py b/test/test_default_html.py index 304053a2..3678390a 100644 --- a/test/test_default_html.py +++ b/test/test_default_html.py @@ -74,8 +74,8 @@ def get_text(node): ('.//h1', 'Command A'), (".//div[@class='highlight']//span", 'usage'), ('.//h2', 'Positional Arguments'), - (".//section[@id='get_parser-positional-arguments']", ''), - (".//section[@id='get_parser-positional-arguments']/dl/dt[1]/kbd", 'baz'), + (".//section[@id='get_parser-A-positional-arguments']", ''), + (".//section[@id='get_parser-A-positional-arguments']/dl/dt[1]/kbd", 'baz'), ], ), (