Skip to content
Open
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
10 changes: 9 additions & 1 deletion sphinxext/rediraffe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sphinx.errors import ExtensionError
from sphinx.util import logging
from sphinx.util.console import green, red, yellow # pylint: disable=no-name-in-module
from sphinx.util.matching import Matcher

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -179,6 +180,7 @@ def build_redirects(app: Sphinx, exception: Union[Exception, None]) -> None:
graph_edges = rediraffe_redirects
elif isinstance(rediraffe_redirects, str):
# filename

path = Path(app.srcdir) / rediraffe_redirects
if not path.is_file():
logger.error(
Expand All @@ -188,7 +190,6 @@ def build_redirects(app: Sphinx, exception: Union[Exception, None]) -> None:
)
app.statuscode = 1
return

try:
graph_edges = create_graph(path)
except ExtensionError as e:
Expand Down Expand Up @@ -295,6 +296,7 @@ def init(self) -> None:

source_suffixes = set(self.app.config.source_suffix)
src_path = Path(self.app.srcdir)
excluded = Matcher(self.app.config.exclude_patterns)

rediraffe_redirects = self.app.config.rediraffe_redirects
redirects_path = None
Expand Down Expand Up @@ -374,6 +376,8 @@ def abs_path_in_src_dir_w_src_suffix(filename: str) -> Union[Path, None]:
deleted_files = list(filter(lambda x: x != None, deleted_files))

for deleted_file in deleted_files:
if excluded(str(deleted_file)):
continue
if deleted_file in absolute_redirects:
logger.info(
f"deleted file {deleted_file} redirects to {absolute_redirects[deleted_file]}."
Expand All @@ -387,6 +391,10 @@ def abs_path_in_src_dir_w_src_suffix(filename: str) -> Union[Path, None]:
for renamed_file in rename_hints:
hint_to, perc = rename_hints[renamed_file]


if excluded(str(renamed_file)):
continue

if renamed_file in absolute_redirects:
logger.info(
f"renamed file {renamed_file} redirects to {absolute_redirects[renamed_file]}."
Expand Down
Loading