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

[events] move write-started from Builder.write to Builder.build method #12736

Closed

Conversation

chrisjsewell
Copy link
Member

This event was recently added in #12567,
but as pointed out in #12680 this may not fire for all builders, since write can be overriden.

I can't recall if there was any additional thinking as to its original placement,
but certainly with #12436, we can "guarantee" that it will be called for all builders when called in build.

@chrisjsewell chrisjsewell linked an issue Aug 5, 2024 that may be closed by this pull request
@chrisjsewell chrisjsewell requested a review from jfbu August 5, 2024 14:55
@picnixz
Copy link
Member

picnixz commented Aug 6, 2024

Yes, it's more logic to call it before the write(). However, could you perhaps say in the docs that it's being called before calling write() and thus an overriding of write() should not re-fire that event?

In other words, the write() hook should assume that weite-started has already been fired.

@AA-Turner
Copy link
Member

I moved it to .write( as it seems putting the cart before the horse to call it in .build(. Personally, I would close this PR and instead view a failure to emit write-started as a bug and violation of the 'consenting adults' principle (clearly we should document that builders should emit the event).

Is this the only such overidable event?

A

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Aug 6, 2024

I moved it to .write(

@AA-Turner 😢, urghh I don't want to moan here, we're all doing good work and mistakes happen, but...
I would urge you not to change people's PRs and merge them, without first asking for feedback from the author (particularly fellow maintainers):
it is not good etiquette, and leads to issues like this that could have been avoided.
I say this also because it is not the first time I've seen it occur, for example #12253

I was just about to integrate this into sphinx-needs, but can't really now, as it has been rendered somewhat useless for its original goal 😞

However, could you perhaps say in the docs that it's being called before calling write()

@picnixz now it is clear why, in https://www.sphinx-doc.org/en/master/extdev/event_callbacks.html, this is already how it is shown; as being called before write:

image

Personally, I would close this PR and instead view a failure to emit write-started as a bug and violation of the 'consenting adults' principle

But this is never how builders have been documented, and it's not really possible currently to enforce anything on builders in the write method, since it is allowed to be overridden
Plus, as per #12680, we now don't emit this event for half of the internal builders, let alone 3rd-party ones.

(obviously, this was part of the reason for #12436, to at least impose some "constraints" and understanding for developers as to what they can and can't do with builders)

Is this the only such overidable event?

Well, as per https://www.sphinx-doc.org/en/master/extdev/event_callbacks.html#builder-specific-events, there are certainly events that only occur for specific builders

@picnixz
Copy link
Member

picnixz commented Aug 12, 2024

My stance changes depending on whether #12767 is merged or not:

  • If Mark Builder.write() as final #12767 is merged, write-started should be left inside the write().
  • If this is not merged, I'd prefer having the write-started event just before the call to write(), otherwise extensions need to explicitly call it (and we need to explicitly add it to the subclasses).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latex builder doesn't emit the write-started event
4 participants