Skip to content

Commit

Permalink
more docs on api
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsiaoming Yang committed Mar 26, 2013
1 parent 7bd8982 commit d343a30
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 13 deletions.
26 changes: 23 additions & 3 deletions docs/api/grunt.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# grunt

- pubdate: 2013-03-20
- pubdate: 2013-03-26
- index: 10

Hack the grunt.

-----

spm hacks in grunt, extends grunt methods.

## invokeTask
```js
var grunt = require('spm').sdk.grunt;
```

It contains everything of grunt, and more.

## loadGlobalTasks
## invokeTask(name, options)

Invoke/call a task.

```js
grunt.invokeTask('build', {
fallback: function(grunt) {
console.log('fallback')
}
})
```

It will search the gruntfiles and detect if the task name in the gruntfile. If the task is in the gruntfile, it will run the task, if not, it will call the fallback function.

## loadGlobalTasks(name)

Load tasks in the global `NODE_PATH`. Just like `loadNpmTasks`, it can load task collections.
87 changes: 79 additions & 8 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# spm

- pubdate: 2013-03-20
- pubdate: 2013-03-26
- index: 0

The API of spm.
Expand All @@ -21,21 +21,85 @@ The version of spm.

Always use `spm.log` in your program, never use `console`.

```js
spm.log('install', 'arale/class')
```

## spm.plugin

- spm.plugin.install
- spm.plugin.uninstall
- spm.plugin.show
- spm.plugin.plugins
API for plugins.

### spm.plugin.install(options)

Install a plugin, used by postinstall hook in npm:

```js
spm.plugin.install({
name: 'init',
bin: 'spm-init',
description: 'init …'
})
```

### spm.plugin.uninstall(name)

Uninstall a plugin, used by uninstall hook in npm:

```js
spm.plugin.uninstall('init')
```

### spm.plugin.plugins

All installed plugins:

```
var plugins = spm.plugin.plugins;
```


## spm.config

Interact with `~/.spm/spmrc` config file.

- spm.config.config
- spm.config.remove
- spm.config.show
### spm.config.get(key)

Get information in spmrc:

```
spm.config.get('user')
spm.config.get('user.username')
```

### spm.config.set(key, value)

Set section in spmrc:

```
spm.config.set('user.username', 'lepture')
```

### spm.config.remove(section)

Remove a section in spmrc:

```
spm.config.remove('user')
```

## spm.build(options)

Build the module.

### spm.build.loadBuildTasks(options, pkg)

Load build tasks: `spm-build`.

This is a task collection which is [grunt-spm-build](https://github.com/spmjs/grunt-spm-build). You can bind and load this task too.

## spm.login(options)

Login/register spmjs.org.

## spm.install(options)

Expand All @@ -49,6 +113,10 @@ Get information of a module from spmjs.org.

Search modules from spmjs.org.

```
spm.search({query: 'jquery'})
```

## spm.publish(options)

Publish a package to spmjs.org.
Expand All @@ -57,6 +125,9 @@ Publish a package to spmjs.org.

Unpublish a package from spmjs.org.

```
spm.unpublish({query: 'arale/class@1.0.0'})
```

## spm.sdk

Expand Down
18 changes: 16 additions & 2 deletions docs/api/yuan.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yuan

- pubdate: 2013-03-20
- pubdate: 2013-03-26
- index: 5

communication with spmjs.org.
Expand All @@ -11,16 +11,30 @@ communication with spmjs.org.
var yuan = require('spm').sdk.yuan
```

This is a lower API, for higher API, use `spm.publish` or `spm.install`.
This is a lower API, for higher API, use:

- `spm.publish`
- `spm.unpublish`
- `spm.info`
- `spm.search`
- `spm.login`

## login

Login your account.

```
yuan(options).login(user, callback)
```

## register

Register an account.

```
yuan(options).register(user, callback)
```

## info

Get information of a module.
Expand Down

0 comments on commit d343a30

Please sign in to comment.