Use with Jupyter Notebook

Use with Jupyter Notebook#

In a Jupyter Notebook, with dargs.notebook.JSON(), one can render an JSON string with an Argument.

from __future__ import annotations

from dargs.notebook import JSON
from dargs.sphinx import _test_argument

jstr = """
{
    "test_argument": "test1",
    "test_list": [
        1,
        2,
        3
    ],
    "test_variant": "test_variant_argument",
    "test_repeat_list": [
        {"test_repeat_item": false},
        {"test_repeat_item": true}
    ],
    "test_repeat_dict": {
        "test1": {"test_repeat_item": false},
        "test2": {"test_repeat_item": true}
    },
    "_comment": "This is an example data"
}
"""
JSON(jstr, _test_argument())
{
  "test_argument"test_argument:
type: str
This argument/variant is only used to test.
: "test1",
  "test_list"test_list:
type: typing.List[int], optional
: [
    1,
    2,
    3
  ],
  "test_variant"test_variant:
type: str
This argument/variant is only used to test.
: "test_variant_argument",
  "test_repeat_list"test_repeat_list:
type: list
This argument/variant is only used to test.
: [
    {
      "test_repeat_item"test_repeat_item:
type: bool
This argument/variant is only used to test.
: false
    },
    {
      "test_repeat_item"test_repeat_item:
type: bool
This argument/variant is only used to test.
: true
    }
  ],
  "test_repeat_dict"test_repeat_dict:
type: dict
This argument/variant is only used to test.
: {
    {
      "test_repeat_item"test_repeat_item:
type: bool
This argument/variant is only used to test.
: false
    },
    {
      "test_repeat_item"test_repeat_item:
type: bool
This argument/variant is only used to test.
: true
    }
  },
  "_comment": "This is an example data"
}

When the monse stays on an argument key, the documentation of this argument will pop up.