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