Skip to content

Commit

Permalink
Use NodeJS NPM package markdownlint instead of Ruby gem mdl
Browse files Browse the repository at this point in the history
  • Loading branch information
igorshubovych committed Jan 19, 2016
1 parent 5f6b09b commit 72196b0
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 120 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

# npm specific
node_modules
npm-debug.log
10 changes: 10 additions & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": true,
"MD003": { "style": "atx" },
"MD007": { "indent": 4 },
"MD013": { "line_length": 200 },
"MD033": false,
"MD034": false,
"no-hard-tabs": false,
"whitespace": false
}
23 changes: 6 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
sudo: false

cache: bundler
language: node_js

language: ruby
node_js:
- 'stable'

rvm:
- 2.2.2

install:
- bundle
- . $HOME/.nvm/nvm.sh
- nvm install 5.0
- nvm use 5.0
- npm install rubenvereecken/tldr-lint

gemfile:
- Gemfile

script:
- make lint
cache:
directories:
- node_modules

after_success:
- bash scripts/build.sh
Expand Down
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ Detailed explanation:
git remote add upstream https://github.com/tldr-pages/tldr
```

2. Setup Ruby, Rubygems, bundler, Git pre-commit hooks with Markdown linter.
2. Setup pre-commit hooks with Markdown and TLDR linter.

```bash
# Assuming Ruby is set up
# Install bundler Ruby gem
gem install bundler
make setup
# Assuming you have NodeJS
npm install
```

3. If you cloned a while ago, get the latest changes from upstream:
Expand Down
5 changes: 0 additions & 5 deletions Gemfile

This file was deleted.

19 changes: 0 additions & 19 deletions Gemfile.lock

This file was deleted.

40 changes: 0 additions & 40 deletions Makefile

This file was deleted.

29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "tldr",
"version": "1.0.0",
"description": "Simplified, community-driven man pages",
"dependencies": {
"glob": "^6.0.4",
"markdownlint-cli": "^0.0.2",
"tldr-lint": "^0.0.7",
"husky": "^0.10.2"
},
"scripts": {
"precommit": "npm test",
"lint-markdown": "markdownlint pages/**/*.md",
"lint-tldr": "tldr-lint ./pages",
"test": "markdownlint pages/**/*.md && tldr-lint ./pages",
"build-index": "node ./scripts/build-index.js > pages/index.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tldr-pages/tldr.git"
},
"author": "Romain Prieto",
"private": true,
"license": "MIT",
"bugs": {
"url": "https://github.com/tldr-pages/tldr/issues"
},
"homepage": "http://tldr-pages.github.io"
}
47 changes: 47 additions & 0 deletions scripts/build-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

var glob = require("glob");

function parsePlatform(pagefile) {
return pagefile.split(/\//)[1];
}

function parsePagename(pagefile) {
return pagefile.split(/\//)[2].replace(/\.md$/, '');
}

function buildShortPagesIndex(files) {
var reducer = function(index, file) {
var os = parsePlatform(file);
var page = parsePagename(file);
if (index[page]) {
index[page].push(os);
} else {
index[page] = [os];
}
return index;
};

return files.reduce(reducer, {});
}

function buildPagesIndex(shortIndex) {
return Object.keys(shortIndex)
.sort()
.map(function(page) {
return {
name: page,
platform: shortIndex[page]
};
});
}

function saveIndex(index) {
console.log(JSON.stringify(index));
}

glob("pages/**/*.md", function (er, files) {
var shortIndex = buildShortPagesIndex(files);
var index = buildPagesIndex(shortIndex);
saveIndex(index);
});
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function initialize {
}

function rebuild_index {
$TLDRHOME/scripts/build_index.rb
npm run build-index
}

function build_archive {
Expand Down
25 changes: 0 additions & 25 deletions scripts/build_index.rb

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/markdown-style.rb

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/pre-commit

This file was deleted.

0 comments on commit 72196b0

Please sign in to comment.