Add EnvironmentManager.get_updated_docs() to weaken the coupling env modules

This commit is contained in:
Takeshi KOMIYA 2017-01-10 13:52:51 +09:00
parent b2c76f44b6
commit 105951cdb2
4 changed files with 15 additions and 2 deletions

View File

@ -647,8 +647,9 @@ class BuildEnvironment(object):
def check_dependents(self, already):
# type: (Set[unicode]) -> Iterator[unicode]
to_rewrite = (self.toctree.assign_section_numbers() + # type: ignore
self.toctree.assign_figure_numbers()) # type: ignore
to_rewrite = []
for manager in itervalues(self.managers):
to_rewrite.extend(manager.get_updated_docs())
for docname in set(to_rewrite):
if docname not in already:
yield docname

View File

@ -48,3 +48,7 @@ class EnvironmentManager(object):
def process_doc(self, docname, doctree):
# type: (unicode, nodes.Node) -> None
raise NotImplementedError
def get_updated_docs(self):
# type: () -> List[unicode]
raise NotImplementedError

View File

@ -65,6 +65,10 @@ class IndexEntries(EnvironmentManager):
else:
entries.append(entry + (None,))
def get_updated_docs(self):
# type: () -> List[unicode]
return []
def create_index(self, builder, group_entries=True,
_fixre=re.compile(r'(.*) ([(][^()]*[)])')):
# type: (Builder, bool, Pattern) -> List[Tuple[unicode, List[Tuple[unicode, List[unicode]]]]] # NOQA

View File

@ -144,6 +144,10 @@ class Toctree(EnvironmentManager):
self.tocs[docname] = nodes.bullet_list('')
self.toc_num_entries[docname] = numentries[0]
def get_updated_docs(self):
# type: () -> List[unicode]
return self.assign_section_numbers() + self.assign_figure_numbers()
def note_toctree(self, docname, toctreenode):
# type: (unicode, addnodes.toctree) -> None
"""Note a TOC tree directive in a document and gather information about