如果 code-block:: 没有可选参数,Sphinx highlight_language 配置选项有什么意义?

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

如果 code-block:: 没有可选参数,Sphinx highlight_language 配置选项有什么意义?

它说它设置了默认值hightlight_language,但是如果每次指定代码都需要说明语言,为什么它需要配置选项?

我是不是做错了什么?

编辑: 从日志中删除代码块的参数。

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!");
        }
    });

使用 code-block:: 指令时,指定语言是可选的。

documentation 中所述,默认语言突出显示适用于 python。通过设置 highlight_language,您可以更改它,例如在未指定语言的情况下使用 code-block:: 时突出显示 C 代码。

这里的文档有点模糊。事实上 ..code-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.

(来源:http://www.sphinx-doc.org/en/stable/markup/code.html

它看起来像这样:

::

    var hello = "Hello, World!";
    console.log(hello);