Bug 1389341 - add basic support for sphinx-js to mach doc r?gps
MozReview-Commit-ID: FIzWD8tnjYi
--- a/build/sparse-profiles/sphinx-docs
+++ b/build/sparse-profiles/sphinx-docs
@@ -2,16 +2,18 @@
[include]
# Code for generating docs.
glob:tools/docs/**
# Potential docs sources
glob:**/*.rst
glob:**/*.md
+glob:**/*.js
+glob:**/*.jsm
# Python API docs.
glob:**/*.py
# moz.build files are read to discover location of docs.
glob:**/moz.build
# Read to set the version of the docs.
--- a/taskcluster/ci/source-test/doc.yml
+++ b/taskcluster/ci/source-test/doc.yml
@@ -20,16 +20,18 @@ generate:
./mach doc --outdir docs-out --no-open --archive
sparse-profile: sphinx-docs
when:
files-changed:
- '**/*.py'
- '**/*.rst'
- '**/*.md'
- 'tools/docs/**'
+ - '**/*.js'
+ - '**/*.jsm'
upload:
description: Generate and upload the Sphinx documentation
platform: lint/opt
treeherder:
symbol: tc(DocUp)
kind: test
tier: 3
--- a/taskcluster/docker/lint/system-setup.sh
+++ b/taskcluster/docker/lint/system-setup.sh
@@ -44,16 +44,22 @@ cd /build
###
# ESLint Setup
###
# install node
. install-node.sh
+###
+# jsdoc Setup
+###
+
+npm install -g jsdoc@3.5.5
+
/build/tooltool.py fetch -m /tmp/eslint.tt
mv /build/node_modules /build/node_modules_eslint
/build/tooltool.py fetch -m /tmp/eslint-plugin-mozilla.tt
mv /build/node_modules /build/node_modules_eslint-plugin-mozilla
###
# fzf setup
###
--- a/tools/docs/conf.py
+++ b/tools/docs/conf.py
@@ -33,18 +33,25 @@ sys.path[:0] = [os.path.join(topsrcdir,
sys.path.insert(0, OUR_DIR)
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.graphviz',
'sphinx.ext.todo',
'mozbuild.sphinx',
+ 'sphinx_js',
]
+# JSDoc must run successfully for dirs specified, so running
+# tree-wide (the default) will not work currently.
+js_source_path = []
+root_for_relative_js_paths = '.'
+jsdoc_config_path = 'tools/docs/jsdoc.json'
+
templates_path = ['_templates']
source_suffix = '.rst'
source_suffix = ['.rst', '.md']
source_parsers = {
'.md': CommonMarkParser,
}
master_doc = 'index'
project = u'Mozilla Source Tree Docs'
new file mode 100644
--- /dev/null
+++ b/tools/docs/jsdoc.json
@@ -0,0 +1,5 @@
+{
+ "source": {
+ "includePattern": ".+\\.jsm$"
+ }
+}
--- a/tools/docs/mach_commands.py
+++ b/tools/docs/mach_commands.py
@@ -1,23 +1,25 @@
# 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, print_function, unicode_literals
import os
+import platform
import sys
from mach.decorators import (
Command,
CommandArgument,
CommandProvider,
)
+import which
import mozhttpd
from mozbuild.base import MachCommandBase
@CommandProvider
class Documentation(MachCommandBase):
"""Helps manage in-tree documentation."""
@@ -37,18 +39,24 @@ class Documentation(MachCommandBase):
help="Don't automatically open HTML docs in a browser.")
@CommandArgument('--http', const=':6666', metavar='ADDRESS', nargs='?',
help='Serve documentation on an HTTP server, '
'e.g. ":6666".')
@CommandArgument('--upload', action='store_true',
help='Upload generated files to S3')
def build_docs(self, what=None, format=None, outdir=None, auto_open=True,
http=None, archive=False, upload=False):
+ try:
+ jsdoc = which.which('jsdoc')
+ except which.WhichError:
+ return die('jsdoc not found - please install from npm.')
+
self._activate_virtualenv()
- self.virtualenv_manager.install_pip_package('sphinx_rtd_theme==0.1.6')
+ self.virtualenv_manager.install_pip_package('sphinx_rtd_theme==0.2.4')
+ self.virtualenv_manager.install_pip_package('sphinx-js==2.1')
self.virtualenv_manager.install_pip_package('recommonmark==0.4.0')
import sphinx
import webbrowser
import moztreedocs
if not outdir:
outdir = os.path.join(self.topobjdir, 'docs')
@@ -163,8 +171,9 @@ class Documentation(MachCommandBase):
if project == 'main':
s3_upload(files)
def die(msg, exit_code=1):
msg = '%s: %s' % (sys.argv[0], msg)
print(msg, file=sys.stderr)
return exit_code
+