Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Sphinx code-block language to use for JSON

I am using Sphinx to document a web service. I would like to show a formatted JSON web response using the code-block directive, which Spinx does via Pygments, but JSON doesn't have a syntax highlighter in Pygments. What language do you suggest I specify instead? HTML? JavaScript?

.. code-block:: javascript

    {
      "name": "roger",
      "score": 100
    }
like image 316
JayhawksFan93 Avatar asked Nov 23 '10 17:11

JayhawksFan93


People also ask

Which is the correct format for writing JSON name value pair?

Data is represented in name/value pairs. Curly braces hold objects and each name is followed by ':'(colon), the name/value pairs are separated by , (comma). Square brackets hold arrays and values are separated by ,(comma).

What is Sphinx rst?

RST stands for ReStructured Text. It is the standard markup language used for documenting python packages. Sphinx is the Python package that generates an html website from RST files, and it is what we are using to generate this site.


1 Answers

I am using Sphinx 1.4.2 which includes a Pygments lexer called "json". This is available out-of-the-box by default. To use:

.. code-block:: json

    {
        "key": "value",
        "key2": "value2",
        ...
    }
like image 182
The Aelfinn Avatar answered Jan 01 '23 20:01

The Aelfinn