Add the ability to define terms that are never word-broken
Is your feature request related to a problem? Please describe.
The problem is in documenting C++ code, what sometimes happens is you encounter something like:
/*some long text */ in C+
+ do this:
It would be nice if C++ did not wrap on the individual + characters, e.g.:
/*some long text */ in
C++ do this:
See also: https://superuser.com/questions/1841412/preventing-word-break-in-markdown-and-rst
Describe the solution you'd like I think the ideal is to add a set in the configuration of "project terms" both for searching purposes and line wrap purposes, so that Sphinx would understand these special technical words that contain symbols (that should not be wrapped).
Describe alternatives you've considered
A "don't break words" setting could also work. Presumably there's a reason why this is not done though.
This occurs within normal reST text, is that right? E.g. a normal paragraph containing the text C++ might put the break between the two + characters.
Forgive my lack of knowledge about the project structure; but I'd assume reStructuredText is just the markup specification and maybe parser. The decision to word break or not is ultimately down to the format that is produced (which seems squarely in Sphinx's ballpark).
Yes, it sounds like a markup-agnostic problem that needs to be handled at the Sphinx level. To rephrase my original question: can you provide an example that reproduces the problem?
Sure, run:
sphinx-quickstart
Then replace the contents of index.rst with:
.. foo-bar documentation master file, created by
sphinx-quickstart on Wed Dec 17 18:41:50 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
foo-bar documentation
=====================
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim C++, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
.. toctree::
:maxdepth: 2
:caption: Contents:
run:
make dirhtml
and open the produced file; you'll see something like this: