Closed peterw-ibm closed 4 years ago
please provide your setup .
Also please be very aware that the json files are to provide variables for use within a template. NOT to provide the json file as content for display.
you would be better off specifying a yaml file and then having a variable for your json content
my_vars.yaml
my_variables:
name: blah
example_json: |-
{"name": "bob"}
this is basically an untested suggestion as your particular use-case was not in the scope when i originally created this. But would be cool to support
but if you are documenting apis you should really consider using something like readme.io and or swagger-ui or redoc which les you specify an openapi spec that you can inline comment and document
Hope this helps.
folder setup:
-- mkdocs.yml ---------------------------- site_name: Test markdownextradata booleans remote_branch: gh-pages remote_name: origin docs_dir: docs markdown_extensions:
-- index.md ---------------------
-- test.json ------------------------------------- { "some_string": "hello", "bool_false": false, "bool_true": true }
-- Browser console ---------------------------------- ReferenceError: False is not defined127.0.0.1:8000:66:41
-- Browser debugger --------------------------------
Yep, as noted in my previous comment; the purpose of this plugin is to provide variables to be used in your templates; not json strings "as" variables.
try the previously mentioned possiblity
my_variables:
name: blah
example_json: |-
{"name": "bob"}
that "might" work. but currently this is a feature thats out of scope if not; if I get some time I may fix it but right now its OOS sorry. But feel free to make a PR.
So as promised (because im a sucker at 23:21) https://pypi.org/project/mkdocs-markdownextradata-plugin/0.1.5/
I have proven that the suggestion above works
you can see the test here: https://github.com/rosscdh/mkdocs-markdownextradata-plugin/blob/master/test/test_basic.py#L28
When injecting a json file with a json boolean (true, false), in the html javascript this boolean shows up as a python boolean (True, False), causing javscript to fail.