Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 58ee738a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.7.3

* Add the base classes to develop wizard: `Wizard` and `RowEditorAddWizard`.
* Add the function `inline_alert`.
* The `matplotlib` and `pandas` versions are displayed in the version view.
* The `List` widget is compliant with the `allowBlank` construct.
* Improve compliance with jslint and pylint.

See merge request !15
parents 57b8f2c8 e4c0df0c
......@@ -8,15 +8,14 @@
build_version [options] version
DESCRIPTION
Helper script to build a version of the plugin_dbui.
The version identifier should contains alphanumeric characters
including ".", "-" and "_".
Push version identifier in the javascript library.
Push version number in the CHANGELOG.
Build debug and minified version of the javascript library.
Build the web2py plugin file
Build the web2py plugin files.
Build the documentations.
EXAMPLES
......@@ -28,25 +27,25 @@
Copyright (c) 2012-2015 R. Le Gac
"""
import argparse
import datetime
import optparse
import os
import re
import sys
import tarfile
import tempfile
import urllib
from os.path import join as opj
from subprocess import call
from numexpr.version import release
# constants
APP = os.path.basename(os.getcwd())
API = 'api'
BUILDDIR = '../plugin_dbui_build'
CHANGELOG = 'static/plugin_dbui/CHANGELOG'
DBUI_W2P = 'web2py.plugin.dbui.%s.w2p'
DOCS = 'static/plugin_dbui/docs'
DOCSRC = 'docs'
EXTJSSRC = 'static/plugin_extjs/src'
......@@ -61,8 +60,10 @@ NOW = datetime.datetime.now()
PACK_PLUGIN_URL = 'http://localhost:8000/%s/default/pack_plugin' % APP
PDF = "pdf"
PDFDOC = opj(DOCS, PDF)
PLUGIN_W2P = 'web2py.plugin.%s.%s.w2p'
REFERENCE = 'reference'
USER = 'user'
W2P = "web2py.plugin.%s.%s.min.w2p"
# basic commands
GIT = '/usr/bin/git'
......@@ -73,22 +74,58 @@ SPHINX = '/usr/bin/sphinx-build'
MSG_RELEASE = 'Enter the new release: '
# files for plugins
ACE_FILES = ['static/plugin_ace/src-min-noconflict/ace.js']
DBUI_FILES = [
'modules/plugin_dbui',
'models/plugin_dbui.py',
'controllers/plugin_dbui.py',
'views/plugin_dbui',
'static/plugin_dbui/resources/css/kde-oxygen.css',
'static/plugin_dbui/resources/css/dbui.css',
'static/plugin_dbui/resources/icons',
'static/plugin_dbui/src',
'static/plugin_dbui/locale/dbui-lang-en.js',
'static/plugin_dbui/locale/dbui-lang-fr.js',
'static/plugin_dbui/dbui-min.js',
'static/plugin_dbui/docs']
EXTJS_FILES = [
'static/plugin_extjs/resources/css/ext-all.css',
'static/plugin_extjs/resources/ext-theme-classic/ext-theme-classic-all.css',
'static/plugin_extjs/resources/ext-theme-classic/images',
'static/plugin_extjs/ext-dev.js',
'static/plugin_extjs/ext-all.js',
'static/plugin_extjs/ext-theme-classic.js',
'static/plugin_extjs/locale/ext-lang-en.js',
'static/plugin_extjs/locale/ext-lang-fr.js',
'static/plugin_extjs/src',
'static/plugin_extjs/cmd']
MATHJAX_FILES = [
'static/plugin_mathjax/fonts/HTML-CSS/TeX/woff',
'static/plugin_mathjax/images',
'static/plugin_mathjax/jax',
'static/plugin_mathjax/extensions',
'static/plugin_mathjax/MathJax.js']
def build():
"""Compile the javascript code and build documentations.
"""
compile_js()
build_html()
build_doc_html()
for doc in (API, REFERENCE, USER):
docsrc = opj(DOCSRC, doc)
if os.path.exists(docsrc):
build_pdf(doc)
build_doc_pdf(doc)
def build_html():
def build_doc_html():
"""Build HTML documentations.
The source files are located in the following directory::
......@@ -109,7 +146,7 @@ def build_html():
sphinx("-b html", docsrc, opj(DOCS, doc))
def build_pdf(doc):
def build_doc_pdf(doc):
""" Build PDF documentations...
Args:
......@@ -152,6 +189,108 @@ def build_pdf(doc):
print "%s documentation in" % fout, PDFDOC
def build_plugin(plugin_name, release, files):
"""Helper function to build a web2py plugin.
It is inspired by the function: ``web2py/gluon/fileutils/w2p_pack_plugin``.
The binary file is moved to the ``plugin_dbui_build`` directory if it exists.
Args:
plugin_name (str): the name of the plugin, *e.g.* extjs
release (str): the release identifier, *e.g* 421
files (list): list of path for files to be include in the tar file.
"""
# create the tar file
filename = W2P % (plugin_name, release)
tarball = tarfile.open(filename, 'w:gz')
for path in files:
tarball.add(path)
tarball.close()
print "The plugin file", filename, "is created."
# move the file to the plugin_dbui_build directory
if not os.path.exists(BUILDDIR):
return
fn_build = opj(BUILDDIR, filename)
if os.path.exists(fn_build):
os.remove(fn_build)
os.rename(filename, fn_build)
print "The plugin file is in ", BUILDDIR
def build_plugin_ace():
"""Build the plugin ace.
It only contains the minimum number of files required
by the web2py applications.
"""
if not is_plugin("ace"):
return
# get the release number
release = get_plugin_version("ace")
# create the tar file
build_plugin('ace', release, ACE_FILES)
def build_plugin_dbui():
"""Build the plugin dbui.
It only contains the minimum number of files required
by the web2py applications.
"""
if not is_plugin("dbui"):
return
# get the release number
release = get_plugin_version("dbui")
# create the tar file
build_plugin('dbui', release, DBUI_FILES)
def build_plugin_extjs():
"""Build the plugin extjs.
It only contains the minimum number of files
required by the web2py applications.
"""
if not is_plugin("extjs"):
return
# get the release number
release = get_plugin_version("extjs")
# create the tar file
build_plugin('extjs', release, EXTJS_FILES)
def build_plugin_mathjax():
"""Build the plugin mathjax.
It only contians the minimum number of files
required by the web2py applications.
"""
if not is_plugin("mathjax"):
return
# get the release number
release = get_plugin_version("mathjax")
# create the tar file
build_plugin('mathjax', release, MATHJAX_FILES)
def commit_change_log():
"""Commit CHANGELOG and App.js.
......@@ -233,6 +372,85 @@ def compile_js():
print 'Minified version of the javascript library', JSLIBMIN, 'is ready'
def get_plugin_version(plugin):
"""
Args:
plugin (str): name of the plugin
Return:
str: the plugin version
"""
if plugin == "ace":
cwd = os.getcwd()
os.chdir('static/plugin_ace')
tmpfile = tempfile.TemporaryFile()
git("describe --tags", stdout=tmpfile)
tmpfile.seek(0)
release = tmpfile.read()
release = release.replace("v", "").replace("\n", "")
tmpfile.close()
os.chdir(cwd)
elif plugin == "dbui":
filename = os.path.join('static', 'plugin_dbui', 'src', 'App.js')
tmpfile = open(filename, 'rb')
text = tmpfile.read()
tmpfile.close()
match = re.match(r"(.+ version: ')([\w._-]*)('.+)", text, re.DOTALL)
release = match.group(2)
elif plugin == "extjs":
fn = os.path.join('static', 'plugin_extjs', 'src', 'version', 'Version.js')
if not os.path.exists(fn):
print "\n\tNo version file for the plugin extjs !"
return ""
tmpfile = open(fn, 'rb')
text = tmpfile.read()
tmpfile.close()
match = re.match(r".+ version = '(\d+(\.\d+)*)',", text, re.DOTALL)
if not match:
print "\n\tExt JS release number not defined !"
return ""
release = match.group(1)
elif plugin == "mathjax":
filename = os.path.join('static', 'plugin_mathjax', 'MathJax.js')
tmpfile = open(filename, 'rb')
text = tmpfile.read()
tmpfile.close()
match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL)
if not match:
print "\n\tMathJax release number not defined !"
return ""
release = match.group(1)
else:
raise ValueError("unknow plugin")
# shrink the release identifier 4.2.1 or 4.2.1.883 -> 421
li = release.split('.')
release = ''.join(li) if len(li) < 4 else ''.join(li[:-1])
if len(release) == 2:
release = "%s0" % release
return release
def get_version():
"""Get the current version identifier.
......@@ -271,6 +489,24 @@ def git(*args, **kwargs):
call(cmd, **kwargs)
def is_plugin(plugin):
"""
Args:
plugin (str): name of the plugin
Returns:
bool: true when the plugin exist.
"""
path = os.path.join('static', 'plugin_%s' % plugin)
if not os.path.exists(path):
print "\n\tNo source file for the plugin %s !" % plugin
return False
return True
def jsduck():
"""Generate the JavaScript documentation.
The HTML files are located in static/plugin_dbui/docs/jsduck
......@@ -439,22 +675,31 @@ def tag():
git("push --tags")
def web2py():
def web2py(plugin):
"""Produce the binary file for the web2py plugin.
Args:
plugin (str): the name of the plugin
"""
print 'Build the web2py plugin binary file...'
print 'Build the web2py plugin_%s binary file...' % plugin
msg = 'Check that the web2py service is running [y/N]'
msg = 'Check that the web2py service is running [y/N]: '
rep = raw_input(msg)
if rep != 'y':
print '\n\tSkip this step.\n'
return
connection = urllib.urlopen(PACK_PLUGIN_URL)
# ask web2py to package the plugin
url = "%s?plugin=%s" % (PACK_PLUGIN_URL, plugin)
connection = urllib.urlopen(url)
txt = connection.read()
fn = DBUI_W2P % get_version().replace('.', '')
# get the release of the plugin
release = get_plugin_version(plugin)
# write the data to a file
fn = PLUGIN_W2P % (plugin, release)
fi = open(fn, 'wb')
fi.write(txt)
fi.close()
......@@ -472,143 +717,149 @@ def web2py():
if __name__ == '__main__':
# define script options
OPS = optparse.OptionParser()
OPS.add_option("-a", "--api-doc",
action="store_true",
dest="api_doc",
help="build the API documentation in HTML.")
OPS.add_option("-A", "--api-pdf",
action="store_true",
dest="api_pdf",
help="build the API documentation in PDF.")
OPS.add_option("-c", "--compile",
action="store_true",
dest="compile",
help="compile the javascript library.")
OPS.add_option("--commit-changelog",
action="store_true",
dest="changelog",
help="commit CHANGELOG and App.js. "
"To be used with --write-release.")
OPS.add_option("-j", "--jsduck",
action="store_true",
dest="jsduck",
help="build the JavaScript documentation.")
OPS.add_option("-r", "--reference-doc",
action="store_true",
dest="reference_doc",
help="build the reference manual in HTML.")
OPS.add_option("-R", "--reference-pdf",
action="store_true",
dest="reference_pdf",
help="build the reference manual in PDF.")
OPS.add_option("-s", "--start-release",
action="store_true",
dest="start_release",
help="start the release candidate by setting "
"release number in change log and App.js. "
"Commit changes in the master branch. "
"Equivalent to --write-release followed by "
"--commit-changelog.")
OPS.add_option("-t", "--tag",
action="store_true",
dest="tag",
help="tag the release in the production branch "
"locally and on the remote repository.")
OPS.add_option("-u", "--user-doc",
action="store_true",
dest="user_doc",
help="build the user manual in HTML.")
OPS.add_option("-U", "--user-pdf",
action="store_true",
dest="user_pdf",
help="build the user manual in PDF.")
OPS.add_option("-v", "--version",
action="store_true",
dest="version",
help="get the current release identifier.")
OPS.add_option("-w", "--web2py",
action="store_true",
dest="web2py",
help="pack the plugin_dbui.")
OPS.add_option("--write-release",
action="store_true",
dest="release",
help="write the release number in CHANGELOG and App.js. "
"To be used with --commit-changelog.")
OPS.set_defaults(api_doc=False,
api_pdf=False,
changelog=False,
compile=False,
jsduck=False,
reference_doc=False,
reference_pdf=False,
release=False,
start_release=False,
tag=False,
user_doc=False,
user_pdf=False,
version=False)
(OPT, ARGS) = OPS.parse_args()
if OPT.api_doc:
APS = argparse.ArgumentParser()
APS.add_argument("--ace",
action="store_true",
help="build the plugin ace minimizing its size.")
APS.add_argument("-a", "--api-doc",
action="store_true",
help="build the API documentation in HTML.")
APS.add_argument("-A", "--api-pdf",
action="store_true",
help="build the API documentation in PDF.")
APS.add_argument("-c", "--compile",
action="store_true",
help="compile the javascript library.")
APS.add_argument("--commit-changelog",
action="store_true",
help="commit CHANGELOG and App.js. "
"To be used with --write-release. "
"Recommend to use --start-release.")
APS.add_argument("--dbui",
action="store_true",
help="build the plugin dbui minimizing its size.")
APS.add_argument("--extjs",
action="store_true",
help="build the plugin extjs minimizing its size.")
APS.add_argument("-j", "--jsduck",
action="store_true",
help="build the JavaScript documentation.")
APS.add_argument("--mathjax",
action="store_true",
help="build the plugin mathjax minimizing its size.")
APS.add_argument("-r", "--reference-doc",
action="store_true",
help="build the reference manual in HTML.")
APS.add_argument("-R", "--reference-pdf",
action="store_true",
help="build the reference manual in PDF.")
APS.add_argument("-s", "--start-release",
action="store_true",
help="start the release candidate by setting "
"release number in change log and App.js. "
"Commit changes in the master branch. "
"Equivalent to --write-release followed by "
"--commit-changelog.")
APS.add_argument("-t", "--tag",
action="store_true",
help="tag the release in the production branch "
"locally and on the remote repository. "
"Recommend to use gitlab instead.")
APS.add_argument("-u", "--user-doc",
action="store_true",
help="build the user manual in HTML.")
APS.add_argument("-U", "--user-pdf",
action="store_true",
help="build the user manual in PDF.")
APS.add_argument("-v", "--version",
action="store_true",
help="get the current release identifier.")
APS.add_argument("-w", "--web2py",
action="store",
choices=["ace", "dbui", "extjs", "mathjax"],
help="build the plugin using web2py.",
metavar="plugin")
APS.add_argument("--write-release",
action="store_true",
help="write the release number in CHANGELOG and App.js. "
"To be used with --commit-changelog. "
"Recommend to use --start-release.")
ARGS = APS.parse_args()
if ARGS.ace:
build_plugin_ace()
if ARGS.api_doc:
sphinx("-b html", opj(DOCSRC, API), opj(DOCS, API))
if OPT.api_pdf:
build_pdf(API)
if ARGS.api_pdf:
build_doc_pdf(API)
if OPT.compile:
if ARGS.compile:
compile_js()
if OPT.changelog:
if ARGS.commit_changelog:
commit_change_log()
if OPT.jsduck:
if ARGS.dbui:
build()
build_plugin_dbui()
if ARGS.extjs:
build_plugin_extjs()
if ARGS.jsduck:
jsduck()
if OPT.release:
set_version(raw_input(MSG_RELEASE))
if ARGS.mathjax:
build_plugin_mathjax()
if OPT.reference_doc:
if ARGS.reference_doc:
sphinx("-b html", opj(DOCSRC, REFERENCE), opj(DOCS, REFERENCE))
if OPT.reference_pdf:
build_pdf(REFERENCE)
if ARGS.reference_pdf:
build_doc_pdf(REFERENCE)
if OPT.start_release:
if ARGS.start_release:
start_release()
if OPT.tag:
if ARGS.tag:
tag()
if OPT.user_doc:
if ARGS.user_doc:
sphinx("-b html", opj(DOCSRC, USER), opj(DOCS, USER))
if OPT.user_pdf:
build_pdf(USER)
if ARGS.user_pdf:
build_doc_pdf(USER)