Error highlighting

37 views
Skip to first unread message

Anton Akhmerov

unread,
Jun 11, 2019, 2:13:03 PM6/11/19
to sphinx-users
Hi everyone,

I have a basic question to which I unfortunately cannot find an answer neither in the documentation nor anywhere else on the web.

I would like to display some stderr in the built documentation, and for that I would like to highlight it similarly to jupyter:

Screenshot from 2019-06-11 20-10-11.png

What is the semanically correct way to achieve this result? Which nodes do I need to insert?

The closest I have found so far is an error admonition, but it seems logically unrelated.

Thank you in advance,
Anton

Stefano David

unread,
Jun 14, 2019, 5:50:32 AM6/14/19
to sphinx-users
Hi


On Tuesday, 11 June 2019 20:13:03 UTC+2, Anton Akhmerov wrote:
Hi everyone,

I have a basic question to which I unfortunately cannot find an answer neither in the documentation nor anywhere else on the web.

I would like to display some stderr in the built documentation, and for that I would like to highlight it similarly to jupyter:

Screenshot from 2019-06-11 20-10-11.png

What is the semanically correct way to achieve this result? Which nodes do I need to insert?
Have you tried adding your code in a  .. code-block:: <language> ? Something like

*****
.. code-block:: bash
   :emphasize-lines: 3

   print('hi', file=sys.stderr)

   hi
*****

HTH,
Stefano

Anton Akhmerov

unread,
Jun 14, 2019, 9:33:31 AM6/14/19
to sphinx-users
Hi Stefano,

Have you tried adding your code in a  .. code-block:: <language> ? Something like

*****
.. code-block:: bash
   :emphasize-lines: 3

   print('hi', file=sys.stderr)

   hi
*****

"emphasize-lines" is indeed very similar to what I want to achieve. Unfortunately it produces a yellow highlight (which roughly means "look here"). Instead I'd like to have a red highlight "something is wrong"; that's somewhat different. Do you know if it's possible to achieve such a red highlight?

Best,
Anton

Stefano David

unread,
Jun 18, 2019, 11:10:28 AM6/18/19
to sphinx-users
I think the only possibility is to modify the CSS for that: just fire up an inspector on the HTML output and check how is called the <div> corresponding to the highlighted zone, then modify it.

Hope this helps,
Stefano

Anton Akhmerov

unread,
Jun 18, 2019, 11:12:45 AM6/18/19
to sphinx...@googlegroups.com

I think the only possibility is to modify the CSS for that: just fire up an inspector on the HTML output and check how is called the <div> corresponding to the highlighted zone, then modify it.

Hope this helps,
Stefano

Got it; thanks. It's unfortunate there's no built-in tool for that.
Anton
 

--
You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sphinx-users/VMpg4d6i1GI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/60e6ffe7-a689-45d1-a243-b71aa0ab39ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages