Mercurial > libervia-website
view tasks/task_generate_doc.py @ 24:e4002775d750
doc: log path of generated doc
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 22 May 2023 09:13:02 +0200 |
parents | 5fd933e238bb |
children | e7c7327f9f25 |
line wrap: on
line source
#!/ur/bin/env python3 import sys import os.path from sat.core.i18n import _ from sat.core.log import getLogger from sat.tools.common import regex from libervia.server.tasks import task log = getLogger(__name__) class Task(task.Task): DOC_DIRS_DEFAULT = ('doc', 'docs') def prepare(self): to_watch = set() # root documentation self.doc_path = self.config_get("doc_path") if self.doc_path is not None: to_watch.add(self.doc_path) # sub docs will be generated before the root documentation self.sub_docs = self.config_get("sub_docs_dict", value_type="path") if self.sub_docs is not None: for d in list(self.sub_docs.values()): to_watch.add(d) self.WATCH_DIRS = list(to_watch) async def start(self): if self.doc_path is None: # we check if there is documentation inside the site for dirname in self.DOC_DIRS_DEFAULT: path = os.path.join(self.site_path, dirname) conf_file = os.path.join(path, 'conf.py') if os.path.isdir(path) and os.path.exists(conf_file): self.doc_path = path break if self.doc_path is None and self.sub_docs is None: log.info("No documentation found for {site_name}, skipping".format( site_name = self.site_name)) return # we first generate the sub documentations for name, sub_doc_path in list(self.sub_docs.items()): sub_dir = regex.path_escape(name or '') build_path = os.path.join(self.build_path, 'doc', sub_dir) log.info(f"generating doc for {sub_doc_path}") await self.runCommand( sys.executable, "-m", "sphinx", sub_doc_path, build_path, ) # then the root one if self.doc_path is not None: build_path = os.path.join(self.build_path, 'doc') log.info(f"generating doc for {self.doc_path}") await self.runCommand( sys.executable, "-m", "sphinx", self.doc_path, build_path, ) log.info(_("documentation has been generated"))