Skip to content

Commit

Permalink
Remove superfluous comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 26, 2016
1 parent a6e49f8 commit cec5f38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 60 deletions.
34 changes: 6 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module remark:toc
* @fileoverview Generate a Table of Contents (TOC) for Markdown files.
*/

'use strict';

/* Dependencies. */
var slug = require('remark-slug');
var toc = require('mdast-util-toc');
var util = require('mdast-util-toc');

/* Expose. */
module.exports = attacher;
module.exports = toc;

/* Constants. */
var DEFAULT_HEADING = 'toc|table[ -]of[ -]contents?';

/**
* Attacher.
*
* @param {Unified} processor - Processor.
* @param {Object} options - Configuration.
* @return {function(node)} - Transformmer.
*/
function attacher(processor, options) {
function toc(processor, options) {
var settings = options || {};
var heading = settings.heading || DEFAULT_HEADING;
var depth = settings.maxDepth || 6;
Expand All @@ -35,14 +17,10 @@ function attacher(processor, options) {

return transformer;

/**
* Adds an example section based on a valid example
* JavaScript document to a `Usage` section.
*
* @param {Node} node - Root to search in.
*/
/* Adds an example section based on a valid example
* JavaScript document to a `Usage` section. */
function transformer(node) {
var result = toc(node, {
var result = util(node, {
heading: heading,
maxDepth: depth,
tight: tight
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
"devDependencies": {
"browserify": "^13.0.0",
"esmangle": "^1.0.0",
"nyc": "^8.1.0",
"is-hidden": "^1.1.0",
"negate": "^1.0.0",
"nyc": "^10.0.0",
"remark": "^6.0.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"tape": "^4.0.0",
"xo": "^0.16.0"
"xo": "^0.17.1"
},
"scripts": {
"build-md": "remark *.md --quiet --frail",
Expand Down
33 changes: 3 additions & 30 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module remark:toc:test
* @fileoverview Test suite for `remark-toc`.
*/

'use strict';

/* Dependencies. */
var test = require('tape');
var fs = require('fs');
var path = require('path');
var remark = require('remark');
var negate = require('negate');
var hidden = require('is-hidden');
var toc = require('..');

/* Methods. */
var read = fs.readFileSync;
var exists = fs.existsSync;
var join = path.join;

/* Constants. */
var ROOT = join(__dirname, 'fixtures');

/* Fixtures. */
var fixtures = fs.readdirSync(ROOT);

/**
* Shortcut to process.
*
* @param {string} value - Value to process.
* @param {Object} config - Configuration for processor.
* @return {string} - Processed `value`.
*/
function process(value, config) {
return remark().use(toc, config).process(value).toString();
}

/*
* Tests.
*/

test('remark-toc()', function (t) {
t.equal(typeof toc, 'function', 'should be a function');

Expand All @@ -51,14 +30,8 @@ test('remark-toc()', function (t) {
t.end();
});

/*
* Fixtures.
*/

test('Fixtures', function (t) {
fixtures.filter(function (filepath) {
return filepath.indexOf('.') !== 0;
}).forEach(function (fixture) {
fixtures.filter(negate(hidden)).forEach(function (fixture) {
var filepath = join(ROOT, fixture);
var output = read(join(filepath, 'output.md'), 'utf-8');
var input = read(join(filepath, 'input.md'), 'utf-8');
Expand Down

0 comments on commit cec5f38

Please sign in to comment.