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

[apidoc] Add --remove-old option #12448

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Jun 20, 2024

A common "gotcha" of re-running sphinx-apidoc, is that if the modules API changes it will not remove old files, leading to build errors for files not in a toctree

Here we introduce a --remove-old option to remove these files.

Note, a key detail here is that we don't want to simply clear the directory before running sphinx-apidoc,
since this would lead to all files having a new mtime,
and then sphinx-build would rebuild all of them even if they have not changed.
So we must first collect the list of all correct files, then remove any not in the list.

The PR also improves some typing of the code and replace os.path by pathlib.Path in most instances


FYI, after this I intend to do the same for sphinx-autogen

A common "gotcha" of re-running `sphinx-apidoc`, is that if the modules API changes it will not remove old files, leading to build errors.

Here we introduce a `-r/----remove-old` option,
to remove these files.

Note, a key detail here is that we don't want to simply clear the directory, before running `sphinx-apidoc`,
since this would lead to all files having a new `mtime`,
and so `sphinx-build` would rebuild all of them,
even if they have not changed.
@chrisjsewell chrisjsewell requested a review from picnixz June 20, 2024 10:26
@chrisjsewell chrisjsewell requested a review from picnixz June 20, 2024 11:03
@chrisjsewell chrisjsewell merged commit d7e1bfe into sphinx-doc:master Jun 20, 2024
23 checks passed
@chrisjsewell chrisjsewell deleted the improve-apidoc branch June 20, 2024 11:12
@AA-Turner AA-Turner added this to the 7.4.0 milestone Jul 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants