Permalink
Browse files

Use NodeJS NPM package markdownlint instead of Ruby gem mdl

  • Loading branch information...
1 parent 5f6b09b commit 72196b030d7644d36762feae9195fc9e97e6ed78 @igorshubovych igorshubovych committed Jan 19, 2016
Showing with 97 additions and 120 deletions.
  1. +1 −0 .gitignore
  2. +10 −0 .markdownlintrc
  3. +6 −17 .travis.yml
  4. +3 −5 CONTRIBUTING.md
  5. +0 −5 Gemfile
  6. +0 −19 Gemfile.lock
  7. +0 −40 Makefile
  8. +29 −0 package.json
  9. +47 −0 scripts/build-index.js
  10. +1 −1 scripts/build.sh
  11. +0 −25 scripts/build_index.rb
  12. +0 −5 scripts/markdown-style.rb
  13. +0 −3 scripts/pre-commit
View
@@ -6,3 +6,4 @@
# npm specific
node_modules
+npm-debug.log
View
@@ -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
+}
View
@@ -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
View
@@ -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:
View
@@ -1,5 +0,0 @@
-source 'https://rubygems.org'
-
-group :development, :test do
- gem 'mdl'
-end
View
@@ -1,19 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- kramdown (1.9.0)
- mdl (0.2.1)
- kramdown (~> 1.5, >= 1.5.0)
- mixlib-cli (~> 1.5, >= 1.5.0)
- mixlib-config (~> 2.1, >= 2.1.0)
- mixlib-cli (1.5.0)
- mixlib-config (2.2.1)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- mdl
-
-BUNDLED WITH
- 1.11.2
View
@@ -1,40 +0,0 @@
-default: lint
-
-index:
- @echo "WARNING!"
- @echo "Index rebuilding is deprecated."
- @echo "You should not do it, unless you understand why you doing this."
- @echo
- @TLDRHOME=`pwd` ./scripts/build_index.rb
- @echo "Index rebuilt."
-
-setup: prerequisites hooks deps
-
-prerequisites:
- @echo
- @echo "IMPORTANT!"
- @echo "Before setting up hooks, make sure you have read Contributing Guidelines"
- @echo "https://github.com/tldr-pages/tldr/blob/master/CONTRIBUTING.md#submitting-a-pull-request"
- @echo
- @echo "TL;DR:"
- @echo "1. Install Ruby suitable for your system"
- @echo "2. Run 'gem install bundler'"
- @echo "3. Install node 5.x"
- @echo "4. Install npm"
- @echo
-
-hooks:
- @cp ./scripts/pre-commit .git/hooks
- @chmod +x .git/hooks/pre-commit
- @echo "Git pre-commit hook installed."
-
-deps:
- @bundle
- @npm install rubenvereecken/tldr-lint
- @echo "OK"
-
-lint:
- @`pwd`/node_modules/.bin/tldr-lint ./pages
- @bundle exec mdl --style ./scripts/markdown-style.rb pages
-
-.PHONY: default index setup prerequisites hooks deps lint
View
@@ -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"
+}
@@ -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);
+});
View
@@ -17,7 +17,7 @@ function initialize {
}
function rebuild_index {
- $TLDRHOME/scripts/build_index.rb
+ npm run build-index
}
function build_archive {
@@ -1,25 +0,0 @@
-#!/usr/bin/env ruby
-
-require "json"
-
-commands = {}
-
-Dir["#{ENV["TLDRHOME"]}/pages/**/*.md"].each do |file|
- # "./pages/osx/xsltproc.md",
- file = file.split("/")
- name = file.pop().gsub(".md","")
- platform = file.pop()
-
- unless commands.key?(name)
- commands[name] = {
- name: name,
- platform: [platform]
- }
- else
- commands[name][:platform] << platform
- end
-end
-
-commands = commands.sort.map do |k,v| v end
-
-File.write("#{ENV["TLDRHOME"]}/pages/index.json", {commands: commands}.to_json)
@@ -1,5 +0,0 @@
-# This file contains the markdown rules markdownlint will check for
-all
-
-exclude_rule 'MD013' # Lengthy lines (80+ chars)
-exclude_rule 'MD034' # Allow bare URLs
View
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-make lint

0 comments on commit 72196b0

Please sign in to comment.