Skip to content

Commit 1a02efc

Browse files
committed
Changed get_full_qualified_name() + Fixed ruff and mypy
1 parent 94624ff commit 1a02efc

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

sphinxarg/ext.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from docutils.parsers.rst import Parser
1414
from docutils.parsers.rst.directives import flag, unchanged
1515
from docutils.statemachine import StringList
16-
from sphinx.ext.autodoc import mock
17-
from sphinx.util.docutils import SphinxDirective, new_document
1816
from sphinx.domains import Domain, Index, IndexEntry
1917
from sphinx.errors import ExtensionError
2018
from sphinx.ext.autodoc import mock
@@ -895,8 +893,10 @@ class ArgParseDomain(Domain):
895893
# option is set to True.
896894
temporary_index_files: list[Path] = []
897895

898-
def get_full_qualified_name(self, node: Element) -> str:
899-
return str(node.arguments[0])
896+
def get_full_qualified_name(self, node: Element) -> str | None:
897+
# The use of this method is not clear - the content is made to
898+
# resemble :meth:`PythonDomain.get_full_qualified_name` instead
899+
return node.get('reftarget', None)
900900

901901
def get_objects(self) -> Iterable[_ObjectDescriptionTuple]:
902902
yield from self.data['commands']
@@ -910,7 +910,7 @@ def resolve_xref(
910910
target: str,
911911
node: pending_xref,
912912
contnode: Element,
913-
) -> Element | None:
913+
) -> nodes.reference | None:
914914
anchor_id = target_to_anchor_id(target)
915915
match = [
916916
(docname, anchor)
@@ -1016,8 +1016,12 @@ def setup(app: Sphinx):
10161016

10171017
app.add_config_value('sphinxarg_build_commands_by_group_index', False, 'html', bool)
10181018
app.add_config_value('sphinxarg_commands_by_group_index_in_toctree', False, 'html', bool)
1019-
app.add_config_value('sphinxarg_commands_by_group_index_file_suffix', CommandsByGroupIndex.name, 'html', str)
1020-
app.add_config_value('sphinxarg_commands_by_group_index_title', CommandsByGroupIndex.localname, 'html', str)
1019+
app.add_config_value(
1020+
'sphinxarg_commands_by_group_index_file_suffix', CommandsByGroupIndex.name, 'html', str
1021+
)
1022+
app.add_config_value(
1023+
'sphinxarg_commands_by_group_index_title', CommandsByGroupIndex.localname, 'html', str
1024+
)
10211025

10221026
app.connect('builder-inited', configure_ext)
10231027
app.connect('build-finished', _delete_temporary_files)

test/test_argparse_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33

4-
@pytest.mark.skip(reason="Refactoring")
4+
@pytest.mark.skip(reason='Refactoring')
55
@pytest.mark.sphinx('html', testroot='argparse-directive')
66
def test_bad_index_groups(app, status, warning):
77
app.build()

test/test_default_html.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
('.//h1', 'blah-blah', False),
1919
(".//div[@class='highlight']//span", 'usage'),
2020
('.//h2', 'Positional Arguments'),
21-
2221
(".//section[@id='sample-directive-opts-positional-arguments']", ''),
2322
(".//section/span[@id='get_parser-positional-arguments']", ''),
2423
(
@@ -27,7 +26,10 @@
2726
),
2827
(".//section[@id='sample-directive-opts-named-arguments']", ''),
2928
(".//section/span[@id='get_parser-named-arguments']", ''),
30-
(".//section[@id='sample-directive-opts-named-arguments']/dl/dt[1]/kbd", '--foo'),
29+
(
30+
".//section[@id='sample-directive-opts-named-arguments']/dl/dt[1]/kbd",
31+
'--foo',
32+
),
3133
(".//section[@id='sample-directive-opts-bar-options']", ''),
3234
(".//section/span[@id='get_parser-bar-options']", ''),
3335
(".//section[@id='sample-directive-opts-bar-options']/dl/dt[1]/kbd", '--bar'),
@@ -42,7 +44,10 @@
4244
('.//h2', 'Positional Arguments'),
4345
(".//section[@id='sample-directive-opts-A-positional-arguments']", ''),
4446
(".//section/span[@id='get_parser-positional-arguments']", ''),
45-
(".//section[@id='sample-directive-opts-A-positional-arguments']/dl/dt[1]/kbd", 'baz'),
47+
(
48+
".//section[@id='sample-directive-opts-A-positional-arguments']/dl/dt[1]/kbd",
49+
'baz',
50+
),
4651
],
4752
),
4853
(

0 commit comments

Comments
 (0)