tools/docs/mach_commands.py

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
     5 from __future__ import unicode_literals
     7 import os
     9 from mach.decorators import (
    10     CommandArgument,
    11     CommandProvider,
    12     Command,
    13 )
    15 from mozbuild.base import MachCommandBase
    16 from mozbuild.frontend.reader import BuildReader
    19 @CommandProvider
    20 class Documentation(MachCommandBase):
    21     """Helps manage in-tree documentation."""
    23     @Command('build-docs', category='build-dev',
    24         description='Generate documentation for the tree.')
    25     @CommandArgument('--format', default='html',
    26         help='Documentation format to write.')
    27     @CommandArgument('outdir', default='<DEFAULT>', nargs='?',
    28         help='Where to write output.')
    29     def build_docs(self, format=None, outdir=None):
    30         self._activate_virtualenv()
    31         self.virtualenv_manager.install_pip_package('mdn-sphinx-theme==0.4')
    33         from moztreedocs import SphinxManager
    35         if outdir == '<DEFAULT>':
    36             outdir = os.path.join(self.topobjdir, 'docs')
    38         manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir,
    39             'tools', 'docs'), outdir)
    41         # We don't care about GYP projects, so don't process them. This makes
    42         # scanning faster and may even prevent an exception.
    43         def remove_gyp_dirs(sandbox):
    44             sandbox['GYP_DIRS'][:] = []
    46         reader = BuildReader(self.config_environment,
    47             sandbox_post_eval_cb=remove_gyp_dirs)
    49         for sandbox in reader.walk_topsrcdir():
    50             for dest_dir, source_dir in sandbox['SPHINX_TREES'].items():
    51                 manager.add_tree(os.path.join(sandbox['RELATIVEDIR'],
    52                     source_dir), dest_dir)
    54             for entry in sandbox['SPHINX_PYTHON_PACKAGE_DIRS']:
    55                 manager.add_python_package_dir(os.path.join(sandbox['RELATIVEDIR'],
    56                     entry))
    58         return manager.generate_docs(format)

mercurial