Set up BuildEnvironment object.
(self, app: Sphinx)
| 256 | self.__dict__.update(state) |
| 257 | |
| 258 | def setup(self, app: Sphinx) -> None: |
| 259 | """Set up BuildEnvironment object.""" |
| 260 | if self.version and self.version != _get_env_version(app.extensions): |
| 261 | raise BuildEnvironmentError(__('build environment version not current')) |
| 262 | if self.srcdir and self.srcdir != app.srcdir: |
| 263 | raise BuildEnvironmentError(__('source directory has changed')) |
| 264 | |
| 265 | if self.project: |
| 266 | app.project.restore(self.project) |
| 267 | |
| 268 | self._app = app |
| 269 | self.doctreedir = app.doctreedir |
| 270 | self.events = app.events |
| 271 | self.srcdir = app.srcdir |
| 272 | self.project = app.project |
| 273 | self.version = _get_env_version(app.extensions) |
| 274 | |
| 275 | # initialise domains |
| 276 | if self.domains is None: |
| 277 | # if we are unpickling an environment, we need to recreate the domains |
| 278 | self.domains = _DomainsContainer._from_environment( |
| 279 | self, registry=app.registry |
| 280 | ) |
| 281 | # setup domains (must do after all initialization) |
| 282 | self.domains._setup() |
| 283 | |
| 284 | # Initialise config. |
| 285 | # The old config is self.config, restored from the pickled environment. |
| 286 | # The new config is app.config, always recreated from ``conf.py`` |
| 287 | self.config_status, self.config_status_extra = self._config_status( |
| 288 | old_config=self.config, |
| 289 | new_config=app.config, |
| 290 | verbosity=app.config.verbosity, |
| 291 | ) |
| 292 | self.config = app.config |
| 293 | |
| 294 | # initialize settings |
| 295 | self._update_settings(app.config) |
| 296 | |
| 297 | @property |
| 298 | def app(self) -> Sphinx: |
no test coverage detected