redhat-developer / redhat-developer/yaml-language-server
Add indent on json stringify of examples
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 352
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 11
Description
Hi, when doing examples if it is an object, or array and not a primitive type, the examples section isn't that useful, if a large object is shown, would it be possible to add indentation to the examples
I'd be happy to add it if it is something we want =D
probably something like this:
s.schema.examples.forEach((example) => {
markdownExamples.push(JSON.stringify(example, null, 4 / '\t'));
});
So instead of
```{"someObject": {"someProperty": "someValue"}}```
it would be
\```
{
"someObject": {
"someProperty": "someValue"
}
}
\```
The ` formatting was a bit messed up.
If we were more ambitious we could probably even output it as yaml instead, which is more fitting to the package name =D
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/languageservice/services/yamlHover.ts at the linked line where schema examples are converted with JSON.stringify. Review how object and array examples are added to the examples section, then verify that large non-primitive examples render with readable indentation while primitive examples remain appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100