author | Andrew Halberstadt <ahalberstadt@mozilla.com> |
Wed, 18 Apr 2018 12:17:44 -0400 | |
changeset 417794 | 3783bfd78a0fa374c1a5984b54a20f399709a1c9 |
parent 417793 | bb3895af484da4eea6fe2436e126b4f53ab1fd87 |
child 417795 | 50bb4134a2e45dd02d44a0425116d0ef8c613f14 |
push id | 33980 |
push user | ebalazs@mozilla.com |
push date | Fri, 11 May 2018 09:35:12 +0000 |
treeherder | mozilla-central@8e9a4a323f0c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mshal |
bugs | 1454640 |
milestone | 62.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/tools/docs/mach_commands.py +++ b/tools/docs/mach_commands.py @@ -50,19 +50,19 @@ class Documentation(MachCommandBase): which.which('jsdoc') except which.WhichError: return die('jsdoc not found - please install from npm.') self._activate_virtualenv() self.virtualenv_manager.install_pip_requirements( os.path.join(here, 'requirements.txt'), quiet=True) - import moztreedocs import webbrowser from livereload import Server + from moztreedocs.package import create_tarball outdir = outdir or os.path.join(self.topobjdir, 'docs') format_outdir = os.path.join(outdir, fmt) path = path or os.path.join(self.topsrcdir, 'tools') path = os.path.normpath(os.path.abspath(path)) docdir = self._find_doc_dir(path) @@ -79,17 +79,17 @@ class Documentation(MachCommandBase): return die('failed to generate documentation:\n' '%s: sphinx return code %d' % (path, result)) else: print('\nGenerated documentation:\n%s' % savedir) if archive: archive_path = os.path.join(outdir, '%s.tar.gz' % props['project']) - moztreedocs.create_tarball(archive_path, savedir) + create_tarball(archive_path, savedir) print('Archived to %s' % archive_path) if upload: self._s3_upload(savedir, props['project'], props['version']) if not serve: index_path = os.path.join(savedir, 'index.html') if auto_open and os.path.isfile(index_path): @@ -142,17 +142,17 @@ class Documentation(MachCommandBase): for d in search_dirs: p = os.path.join(path, d) if os.path.isfile(os.path.join(p, 'conf.py')): return p def _s3_upload(self, root, project, version=None): self.virtualenv_manager.install_pip_package('boto3==1.4.4') - from moztreedocs import distribution_files + from moztreedocs.package import distribution_files from moztreedocs.upload import s3_upload # Files are uploaded to multiple locations: # # <project>/latest # <project>/<version> # # This allows multiple projects and versions to be stored in the
--- a/tools/docs/moztreedocs/__init__.py +++ b/tools/docs/moztreedocs/__init__.py @@ -2,17 +2,16 @@ # 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 unicode_literals import os from mozbuild.frontend.reader import BuildReader -from mozpack.archive import create_tar_gz_from_files from mozpack.copier import FileCopier from mozpack.files import FileFinder from mozpack.manifests import InstallManifest import sphinx import sphinx.apidoc @@ -123,28 +122,8 @@ class SphinxManager(object): packages = [os.path.basename(p) for p in self._python_package_dirs] packages = ['python/%s' % p for p in packages] packages = '\n '.join(sorted(packages)) data = data.format(indexes=indexes, python_packages=packages) with open(os.path.join(self._docs_dir, 'index.rst'), 'wb') as fh: fh.write(data) - - -def distribution_files(root): - """Find all files suitable for distributing. - - Given the path to generated Sphinx documentation, returns an iterable - of (path, BaseFile) for files that should be archived, uploaded, etc. - Paths are relative to given root directory. - """ - finder = FileFinder(root, ignore=('_staging', '_venv')) - return finder.find('**') - - -def create_tarball(filename, root): - """Create a tar.gz archive of docs in a directory.""" - files = dict(distribution_files(root)) - - with open(filename, 'wb') as fh: - create_tar_gz_from_files(fh, files, filename=os.path.basename(filename), - compresslevel=6)
new file mode 100644 --- /dev/null +++ b/tools/docs/moztreedocs/package.py @@ -0,0 +1,30 @@ +# 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 mozpack.archive import create_tar_gz_from_files +from mozpack.files import FileFinder + + +def distribution_files(root): + """Find all files suitable for distributing. + + Given the path to generated Sphinx documentation, returns an iterable + of (path, BaseFile) for files that should be archived, uploaded, etc. + Paths are relative to given root directory. + """ + finder = FileFinder(root, ignore=('_staging', '_venv')) + return finder.find('**') + + +def create_tarball(filename, root): + """Create a tar.gz archive of docs in a directory.""" + files = dict(distribution_files(root)) + + with open(filename, 'wb') as fh: + create_tar_gz_from_files(fh, files, filename=os.path.basename(filename), + compresslevel=6)