Skip to content

Commit

Permalink
Make argument and option section IDs more unique (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jul 15, 2024
1 parent e3eee29 commit 1fd3047
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sphinxarg/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ def render_list(l, markdown_help, settings=None):
return all_children


def print_action_groups(data, nested_content, markdown_help=False, settings=None):
def print_action_groups(
data,
nested_content,
markdown_help=False,
settings=None,
id_prefix='',
):
"""
Process all 'action groups', which are also include 'Options' and 'Required
arguments'. A list of nodes is returned.
Expand All @@ -97,7 +103,8 @@ def print_action_groups(data, nested_content, markdown_help=False, settings=None
for action_group in data['action_groups']:
# Every action group is composed of a section, holding
# a title, the description, and the option group (members)
section = nodes.section(ids=[action_group['title'].replace(' ', '-').lower()])
title_as_id = action_group['title'].replace(' ', '-').lower()
section = nodes.section(ids=[f'{id_prefix}-{title_as_id}'])
section += nodes.title(action_group['title'], action_group['title'])

desc = []
Expand Down Expand Up @@ -487,6 +494,7 @@ def run(self):
f = self._open_filename()
code = compile(f.read(), self.options['filename'], 'exec')
exec(code, mod)
module_name = None
attr_name = self.options['func']
func = mod[attr_name]
else:
Expand Down Expand Up @@ -563,6 +571,7 @@ def run(self):
nested_content,
markdown_help,
settings=self.state.document.settings,
id_prefix=(f'{module_name}-' if module_name else '') + attr_name,
)
)
if 'nosubcommands' not in self.options:
Expand Down

0 comments on commit 1fd3047

Please sign in to comment.