Skip to content

Commit

Permalink
Combine 'compile_xxx' and 'build_xxx' functions
Browse files Browse the repository at this point in the history
These are only called from the one location and we already use 'build'
to do both building and writing. Given that we intend to simplify the
handling of the 'filenames' argument, this makes our lives there much
easier.

Signed-off-by: Stephen Finucane <stephen@that.guru>
  • Loading branch information
stephenfin authored and AA-Turner committed Sep 26, 2022
1 parent 6adbb00 commit 9ab21ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 0 additions & 3 deletions sphinx/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,10 @@ def build(self, force_all: bool = False, filenames: Optional[List[str]] = None)
self.phase = BuildPhase.READING
try:
if force_all:
self.builder.compile_all_catalogs()
self.builder.build_all()
elif filenames:
self.builder.compile_specific_catalogs(filenames)
self.builder.build_specific(filenames)
else:
self.builder.compile_update_catalogs()
self.builder.build_update()

self.events.emit('build-finished', None)
Expand Down
7 changes: 7 additions & 0 deletions sphinx/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def to_domain(fpath: str) -> Optional[str]:
message = __('targets for %d po files that are specified') % len(catalogs)
self.compile_catalogs(catalogs, message)

# TODO(stephenfin): This would make more sense as 'compile_outdated_catalogs'
def compile_update_catalogs(self) -> None:
repo = CatalogRepository(self.srcdir, self.config.locale_dirs,
self.config.language, self.config.source_encoding)
Expand All @@ -263,6 +264,8 @@ def compile_update_catalogs(self) -> None:

def build_all(self) -> None:
"""Build all source files."""
self.compile_all_catalogs()

self.build(None, summary=__('all source files'), method='all')

def build_specific(self, filenames: List[str]) -> None:
Expand Down Expand Up @@ -290,11 +293,15 @@ def build_specific(self, filenames: List[str]) -> None:

docnames.append(docname)

self.compile_specific_catalogs(filenames)

self.build(docnames, method='specific',
summary=__('%d source files given on command line') % len(docnames))

def build_update(self) -> None:
"""Only rebuild what was changed or added since last build."""
self.compile_update_catalogs()

to_build = self.get_outdated_docs()
if isinstance(to_build, str):
self.build(['__all__'], to_build)
Expand Down

0 comments on commit 9ab21ce

Please sign in to comment.