def read_build_config(self): """Read the active build config and add docs to this instance.""" # Reading the Sphinx variables doesn't require a full build context. # Only define the parts we need. class fakeconfig(object): def __init__(self, topsrcdir): self.topsrcdir = topsrcdir config = fakeconfig(self._topsrcdir) reader = BuildReader(config) for path, name, key, value in reader.find_sphinx_variables(): reldir = os.path.dirname(path) if name == 'SPHINX_TREES': assert key if key.startswith('/'): key = key[1:] else: key = os.path.join(reldir, key) self.add_tree(os.path.join(reldir, value), key) if name == 'SPHINX_PYTHON_PACKAGE_DIRS': self.add_python_package_dir(os.path.join(reldir, value))
def build_docs(self, format=None, outdir=None): self._activate_virtualenv() self.virtualenv_manager.install_pip_package('mdn-sphinx-theme==0.4') from moztreedocs import SphinxManager if outdir == '<DEFAULT>': outdir = os.path.join(self.topobjdir, 'docs') manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir, 'tools', 'docs'), outdir) # We don't care about GYP projects, so don't process them. This makes # scanning faster and may even prevent an exception. def remove_gyp_dirs(context): context['GYP_DIRS'][:] = [] reader = BuildReader(self.config_environment, sandbox_post_eval_cb=remove_gyp_dirs) for path, name, key, value in reader.find_sphinx_variables(): reldir = os.path.dirname(path) if name == 'SPHINX_TREES': assert key manager.add_tree(os.path.join(reldir, value), os.path.join(reldir, key)) if name == 'SPHINX_PYTHON_PACKAGE_DIRS': manager.add_python_package_dir(os.path.join(reldir, value)) return manager.generate_docs(format)
def read_build_config(docdir): """Read the active build config and return the relevant doc paths. The return value is cached so re-generating with the same docdir won't invoke the build system a second time.""" trees = {} python_package_dirs = set() is_main = docdir == MAIN_DOC_PATH relevant_mozbuild_path = None if is_main else docdir # Reading the Sphinx variables doesn't require a full build context. # Only define the parts we need. class fakeconfig(object): topsrcdir = build.topsrcdir reader = BuildReader(fakeconfig()) for path, name, key, value in reader.find_sphinx_variables( relevant_mozbuild_path): reldir = os.path.dirname(path) if name == 'SPHINX_TREES': # If we're building a subtree, only process that specific subtree. absdir = os.path.join(build.topsrcdir, reldir, value) if not is_main and absdir not in (docdir, MAIN_DOC_PATH): continue assert key if key.startswith('/'): key = key[1:] else: key = os.path.normpath(os.path.join(reldir, key)) if key in trees: raise Exception( '%s has already been registered as a destination.' % key) trees[key] = os.path.join(reldir, value) if name == 'SPHINX_PYTHON_PACKAGE_DIRS': python_package_dirs.add(os.path.join(reldir, value)) return trees, python_package_dirs
def build_docs(self, format=None, outdir=None): self._activate_virtualenv() self.virtualenv_manager.install_pip_package('sphinx_rtd_theme==0.1.6') from moztreedocs import SphinxManager if outdir == '<DEFAULT>': outdir = os.path.join(self.topobjdir, 'docs') manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir, 'tools', 'docs'), outdir) # We don't care about GYP projects, so don't process them. This makes # scanning faster and may even prevent an exception. def remove_gyp_dirs(context): context['GYP_DIRS'][:] = [] # Reading the Sphinx variables doesn't require a full build context. # Only define the parts we need. class fakeconfig(object): def __init__(self, topsrcdir): self.topsrcdir = topsrcdir config = fakeconfig(self.topsrcdir) reader = BuildReader(config) for path, name, key, value in reader.find_sphinx_variables(): reldir = os.path.dirname(path) if name == 'SPHINX_TREES': assert key manager.add_tree(os.path.join(reldir, value), os.path.join(reldir, key)) if name == 'SPHINX_PYTHON_PACKAGE_DIRS': manager.add_python_package_dir(os.path.join(reldir, value)) return manager.generate_docs(format)