用于构建(打包、聚合)javascript库的各种python工具

JSTools的Python项目详细描述


‘JSTools’ is a collection of utilities for managing JavaScript libraries.

安装

Until jstools is released into pypi, we suggest checking out jstools and installing using either ‘python setup.py install’ or ‘python setup.py develop’ from within your checkout.

要求

Should be python 2.4 friendly, tested most on python 2.5

易于安装

$ easy_install jstools

This will put the following scripts in ‘/your/python/distribution/bin’:

$ bin/jsbuild
$ bin/jsmin

Depending on your system, this action may require sudo.

环境安装

‘jstools’ includes a script to create a contained python environment. This script also automatically downloads the yui compressor and puts it in a place jstools can find it.

This script will turn a folder of your choice into a python environment [1] with the jstools scripts installed in a directory called ‘bin’:

$ easy_install -b ./ -e jstools
$ python jstools/install_jstools ./jsdir

This makes ‘jsdir’ jstools enabled with it’s own ‘bin’. source the script ‘bin/activate’, and now jsbuild and jsmin are on your path:

$ cd jsdir
$ . bin/activate

其他分配选项

You can download jstools in whatever flavor your prefer:

$ wget http://github.com/whitmo/jstools/tarball/master
$ svn co http://svn.opengeo.org/jstools/trunk/ # not currently working
$ git clone git://github.com/whitmo/jstools.git

脚本

jsbuild

Merges and compresses files according to a configuration file. jsbuild will walk each root directory specified in configuration, index all the files ending with .js and then compile an aggregate source based on the specification in the config file and the dependencies declared inside the files themselves.

用法

jsbuild<;配置文件>;[选项]

选项

用法:jsbuild[选项]filename1.cfg[文件名2.cfg…]

选项:
-h, --helpshow this help message and exit
-u, --uncompress
Don’t compresses aggregated javascript. jsbuild defaults to applying ‘jsmin’ to all output.
-v, --verboseprint more info
-l, --list-only
Only list javascript files that would have been merged
-o OUTPUT_DIR, --output=OUTPUT_DIR
Output directory for files jsbuild creates (defaults to current directory)
-r RESOURCE_DIR, --resource=RESOURCE_DIR
base directory for resource files (for interpolation)
-b ROOT_DIR, --base-dir=ROOT_DIR
base directory for root dirs (defaults to current directory)
-j SINGLE_FILE, --just=SINGLE_FILE
New in 1.1: Only create file for this section
-s CONCAT, --single-file-build=CONCAT
New in 1.1. Create a single file of all of possible output
-c COMPRESSOR, --compressor=COMPRESSOR
New in 1.1. Specify compressor plugin to use in form {specifier}:{‘arguments_string’}.

配置格式

配置文件可以有多个唯一命名的输出文件(即 多个部分)。

节的格式如下:

[Output.js]
root=
     path/to/where/files/are
     other/path/to/where/files/are

license=path/to/license/for/these/libs

first=
     3rd/prototype.js
     core/application.js
     core/params.js

last=
    core/api.js

exclude=
     3rd/exclude/file.js
     3rd/exclude/dir
     r:3rd/exclude/.*debug.js
#...

将强制加载第一节中列出的文件 所有其他文件之前(按列出的顺序)。最后一个中的文件 在所有其他文件(在 订单列表)。

将不会导入exclude部分中的文件列表。 排除项可以是文件或目录的相对路径,也可以是 以patternr:开头的python正则表达式,请参见pythonre语法: http://docs.python.org/library/re.html#regular-expression-syntax

该配置允许在 配置文件。可以用“%(资源目录)s”代替该值 代表-R旗。

使用“35;”注释的行将被忽略。

如果定义了include部分,jsbuild将只列出build 本节中的文件及其依赖项,否则所有文件都来自 将建立根节。

依赖语法

文件合并使用候选javascript文件中的提示来 确定依赖关系。指定了两种类型的依赖项 在源文件中使用两种不同的注释格式。

指定在给定的 源文件,包括以下格式的注释:

// @requires <file path>

例如

// @requires Geo/DataSource.js

指定目标文件必须包含在任何位置 在合并的生成中-在给定源文件之前或之后- 在源文件中包含以下格式的注释:

// @include <file path>

例如

// @include Geo/DataSource.js

请注意,配置文件中的“排除”列表将 重写由@requires和@include指定的依赖项 上面描述的注释指令。

jsmin

将javascript的输入流压缩为输出流

用法

jsmin<;cat some.js>;some-compressed.js

许可证

–软件应用于善,而不是恶。–

有关完整的版权信息,请参见文件

许可证

混合的。与OpenLayers相同,除非另有说明

构建支持

参见jstools/bo.txt

运行测试

in the src dir in an environment w/ yuicomp installed:

$ easy_install nose
$ paver get_yuicomp
$ cd test
$ nosetests {options}

or most simply:

$ python setup.py test

学分

jstools作为构建脚本的集合启动,作为 OpenLayers项目[35;]\

whitmorris(opengeo.org的whit)将这些脚本重新打包为jstools tim schaub(opengeo.org的tschaub)对tsort做了大量的修改。

[1]

See virtualenv for more information about the python environment. You may activate and deactivate this environment to add the installed scripts to your path, localize python package installs and other niceties ala:

^{pr 2}$
[2]OpenLayers Homepage and the original scripts

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在java Swing中检测重叠对象   java JAXB,xs:any和targetNamespace   JavaFX中的java按钮操作以错误的顺序执行   java Android显示所有已安装应用的应用选择器   在Java中,有没有比仿射变换更有效的旋转图像的方法?   java Play 2.4.6,为测试中的字节码增强配置生成设置   java无法在片段中的图像滑块中获取图像   在java中尝试MD5哈希   Android studio应用程序能否读取Java桌面应用程序序列化的数据类?   无法强制转换java自定义类   自定义Arraylist中的java Split 2列csv字符串   java Spring自定义请求上下文   java在安卓应用程序运行期间,如何检查网络状态是否发生变化?   java是否应该更改HTTP客户端以获得来自服务器的异步响应?   java使用TableModel来保存和处理数据,或者让它只显示对象(内容)   java如何获取麦克风/扬声器名称?   java Android从另一个类更新布局   通过Java RXTX与空调制解调器进行串行到串行通信?