mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-22 05:42:09 +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:
commit
c8e25f0baf
13 changed files with 97 additions and 120 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@
|
|||
|
||||
# npm specific
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
|
10
.markdownlintrc
Normal file
10
.markdownlintrc
Normal 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
|
||||
}
|
23
.travis.yml
23
.travis.yml
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
5
Gemfile
5
Gemfile
|
@ -1,5 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'mdl'
|
||||
end
|
19
Gemfile.lock
19
Gemfile.lock
|
@ -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
|
40
Makefile
40
Makefile
|
@ -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
29
package.json
Normal 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
47
scripts/build-index.js
Normal 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);
|
||||
});
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
make lint
|
Loading…
Add table
Reference in a new issue