aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonan Amicel <ronan.amicel@gmail.com>2012-10-12 12:23:07 +0200
committerRonan Amicel <ronan.amicel@gmail.com>2012-10-13 12:22:48 +0200
commit6f14742325e1101ffe5c1d564e6b3b2c5142be78 (patch)
tree3d593adb1f59b85a6a3f746d9a45e35b53117e7d
parentImport nodejs module in fabtools module namespace (diff)
downloadfabtools-6f14742325e1101ffe5c1d564e6b3b2c5142be78.tar.xz
Update Node.js documentation
-rw-r--r--docs/api/index.rst1
-rw-r--r--docs/api/nodejs.rst7
-rw-r--r--fabtools/nodejs.py65
3 files changed, 60 insertions, 13 deletions
diff --git a/docs/api/index.rst b/docs/api/index.rst
index 3084c04..a0282e9 100644
--- a/docs/api/index.rst
+++ b/docs/api/index.rst
@@ -9,6 +9,7 @@ fabtools
files
mysql
network
+ nodejs
openvz
postgres
python
diff --git a/docs/api/nodejs.rst b/docs/api/nodejs.rst
new file mode 100644
index 0000000..01c1654
--- /dev/null
+++ b/docs/api/nodejs.rst
@@ -0,0 +1,7 @@
+.. _nodejs_module:
+
+:mod:`fabtools.nodejs`
+----------------------
+
+.. automodule:: fabtools.nodejs
+ :members:
diff --git a/fabtools/nodejs.py b/fabtools/nodejs.py
index 4f6f310..e4d4c9f 100644
--- a/fabtools/nodejs.py
+++ b/fabtools/nodejs.py
@@ -1,8 +1,13 @@
"""
-NodeJS environments and packages
-================================
+Node.js
+=======
+
+This module provides tools for installing `Node.js`_ and managing
+packages using `npm`_.
+
+.. _Node.js: http://nodejs.org/
+.. _npm: http://npmjs.org/
-Packages are managed with npm.
"""
from fabric.api import run, sudo, cd
from fabtools import require
@@ -10,8 +15,17 @@ from fabtools import require
def install_nodejs(version="0.8.9"):
"""
- Installing Node JS 0.8.9 by default. This script works only for recent
- version of Node JS.
+ Install Node JS from source.
+
+ Example::
+
+ import fabtools
+
+ # Install Node.js
+ fabtools.nodejs.install_nodejs()
+
+ .. note:: This function only works for recent versions of Node.js.
+
"""
require.deb.packages([
"make",
@@ -34,12 +48,24 @@ def install_nodejs(version="0.8.9"):
def install(package=None, version=None, global_install=True):
"""
- Install given npm package. If global_install is set to false, package
- is installed locally.
+ Install Node.js package using ``npm``.
+
+ If ``global_install`` is ``False``, the package will be installed
+ locally.
+
+ Example::
- If no package is given npm install is run inside current directory
- and install locally all files given by package.json file that should
- be located at the root of curent directory.
+ import fabtools
+
+ # Install package globally
+ fabtools.nodejs.install('express')
+
+ # Install package locally
+ fabtools.nodejs.install('underscore', global_install=False)
+
+ If no package name is given, then ``npm install`` will be run,
+ which will locally install all packages specified in the
+ ``package.json`` file in the current directory.
"""
if package:
if version:
@@ -55,7 +81,7 @@ def install(package=None, version=None, global_install=True):
def update(package, global_install=True):
"""
- update given pack
+ Update Node.js package.
"""
if global_install:
sudo("npm update -g {package}".format(package=package))
@@ -65,8 +91,21 @@ def update(package, global_install=True):
def uninstall(package, version=None, global_uninstall=True):
"""
- Uninstall given npm package. If global_install is set to false, package
- is uninstalled locally.
+ Uninstall Node.js package.
+
+ If ``global_install`` is False, the package will be uninstalled
+ locally.
+
+ Example::
+
+ import fabtools
+
+ # Uninstall package globally
+ fabtools.nodejs.uninstall('express')
+
+ # Uninstall package locally
+ fabtools.nodejs.uninstall('underscore', global_uninstall=False)
+
"""
if version:
package += "@{version}".format(version=version)