Cython syntax highlighting for Sphinx

36 views
Skip to first unread message

Jeroen Demeyer

unread,
Oct 10, 2010, 3:55:23 AM10/10/10
to sage-devel
Hello,

Does anybody know how to have syntax highlighting for Cython code in
Sage? Clearly the code exists, because the official Cython
documentation (see for example
http://docs.cython.org/src/tutorial/external.html) is properly syntax
highlighted. So either this is not included in Sage or it is but I
don't know how to enable it.

Thanks,
Jeroen.

Mike Hansen

unread,
Oct 10, 2010, 1:38:16 PM10/10/10
to sage-...@googlegroups.com

You can do

.. code-block:: cython

cdef i

See http://sphinx.pocoo.org/markup/code.html for more info.

--Mike

Jeroen Demeyer

unread,
Oct 10, 2010, 4:25:42 PM10/10/10
to sage-...@googlegroups.com
On 2010-10-10 19:38, Mike Hansen wrote:
> You can do
>
> .. code-block:: cython
>
> cdef i

That doesn't work for me with the version of Sphinx in sage-4.6.alpha3.
It just literally writes the text
".. code-block:: cython" in the output...

Message has been deleted

Jeroen Demeyer

unread,
Nov 18, 2010, 8:41:55 AM11/18/10
to sage-...@googlegroups.com, Robert Bradshaw
On 2010-10-11 08:40, Minh Nguyen wrote:
> This looks like we need to upgrade Sphinx (and possibly Pygments as
> well). This is now ticket #10118:
>
> http://trac.sagemath.org/sage_trac/ticket/10118

This doesn't actually solve the problem: Sphinx 1.0.4 still doesn't know
about Cython.

Robert: how does the Cython project generate its documentation?

Jeroen Demeyer

unread,
Nov 18, 2010, 8:53:45 AM11/18/10
to sage-...@googlegroups.com, Robert Bradshaw
On 2010-10-11 08:40, Minh Nguyen wrote:
> Hi Jeroen,

>
> On Mon, Oct 11, 2010 at 7:25 AM, Jeroen Demeyer <jdem...@cage.ugent.be> wrote:
>> That doesn't work for me with the version of Sphinx in sage-4.6.alpha3.
>> It just literally writes the text
>> ".. code-block:: cython" in the output...
>
> This looks like we need to upgrade Sphinx (and possibly Pygments as
> well).

Sorry, I was too quick. The syntax highlighting is done by Pygments (as
you suggested), Sphinx actually Pygments to do the highlighting.

So we need to upgrade Pygments (which is hopefully easy, since it's pure
Python without any patches), see #10290.

Jeroen.

Reply all
Reply to author
Forward
0 new messages