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

Ignore unknown directive options rather than aborting #199

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

Conversation

terencehonles
Copy link

This is the same as my PR github/markup#1452 and it may make sense to incorporate other changes from GitHub's rST processing.

@terencehonles
Copy link
Author

I didn't look at the code too closely, but it may make sense to see if these can surfaced as warnings which would still fail with twine check --strict but would not prevent the rST from rendering. I had made the change on GitHub since it silently would drop documentation examples and it appears that's the same for PyPI, but since twine check and possibly others consume this library the unknown options could possibly still be passed up without blowing up.

@terencehonles
Copy link
Author

@di not sure if you have any input on this, sorry to bother if you're the wrong person to ask.

Copy link
Member

@miketheman miketheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing older PRs, and took some time to discover some history and docutils - good learning on my part!

A few notes inline, using Conventional Comments style.

In general, it needs a rebase against current main since we added type hints there's a conflict.

python-version: "3.x"
python-version: "3.6"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: ‏remove this from the changeset, as the CI step for linting uses latest intentionally. Supported versions of Python are installed and tested against in the test job.
Also support for Python 3.6 was dropped from this library in #236

return options


utils.extract_extension_options = extract_extension_options
Copy link
Member

@miketheman miketheman Jul 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: ‏ I can't shake the feeling that this override is "wrong", despite it being completely valid and works. I spent some time trying to find other hooks in docutils to provide an option, a setting, or something to prevent needing to completely override a utility class that is used during rendering, but didn't find anything satisfying.

It works now, but if docutils ever changes the function, would we ever know?

Comment on lines +40 to +43
# silently drop unknown options as long as they are not duplicates
if convertor is None:
dropped.add(name)
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: ‏If I'm reading this correctly, this would drop any unknown options, not only the one surfaced as the code-block caption, correct?

Does this increase the possibility of errors being introduced for other known options? For example, if I mistyped the :header: option to :headers:, I get no warning/error due to this change, and the headers will be missing from the rendered output.

Would it be better to provide this function a specific list of known options we want to skip and thus keep the scope of the override narrow, at least until doctuils implements caption for code-block?

@miketheman
Copy link
Member

Related to #160

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