gecko/tools/docs/mach_commands.py
Gregory Szorc 4f2fb895aa Bug 1176642 - Use absolute_import in mach_commands.py files; r=glandium
This removes ambiguity as to which modules are being imported, making
import slightly faster as Python doesn't need to test so many
directories for file presence.

All files should already be using absolute imports because mach command
modules aren't imported to the package they belong to: they instead
belong to the "mach" package. So relative imports shouldn't have been
used.
2015-06-21 17:39:09 -07:00

45 lines
1.3 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals
import os
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
from mozbuild.base import MachCommandBase
@CommandProvider
class Documentation(MachCommandBase):
"""Helps manage in-tree documentation."""
@Command('build-docs', category='build-dev',
description='Generate documentation for the tree.')
@CommandArgument('--format', default='html',
help='Documentation format to write.')
@CommandArgument('outdir', default='<DEFAULT>', nargs='?',
help='Where to write output.')
def build_docs(self, format=None, outdir=None):
self._activate_virtualenv()
self.virtualenv_manager.install_pip_package('sphinx_rtd_theme==0.1.6')
import sphinx
if outdir == '<DEFAULT>':
outdir = os.path.join(self.topobjdir, 'docs')
args = [
'sphinx',
'-b', format,
os.path.join(self.topsrcdir, 'tools', 'docs'),
os.path.join(outdir, format),
]
return sphinx.main(args)