Use NodeJS NPM package markdownlint instead of Ruby gem mdl
This commit is contained in:
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
|
Reference in New Issue
Block a user