I've not found any useful information how to do it quickly. So here is my way:
- I've found custom pygments lexer which support JSON: pygments-json . I will be part of pygments soon
- It wasn't clear to me how to add custom pygments lexer to sphinx, my google-fu isn't good today
- A bit more googling gave me Sphinx Extensions API , especially add_lexer method of Sphinx instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(sphinx): | |
from pygson.json_lexer import JSONLexer | |
sphinx.add_lexer("json", JSONLexer()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sys.path.insert(0, os.path.join(os.path.abspath('.'), "ext")) |
pip install pygments-json
and use
.. code-block:: json
Nice and smooth:
