Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show Title, Examples and other custom properties too? #97

Open
pmeems opened this issue May 20, 2022 · 1 comment
Open

How to show Title, Examples and other custom properties too? #97

pmeems opened this issue May 20, 2022 · 1 comment

Comments

@pmeems
Copy link

pmeems commented May 20, 2022

We use docson to show referenced JSON in our JSON Schema documentation.
Here's an example: https://delta-datawarehouse.readthedocs.io/en/latest/explanation.html#unique-id-of-the-farmer
The title is used in the box header but not with the properties.

I also use examples which I would like to show. Here's an example of how we use examples: https://delta-datawarehouse.readthedocs.io/en/latest/explanation.html#start-production-year
And sometimes I also use $extended-description.

I would like to show:

  • Title
  • Property name
  • Type
  • Description
  • Extended description
  • Examples
  • Pattern

I tried adding <div class="signature-title">{{title this}}</div> to the box template but that results in an error.

Please advice.

@pmeems
Copy link
Author

pmeems commented May 20, 2022

I managed to get the title working after adding to docson.js:

    Handlebars.registerHelper('title', function(schema) {
        var value = schema.title;

        if( !value ) return "";
        var text = value;
        if(marked) {
            marked.setOptions({gfm: true, breaks: true})
            return new Handlebars.SafeString(marked(text));
        } else {
            return text;
        }
    });

And using <div class="signature-title">{{title this}}</div> in the box template.

Doing the same for the examples results in an error in the marked library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant