1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-22 08:42:08 +02:00

Merge pull request #697 from igorshubovych/no-ruby

Use NodeJS NPM package markdownlint instead of Ruby gem mdl
This commit is contained in:
Ruben Vereecken 2016-01-21 13:21:14 +02:00
commit c8e25f0baf
13 changed files with 97 additions and 120 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@
# npm specific # npm specific
node_modules node_modules
npm-debug.log

10
.markdownlintrc Normal file
View file

@ -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 file

@ -1,24 +1,13 @@
sudo: false sudo: false
cache: bundler language: node_js
language: ruby node_js:
- 'stable'
rvm: cache:
- 2.2.2 directories:
- node_modules
install:
- bundle
- . $HOME/.nvm/nvm.sh
- nvm install 5.0
- nvm use 5.0
- npm install rubenvereecken/tldr-lint
gemfile:
- Gemfile
script:
- make lint
after_success: after_success:
- bash scripts/build.sh - bash scripts/build.sh

View file

@ -74,13 +74,11 @@ Detailed explanation:
git remote add upstream https://github.com/tldr-pages/tldr 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 ```bash
# Assuming Ruby is set up # Assuming you have NodeJS
# Install bundler Ruby gem npm install
gem install bundler
make setup
``` ```
3. If you cloned a while ago, get the latest changes from upstream: 3. If you cloned a while ago, get the latest changes from upstream:

View file

@ -1,5 +0,0 @@
source 'https://rubygems.org'
group :development, :test do
gem 'mdl'
end

View file

@ -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 file

@ -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

29
package.json Normal file
View file

@ -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
scripts/build-index.js Normal file
View file

@ -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 file

@ -17,7 +17,7 @@ function initialize {
} }
function rebuild_index { function rebuild_index {
$TLDRHOME/scripts/build_index.rb npm run build-index
} }
function build_archive { function build_archive {

View file

@ -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)

View file

@ -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 file

@ -1,3 +0,0 @@
#!/bin/sh
make lint