Open cderv opened 6 months ago
From @dragonstyle comments in #8396
I think we're not expecting the sidebar definition in the _sidebar.yml file to be an array- it should be an object (...)
I think the use of metadata-files must be dodging validation somehow... It would be ideal if that would also throw a validation error.
I think we have an open bug for this somewhere. This is pretty hard to do in general because this mixes validation and "yaml creation". It's the same bug as "we should validate _metadata.yml somehow", but the problem is that the validation of this file is dependent on the files that load it.
but the problem is that the validation of this file is dependent on the files that load it.
could there be a middle ground where only the schema type of content in the metadata-files
provided is check ?
This would have avoided providing an array instead of an object.
This would not be perfect, but if possible, this would be a first level to validate the file statically like we do a _quarto.yml
maybe?
Just idea - Best effort to improve user's experience.
could there be a middle ground where only the schema type of content in the metadata-files provided is check ? This would have avoided providing an array instead of an object.
Not really, because it's a similar problem to the one I alluded:
but the problem is that the validation of this file is dependent on the files that load it.
The resolution of metadata-files
happens after the YAML is loaded, in the same way that the merging of _metadata.yml
happens after the YAML document block is loaded.
In order to solve this problem, we would have to write a spec for the precise way and time in which validation happens. It would freeze the semantics of metadata in a way that I'm not ready to commit to yet. Maybe in a couple of years we could do that.
It's a really thorny problem.
I understand better now. Thanks.
So validation and error at rendering is not an easy problem.
In my mind, that leaves us with linters in IDE. Not dependent on us directly, but probably a little as we provide the information. This may be a wild thought, but if an IDE (like VSCODE with our extension, our RStudio IDE) has a way to mark some YAML as "this yaml should respect quarto config schema", it could be a solution to inform users of malformed YAML - even if quarto render
won't do anything because of what mentioned before. Linting information is already showing for _quarto.yml
so could be also working for other if IDE allows it. 🤷♂️
My last thought on this 😅
Wait--this is not true:
I think we're not expecting the sidebar definition in the _sidebar.yml file to be an array- it should be an object (...)
Here's an example from the quarto docs:
sidebar:
- id: tutorials
title: "Tutorials"
style: "docked"
background: light
collapse-level: 2
contents:
# navigation items
- id: howto
title: "How-To"
contents:
# navigation items
- id: fundamentals
title: "Fundamentals"
contents: :
# navigation items
- id: reference
title: "Reference"
contents:
# navigation items
edit: ah wait nevermind -- maybe that's referring to the expectation, based on what sidebar entry is in the _quarto.yml
(an object)
Discussed in https://github.com/quarto-dev/quarto-cli/discussions/8396