From 5306104efff36db300f3993753195f2ef9238ecd Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Tue, 6 Oct 2015 13:29:33 +0100 Subject: [PATCH 1/3] Add sourceFileName to templating data items --- doc.js | 1 + template.dot | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc.js b/doc.js index c62adb3..25742fa 100644 --- a/doc.js +++ b/doc.js @@ -243,6 +243,7 @@ module.exports = function (txt, filename, sourceFileName) { inside = false; eve("doc.end." + mode, null, mode, ""); itemData.line = line + 1; + itemData.sourceFileName = sourceFileName; (function (value, Clas, data, pointer) { eve.on("doc.item", function () { if (this == pointer) { diff --git a/template.dot b/template.dot index ea6375b..2390ed0 100644 --- a/template.dot +++ b/template.dot @@ -44,7 +44,7 @@ {{~it.out :item:index}}
-

{{=item[0].name}}

+

{{=item[0].name}}

From 53f949c0ae89601b0d325991fa76196c4172fb90 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Tue, 6 Oct 2015 13:38:44 +0100 Subject: [PATCH 2/3] Create output directory if it doesn't exist using mkdirp package --- dr.js | 11 ++++++++--- package.json | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dr.js b/dr.js index 38146be..e8a7021 100644 --- a/dr.js +++ b/dr.js @@ -22,6 +22,7 @@ var fs = require("fs"), format = require("./formatter.js"), dot = require("dot"), _ref = require("child_process"), + mkdirp = require("mkdirp"), // spawn = _ref.spawn, exec = _ref.exec; @@ -156,7 +157,8 @@ if (!files.length) { } json.template = json.template && path.resolve(pth, json.template); output = path.resolve(pth, json.output) || ""; - pth = output.substring(0, output.length - path.basename(output).length); + pth = path.dirname(output) + '/'; + mkdirp.sync(pth, 0755); if (json.css != "custom") { exec("mkdir " + pth + "js " + pth + "css " + pth + "fonts " + pth + "img"); exec("cp " + __dirname + "/node_modules/topcoat/css/topcoat-mobile-light.css " + pth + "css/topcoat-desktop-light.css"); @@ -225,8 +227,11 @@ if (!files.length) { toc: betterTOC }); - fs.writeFile(output || (getPath(fileName) + ".html"), html, function () { - console.log("Saved to \033[32m" + (output || getPath(fileName) + ".html") + "\033[0m\n"); + output = output || (getPath(fileName) + ".html"); + mkdirp.sync(path.dirname(output), 0755); + + fs.writeFile(output, html, function () { + console.log("Saved to \033[32m" + output + "\033[0m\n"); }); } diff --git a/package.json b/package.json index bd2d207..fd13364 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "eve": "*", "markdown": "*", + "mkdirp": "^0.5.1", "topcoat": "*", "dot": "*" }, From f5e7e3f650a5e6a2007b310536b085ab2e4add84 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Tue, 6 Oct 2015 13:40:10 +0100 Subject: [PATCH 3/3] Add hashbang for "binary" --- dr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dr.js b/dr.js index e8a7021..2daa27f 100644 --- a/dr.js +++ b/dr.js @@ -1,3 +1,5 @@ +#!/usr/bin/env node + // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License");