forked from sphinx-doc/sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from sphinx.locale import __ | ||
from sphinx.util import logging | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Sequence | ||
from pathlib import Path | ||
from typing import Final | ||
|
||
LOGGER: Final[logging.SphinxLoggerAdapter] = logging.getLogger('sphinx.ext.apidoc') | ||
|
||
|
||
def _remove_old_files( | ||
written_files: Sequence[Path], destdir: Path, suffix: str | ||
) -> None: | ||
files_to_keep = frozenset(written_files) | ||
for existing in destdir.rglob(f'*.{suffix}'): | ||
if existing not in files_to_keep: | ||
try: | ||
existing.unlink() | ||
except OSError as exc: | ||
LOGGER.warning( | ||
__('Failed to remove %s: %s'), | ||
existing, | ||
exc.strerror, | ||
type='autodoc', | ||
) |