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

Mark Builder.write() as final #12767

Merged
merged 11 commits into from
Oct 10, 2024
Merged

Conversation

AA-Turner
Copy link
Member

Resolves #12736, #12680.

We introduce a new method, Builder.write_documents() to oversee writing docnames, in-between Builder.write() and Builder.write_doc(). Builder.write() is then marked as final, and existing users of .write() are migrated to the new function.

An alternative design would be to introduce a new method in-between Builder.build() and Builder.write(), effectively renaming write_documents in this PR to write and write to a new name. That comes with risks, though, as if copying assets and preparing writing is not idempotent, it will not be backwards compatible.

The current design is backwards compatible as users overriding Builder.write() will observe no runtime failures, but will recieve new static typing failures. The migration route is to use Builder.write_documents().

A

@chrisjsewell
Copy link
Member

Thanks for the review request @AA-Turner looks interesting 😄 hopefully will be able to have a look within the next few days

sphinx/builders/__init__.py Show resolved Hide resolved
sphinx/builders/__init__.py Outdated Show resolved Hide resolved
sphinx/builders/html/__init__.py Outdated Show resolved Hide resolved
sphinx/builders/texinfo.py Show resolved Hide resolved
sphinx/ext/doctest.py Outdated Show resolved Hide resolved
@AA-Turner
Copy link
Member Author

Friendly ping @chrisjsewell -- interested in your thoughts on this!

A

@chrisjsewell
Copy link
Member

Friendly ping @chrisjsewell -- interested in your thoughts on this!

Sorry for the delay, I got a bit side-tracked with other things 🫣
Hope to give this a proper look over the weekend or Monday 😅

@AA-Turner
Copy link
Member Author

Friendly ping again @chrisjsewell if you have any time. Sorry I've let this languish for a fortnight, meant to comment earlier!

A

@AA-Turner
Copy link
Member Author

October ping @chrisjsewell

A

@AA-Turner AA-Turner mentioned this pull request Oct 6, 2024
@AA-Turner AA-Turner added this to the 8.1.0 milestone Oct 7, 2024
# Conflicts:
#	CHANGES.rst
#	sphinx/builders/__init__.py
#	sphinx/builders/changes.py
#	sphinx/builders/html/__init__.py
@chrisjsewell
Copy link
Member

October ping @chrisjsewell

Hey @AA-Turner sorry let me have a quick look over this in the next hour, before you merge 😄

@AA-Turner
Copy link
Member Author

Thanks Chris -- I was going to write to you to ask if this should be left out of 8.1, so if you have time now to review that's tremendous.

A

@chrisjsewell
Copy link
Member

Thanks Chris -- I was going to write to you to ask if this should be left out of 8.1, so if you have time now to review that's tremendous.

A

yep, just about finished a big release for sphinx-needs that diverted my attention 😅, which this certainly has a bearing on this useblocks/sphinx-needs#1326

Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

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

Just some nitpicks, but yeh I think good in principle cheers

sphinx/builders/__init__.py Show resolved Hide resolved
doc/_static/diagrams/sphinx_build_flow.dot Show resolved Hide resolved
doc/extdev/builderapi.rst Outdated Show resolved Hide resolved
doc/extdev/builderapi.rst Show resolved Hide resolved
@chrisjsewell
Copy link
Member

chrisjsewell commented Oct 10, 2024

Oh one other thing: should we make Builder an https://docs.python.org/3/library/abc.html#abc.ABC class, with @abstractmethod rather than using raise NotImplementedError?

# Conflicts:
#	CHANGES.rst
@AA-Turner AA-Turner merged commit d135d2e into sphinx-doc:master Oct 10, 2024
23 checks passed
@AA-Turner AA-Turner deleted the build-write branch October 10, 2024 14:59
jdknight added a commit to sphinx-contrib/confluencebuilder that referenced this pull request Oct 12, 2024
Sphinx's builder implementation has added a final hint on the `write`
call and introduced a `write_documents` as a more appropriate hook for
processing documents [1]. This commit updates `SingleConfluenceBuilder`
to no longer use `write`, except for supporting legacy versions of
Sphinx that this extension still supports.

[1]: sphinx-doc/sphinx#12767

Signed-off-by: James Knight <james.d.knight@live.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants