mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Clear record_dependencies
for each document (#10855)
This commit is contained in:
parent
73a1ee4560
commit
8db24515ea
@ -10,6 +10,7 @@ from typing import (TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.nodes import Node
|
||||
from docutils.utils import DependencyList
|
||||
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
||||
@ -490,6 +491,9 @@ class Builder:
|
||||
filename = self.env.doc2path(docname)
|
||||
filetype = get_filetype(self.app.config.source_suffix, filename)
|
||||
publisher = self.app.registry.get_publisher(self.app, filetype)
|
||||
# record_dependencies is mutable even though it is in settings,
|
||||
# explicitly re-initialise for each document
|
||||
publisher.settings.record_dependencies = DependencyList()
|
||||
with sphinx_domains(self.env), rst.default_role(docname, self.config.default_role):
|
||||
# set up error_handler for the target document
|
||||
codecs.register_error('sphinx', UnicodeDecodeErrorHandler(docname)) # type: ignore
|
||||
|
4
tests/roots/test-environment-record-dependencies/api.rst
Normal file
4
tests/roots/test-environment-record-dependencies/api.rst
Normal file
@ -0,0 +1,4 @@
|
||||
API
|
||||
===
|
||||
|
||||
.. automodule:: example_module
|
5
tests/roots/test-environment-record-dependencies/conf.py
Normal file
5
tests/roots/test-environment-record-dependencies/conf.py
Normal file
@ -0,0 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
extensions = ['sphinx.ext.autodoc']
|
@ -0,0 +1,2 @@
|
||||
def example_function():
|
||||
return 42
|
@ -0,0 +1,3 @@
|
||||
.. toctree::
|
||||
|
||||
api
|
10
tests/test_environment_record_dependencies.py
Normal file
10
tests/test_environment_record_dependencies.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""Tests for ``record_dependencies``."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='environment-record-dependencies')
|
||||
def test_record_dependencies_cleared(app):
|
||||
app.builder.read()
|
||||
assert app.env.dependencies['index'] == set()
|
||||
assert app.env.dependencies['api'] == {'example_module.py'}
|
Loading…
Reference in New Issue
Block a user