mirror of https://github.com/zulip/zulip.git
api_code_example: Use json instead of ujson; specify separators.
The Markdown extension that lives inside zerver/lib/bugdown/api_code_example.py previously used ujson. ujson's `dumps` function doesn't accept a `separators` argument, which means we have no control over how the JSON is pretty-printed. This resulted in JSON fixtures with no spaces after the colon, which looks unnecessarily convoluted. So now, we use the built-in `json` module to get around this. For further reading, this issue <https://github.com/esnme/ultrajson/issues/82> opened on ujson's repo explains why they are reluctant to support such formatting due to performance considerations.
This commit is contained in:
parent
e80609a3e9
commit
96036f07a3
|
@ -1,7 +1,7 @@
|
|||
import re
|
||||
import os
|
||||
import sys
|
||||
import ujson
|
||||
import json
|
||||
import inspect
|
||||
|
||||
from markdown.extensions import Extension
|
||||
|
@ -143,7 +143,8 @@ class APICodeExamplesPreprocessor(Preprocessor):
|
|||
else:
|
||||
fixture_dict = zerver.lib.api_test_helpers.FIXTURES[function]
|
||||
|
||||
fixture_json = ujson.dumps(fixture_dict, indent=4, sort_keys=True)
|
||||
fixture_json = json.dumps(fixture_dict, indent=4, sort_keys=True,
|
||||
separators=(',', ': '))
|
||||
|
||||
fixture.append('```')
|
||||
fixture.extend(fixture_json.splitlines())
|
||||
|
|
Loading…
Reference in New Issue