diff --git a/AUTHORS.rst b/AUTHORS.rst index 0a4678c..c13b86c 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -4,6 +4,7 @@ Credits ``doc2dash`` is written and maintained by Hynek Schlawack and various contributors: +- `Ashera Scout `_ - `Bogdan Popescu `_ - `Dirkjan Ochtman `_ - `Henrique Bastos `_ diff --git a/doc2dash/parsers/intersphinx.py b/doc2dash/parsers/intersphinx.py index 00b3eda..fd46258 100644 --- a/doc2dash/parsers/intersphinx.py +++ b/doc2dash/parsers/intersphinx.py @@ -100,6 +100,15 @@ def _inv_to_entries(inv): try: t = INV_TO_TYPE[type_key.split(":")[-1]] for el, data in iteritems(val): - yield ParserEntry(name=el, type=t, path=data[2]) + """ + Discard the anchors between head and tail to make it + compatible with situations that extra meta information encoded + """ + path_tuple = data[2].split("#") + if len(path_tuple) > 1: + path_str = "#".join((path_tuple[0], path_tuple[-1])) + else: + path_str = data[2] + yield ParserEntry(name=el, type=t, path=path_str) except KeyError: pass diff --git a/tests/parsers/intersphinx/test_intersphinx.py b/tests/parsers/intersphinx/test_intersphinx.py index 86c684f..4dc3863 100644 --- a/tests/parsers/intersphinx/test_intersphinx.py +++ b/tests/parsers/intersphinx/test_intersphinx.py @@ -39,11 +39,25 @@ def test_inv_to_entries(self): result = list( _inv_to_entries({"py:method": { u"some_method": (None, None, u"some_module.py", u"-"), + }, + "std:option": { + u"--destination": ( + u"doc2dash", + u"2.0", + u"index.html#document-usage#cmdoption--destination", + u"-" + ) }}) ) - assert [ParserEntry( + assert set([ParserEntry( name=u'some_method', type=u'Method', path=u'some_module.py' - )] == result + ), + ParserEntry( + name=u'--destination', + type=u'Option', + path=u'index.html#cmdoption--destination' + ) + ]) == set(result) class TestFindAndPatchEntry(object):