Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of the Sphinx highlight_language config option if code-block:: doesn't have an optional argument?

What is the point of the Sphinx highlight_language config option if code-block:: doesn't have an optional argument?

It says that it sets the default hightlight_language, but if every time that you specify code you need to state the language, why does it need the config option?

Am I doing something wrong?

Edit: From the logs when I remove the argument for codeblock.

C:\c\Sponge\SpongeDocs\source\plugin\scheduler.rst:25: ERROR: Error in "code-block" directive:
1 argument(s) required, 0 supplied.

.. code-block::

    taskBuilder.execute(new Runnable() {
        public void run() {
            logger.info("Yay! Schedulers!");
        }
    });
like image 994
Ryan Leach Avatar asked Jan 12 '16 09:01

Ryan Leach


2 Answers

Documentation is a little bit vague here. In fact ..code-block:: directive should only be used if you want to specify language explicitly for some reason. For default you should use a simple :: block:

Examples of Python source code or interactive sessions are represented using standard reST literal blocks. They are started by a :: at the end of the preceding paragraph and delimited by indentation.

(Source: http://www.sphinx-doc.org/en/stable/markup/code.html)

It will look like this:

::

    var hello = "Hello, World!";
    console.log(hello);
like image 66
kojo Avatar answered Nov 15 '22 20:11

kojo


When using the code-block:: directive, specifying the language is optional.

As explained in the documentation, the default language highlighting is for python. With setting the highlight_language, you can change this, e.g. to have c code highlighting when using a code-block:: without specifying a language.

like image 25
Timotheus.Kampik Avatar answered Nov 15 '22 19:11

Timotheus.Kampik