用于构建(打包、聚合)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 JList侦听器找不到符号   多点触摸跨平台java应用程序(Windows、Mac和Linux(Ubuntu)(可能是Android))   在UnitTest中找不到java类加载器资源   java当我尝试在Eclipse中运行我的minecraft mod时,我总是遇到这个错误,这是什么意思?   内部有一个同步块的静态方法,在java中阻止整个类?   不支持java操作:具有BillableStatus的费用在采购中应具有AccountBasedExpenseLineDetail行的CustomerRef   java运行时常量池GC集合   java无法解析配置“:app:\u debugApk”的所有依赖项。找不到名为“default”的配置   在GCP计算引擎中托管Neo4j的java   java如何从BroadcastReceiver更新片段选项卡?   线程“main”组织中的java异常。冬眠注释异常:@org。冬眠注释。表引用未知表:ProductForPractice   在Java/Groovy中嵌入处理   java Android REST教程/示例项目   java我可以在同一测试中在一个模拟器上启动应用程序,在另一个模拟器上启动移动浏览器吗?   java如何更改通知横幅的方向?   安卓 Java帮助实现Firebase授权   if else之后的rs.next()中出现java错误?