0

I am writing some sphinx documentation. Suppose classes Foo and Bar are in the documentation. Elsewhere I would like to say

A :class:`~.Foo` contains multiple :class:`~.Bar`s.

and get [Foo] to be linked and a link that looks like [Bar]s,

A [Foo] contains multiple [Bar]s.

but get a warning

WARNING: Inline interpreted text or phrase reference start-string without end-string.

and a failure to render / link. The rendered page looks like

A [Foo] contains multiple :class:`~.Bar`s.

instead.

How may I achieve an automatic link to a class + a suffix (like -s, -ly, -ing) but no space in between in rst/restructured text/sphinx?

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
evanb
  • 137
  • 6

1 Answers1

1

In reStructuredText you can escape a space before and after roles and backticks, then place other characters next to the role.

Try this:

A :class:`~.Foo` contains multiple :class:`~.Bar`\ s.

See a similar question and answer.

Another option is to use MyST which allows more flexible formatting without such obscure syntax.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57