From 058613310973365a64c2bf94f7a5ab9a2f1b14b9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 9 Dec 2016 20:38:04 -0500 Subject: Switch from yuidoc to JSDoc3. Before it downloaded yuidoc for you; not it expects that jsdoc is already installed. Note that it was old-school, abandoned yuidoc, not its successor yuidocjs. The migration path from yuidoc->jsdoc actually seemed simpler than yuidoc->yuidocjs. --- jarmonbuild/commands.py | 88 ++++--------------------------------------------- 1 file changed, 6 insertions(+), 82 deletions(-) (limited to 'jarmonbuild/commands.py') diff --git a/jarmonbuild/commands.py b/jarmonbuild/commands.py index ebd6ebc..5623bbb 100644 --- a/jarmonbuild/commands.py +++ b/jarmonbuild/commands.py @@ -4,7 +4,6 @@ Functions and Classes for automating the release of Jarmon """ -import hashlib import logging import os import shutil @@ -15,23 +14,10 @@ import urllib from datetime import datetime from optparse import OptionParser from subprocess import check_call, PIPE -from tempfile import gettempdir -from urllib2 import urlopen from zipfile import ZipFile, ZIP_DEFLATED import pkg_resources - -JARMON_PROJECT_TITLE = 'Jarmon' -JARMON_PROJECT_URL = 'http://www.launchpad.net/jarmon' -JARMON_COPYRIGHT = 'Richard Wall' - -YUIDOC_URL = 'https://github.com/yui/yuidoc/archive/yuidoc-50.zip' -YUIDOC_DIR = 'yuidoc-yuidoc-50' -YUIDOC_MD5 = '725fc7cdf349f8dfd20d487841e9d3b9' -YUIDOC_DEPENDENCIES = ['pygments', 'cheetah'] - - class BuildError(Exception): """ A base Exception for errors in the build system @@ -59,7 +45,7 @@ class BuildCommand(object): class BuildApidocsCommand(BuildCommand): """ - Download YUI Doc and use it to generate apidocs for jarmon + Generate apidocs for jarmon """ command_name = 'apidocs' @@ -78,88 +64,26 @@ class BuildApidocsCommand(BuildCommand): if len(args) != 1 and len(args) != 2: parser.error('Wrong number of arguments. This command expects a ' - 'version number only.') + 'version number, and optionally a directory.') buildversion = args[0] - tmpdir = gettempdir() workingbranch_dir = self.workingbranch_dir build_dir = self.build_dir apidocs_dir = os.path.join(args[1] if len(args) == 2 else build_dir, 'docs', 'apidocs') - yuidoc_dir = os.path.join(build_dir, YUIDOC_DIR) - - # Check for yuidoc dependencies - for r in pkg_resources.parse_requirements(YUIDOC_DEPENDENCIES): - if not pkg_resources.working_set.find(r): - raise BuildError('Unsatisfied yuidoc dependency: %r' % (r,)) - - # download and cache yuidoc - yuizip_path = os.path.join(tmpdir, os.path.basename(YUIDOC_URL)) - if os.path.exists(yuizip_path): - self.log.debug('Using cached YUI doc') - - def producer_local(): - yield open(yuizip_path).read() - - producer = producer_local - else: - self.log.debug('Downloading YUI Doc') - - def producer_remote(): - with open(yuizip_path, 'w') as yuizip: - download = urlopen(YUIDOC_URL) - while True: - bytes = download.read(1024 * 10) - if not bytes: - break - else: - yuizip.write(bytes) - yield bytes - - producer = producer_remote - - checksum = hashlib.md5() - for bytes in producer(): - checksum.update(bytes) - - actual_md5 = checksum.hexdigest() - if actual_md5 != YUIDOC_MD5: - raise BuildError( - 'YUI Doc checksum error. File: %s, ' - 'Expected: %s, ' - 'Got: %s' % (yuizip_path, YUIDOC_MD5, actual_md5)) - else: - self.log.debug('YUI Doc checksum verified') # Remove any existing apidocs so that we can track removed files shutil.rmtree(apidocs_dir, True) - # extract yuidoc folder from the downloaded zip file - self.log.debug( - 'Extracting YUI Doc from %s to %s' % (yuizip_path, yuidoc_dir)) - zip = ZipFile(yuizip_path) - zip.extractall( - build_dir, (m for m in zip.namelist() if m.startswith(YUIDOC_DIR))) - # Use the yuidoc script that we just extracted to generate new docs - self.log.debug('Running YUI Doc') + self.log.debug('Running JSDoc') check_call(( - sys.executable, - os.path.join(yuidoc_dir, 'bin', 'yuidoc.py'), + 'jsdoc', + '-c', os.path.join(workingbranch_dir, 'jarmonbuild', 'jsdoc.json'), + '-d', apidocs_dir, os.path.join(workingbranch_dir, 'jarmon'), - '--parseroutdir=%s' % (apidocs_dir,), - '--outputdir=%s' % (apidocs_dir,), - '--template=%s' % ( - os.path.join( - workingbranch_dir, 'jarmonbuild', 'yuidoc_template'),), - '--version=%s' % (buildversion,), - '--project=%s' % (JARMON_PROJECT_TITLE,), - '--projecturl=%s' % (JARMON_PROJECT_URL,), - '--copyright=%s.' % (JARMON_COPYRIGHT,), ), stdout=PIPE, stderr=PIPE,) - shutil.rmtree(yuidoc_dir) - class BuildReleaseCommand(BuildCommand): """ -- cgit v1.2.3-2-g168b