Commit Graph

10 Commits

Author SHA1 Message Date
Chris Sewell
04bd0df100 👌 Improve external role warnings (and revert object fallback) (#12193)
The key issue this commit seeks to address, is that existing tools / documentation often lead users to mistakenly use object types and not role names, a classic example being `function` not `func`

Previously, the warning message for using e.g. `` external:function`target` `` (with `py` as the default domain), would be:

```
WARNING: role for external cross-reference not found: function
```

This gives no information to the user on how to fix the issue, even though there is actually quite an easy fix

This commit adds logic to create more specific / helpful warning messages, e.g.

```
WARNING: role for external cross-reference not found in domains 'py', 'std': 'function' (perhaps you meant one of: 'py:func', 'py:obj')
```

This goes through the same original logic but, if the role is not found, it will look if the role name is actually an available object type on the domain(s), and then suggest its related roles.

This commit also reverts #12133, which provided a (silent) fallback to auto convert an object type to a role name.
2024-03-25 14:39:51 +01:00
Chris Sewell
565d4104d5 👌 Handle external references pointing to object types (#12133)
This commit fixes the issue of `objects.inv` denoting object names, whilst the `external` role only allows for role names. 

As an example, take the `objects.inv` for the sphinx documentation, which contains:

```
py:function
    compile                  : usage/domains/python.html#compile
```

A user might understandably expect that they could reference this using `` :external:py:function:`compile` ``, but actually this would previously error with:

```
WARNING: role for external cross-reference not found: py:function
```

this is because, `function` is the object type, yet `external` expects the related role name `func`.

It should not be necessary for the user to know about this distinction,
so in this commit, we add logic, to first look if the name relates to a role name (as previous, to not be back-breaking) but, if not, then also look if the name relates to an object that has a known role and, if so, use that.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-19 13:42:50 +01:00
Jakob Lykke Andersen
c11b109d59 intersphinx role: :external+inv:**: instead of :external:inv+**: 2022-01-16 09:48:11 +01:00
Jakob Lykke Andersen
029d0e5b18 intersphinx role: new inventory parsing from role name 2022-01-16 09:48:06 +01:00
Jakob Lykke Andersen
ce5512e3af intersphinx role, implement warning scheme
and temporarily remove explicit inventories
2022-01-16 09:48:06 +01:00
Jakob Lykke Andersen
184fd6a4aa intersphinx role, update based on merged refactoring 2022-01-16 09:48:06 +01:00
Jakob Lykke Andersen
36c6eafdf1 intersphinx: explicitly parse out inventory specification 2022-01-16 09:48:06 +01:00
Jakob Lykke Andersen
69fa5260fc intersphinx role: rename to 'external' 2022-01-16 09:47:54 +01:00
Jakob Lykke Andersen
8605644e83 intersphinx: more role testing 2022-01-16 09:47:54 +01:00
Takeshi KOMIYA
35dcc60a7c intersphinx: Add :intersphinx:***: role 2022-01-16 09:47:53 +01:00