Mercurial > libervia-website
view tasks/task_generate_doc.py @ 10:0e9e97777fe0
doc: `-` in doc name is replace by `/`:
this is needed for Cagou which is deskop/mobile frontend.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 23 Apr 2021 11:04:23 +0200 |
parents | b5fc67c97c50 |
children | a24d362796be |
line wrap: on
line source
#!/ur/bin/env python3 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.getConfig("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.getConfig("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 sphinx = self.findCommand('sphinx-build') # we first generate the sub documentations for name, sub_doc_path in list(self.sub_docs.items()): sub_dir = regex.pathEscape(name or '') build_path = os.path.join(self.build_path, 'doc', sub_dir) await self.runCommand(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') await self.runCommand(sphinx, self.doc_path, build_path) log.info(_("documentation has been generated"))