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

feat(Builder): Ignore unknown quartodoc options #371

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gadenbuie
Copy link
Contributor

Rather than throwing an error to allow for backwards-compatible future expansion of quartodoc options.

In #370 I noticed that adding a new quartodoc option would make the _quarto.yml file automatically incompatible with older versions of quartodoc. I think it's reasonable to ignore extra options with a warning.

Rather than throwing an error to allow for backwards-compatible
future expansion of quartodoc options.
@machow
Copy link
Owner

machow commented Oct 9, 2024

If we add an option to quartodoc, and use it in _quarto.yml -- wouldn't this make it incompatible with previous versions? (Since they won't use the option, they'll produce a different behavior). I might be thinking through this wrong, is there a case you had in mind?

It seems like in the sidebar_options case, it's unlikely you'd set the option and want it not to do anything (but I'm likely not thinking of a situation).

@gadenbuie
Copy link
Contributor Author

Yeah I guess I don't have a strong reason why you'd need quartodoc not to throw with an unknown option.

Personally, with loosely structured data (like YAML) in artifacts that live longer than package updates, I personally prefer avoiding halting everything unless it's absolutely required. So in this case, I'd rather quartodoc let me know that there's an unused keyword but not halt rendering. That said, I'm realizing now that the halting happens with quartodoc build and not with quarto render, which is an important difference and I'm back to thinking it's okay to halt.

I do think the error message could be more useful, though. Here's what I get if I add an extra item in to the quartodoc section:

> quartodoc build
# ... stack trace ...
TypeError: __init__() got an unexpected keyword argument 'sidebar_options'
make: *** [py-docs] Error 1

I updated this PR to throw instead of warn, here's an example:

import yaml
from quartodoc import Builder

cfg = yaml.safe_load(
    """
    quartodoc:
      package: quartodoc
      this_is_not_a_real_option: true
      options:
        members: [a_func, a_attr]
      sections:
        - contents: [quartodoc.tests.example]
    """
    )

Builder.from_quarto_config(cfg)
ValueError: Unknown quartodoc option: 'this_is_not_a_real_option'. Please see
<https://machow.github.io/quartodoc/get-started/basic-docs.html> for
quartodoc site configuration options.

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

Successfully merging this pull request may close these issues.

2 participants