Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Dec 17, 2014
1 parent bccc81f commit cf583de
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
32 changes: 29 additions & 3 deletions README.md
Expand Up @@ -22,7 +22,7 @@ A TOC will be generated exactly on this place for the following headers.
var toc = require('toc-md');
```

Provides the only function which inserts a TOC to a given source:
#### toc.insert

**@param** *{String}* - a source where to insert a TOC (must contain the HTML comment `<!-- TOC -->`)<br>
**@param** *{Object}* - options:<br>
Expand All @@ -31,6 +31,11 @@ Provides the only function which inserts a TOC to a given source:

**@param** *{Function}* - callback

#### toc.clean

**@param** *{String}* - a source whereof to clean a TOC<br>
**@param** *{Function}* - callback

#### Example

```js
Expand All @@ -43,13 +48,23 @@ var options = {
maxDepth: 6
};

toc(source, options, function (err, res) {
toc.insert(source, options, function (err, res) {
if (err) {
console.log(err);
} else {
fs.writeFileSync('markdown-with-toc.md', res);
}
});

source = fs.readFileSync('markdown-with-toc.md', 'utf-8');

toc.clean(source, function (err, res) {
if (err) {
console.log(err);
} else {
fs.writeFileSync('markdown-without-toc.md', res);
}
});
```

### CLI
Expand All @@ -65,18 +80,29 @@ Options:
-h, --help : Help
-v, --version : Shows the version number
-m MAXDEPTH, --max-depth=MAXDEPTH : Uses headings whose depth is at most the specified value (default: 6)
-c, --clean : Cleans a TOC

Arguments:
SOURCE : Path to an input markdown file (it must contain the HTML comment <!-- TOC -->) (required)
TARGET : Path to an output markdown file
```

If argument `TARGET` is not specified, a TOC will be added to `SOURCE`.
If argument `TARGET` is not specified, a result will be written to `SOURCE`.

#### Example

##### Insert

```bash
$ toc-md path/to/input/markdown path/to/output/markdown --max-depth=4

$ toc-md path/to/markdown -m 4
```

##### Clean

```bash
$ toc-md path/to/input/markdown path/to/output/markdown --clean

$ toc-md path/to/markdown -c
```
33 changes: 29 additions & 4 deletions README.ru.md
Expand Up @@ -22,7 +22,7 @@ $ npm install toc-md
var toc = require('toc-md');
```

Предоставляет единственную функцию, которая добавляет оглавление исходному тексту:
#### toc.insert

**@param** *{String}* - исходный текст, в который необходимо добавить оглавление (обязательно должен содержать HTML-комментарий `<!--TOC-->`)<br>
**@param** *{Object}* - опции:<br>
Expand All @@ -31,6 +31,11 @@ var toc = require('toc-md');

**@param** *{Function}* - callback

#### toc.clean

**@param** *{String}* - исходный текст, который необходимо очистить от оглавления<br>
**@param** *{Function}* - callback

#### Пример

```js
Expand All @@ -43,13 +48,23 @@ var options = {
maxDepth: 6
};

toc(source, options, function (err, res) {
toc.insert(source, options, function (err, res) {
if (err) {
console.log(err);
} else {
fs.writeFileSync('markdown-с-оглавлением.md', res);
}
});

source = fs.readFileSync('markdown-с-оглавлением.md', 'utf-8');

toc.clean(source, function (err, res) {
if (err) {
console.log(err);
} else {
fs.writeFileSync('markdown-без-оглавления.md', res);
}
});
```

### CLI
Expand All @@ -65,19 +80,29 @@ $ toc-md --help
-h, --help : Помощь
-v, --version : Показывает номер версии
-m MAXDEPTH, --max-depth=MAXDEPTH : Использует заголовки, вложенность которых не больше указанного значения (по умолчанию: 6)
-c, --clean : Очищает оглавление

Arguments:
SOURCE : Путь к входному markdown-файлу (он должен содержать HTML-комментарий <!-- TOC -->) (обязательный аргумент)
TARGET : Путь к выходному markdown-файлу
```

Если аргумент `TARGET` не указан, то содержание будет добавлено в `SOURCE`.
Если аргумент `TARGET` не указан, то результат будет записан в `SOURCE`.

<a name="пример"></a>
#### Пример

##### Добавление оглавления

```bash
$ toc-md путь/к/входному/markdown-файлу путь/к/выходному/markdown-файлу --max-depth=4

$ toc-md путь/к/markdown-файлу -m 4
```

##### Очистка оглавления

```bash
$ toc-md путь/к/входному/markdown-файлу путь/к/выходному/markdown-файлу --clean

$ toc-md путь/к/markdown-файлу -c
```

0 comments on commit cf583de

Please sign in to comment.