Skip to content

Fix GH #54853: BUG: DeprecationWarning for frontend.OptionParser when building docs #54854

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ def _get_page_title(self, page):
Open the rst file `page` and extract its title.
"""
fname = os.path.join(SOURCE_PATH, f"{page}.rst")
option_parser = docutils.frontend.OptionParser(
components=(docutils.parsers.rst.Parser,)
doc = docutils.utils.new_document(
Copy link
Member

Choose a reason for hiding this comment

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

Can you use something like this instead? https://stackoverflow.com/a/75996218

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but my understanding from the docs is that this version allows customization through a configuration file, whereas the SO answer does not. So I'd lean on keeping it like it is, but I'm happy to change the PR if you'd prefer.

(This is assuming you're not talking about supporting docutils prior to 0.18. Otherwise let me know.)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I was referring to using get_default_settings. I would prefer using more "public" APIs from docutils rather then digging into docutils.core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as requested :)

"<doc>",
docutils.frontend.get_default_settings(docutils.parsers.rst.Parser),
)
doc = docutils.utils.new_document("<doc>", option_parser.get_default_values())
with open(fname, encoding="utf-8") as f:
data = f.read()

Expand Down