Leaflet / Leafdoc

A lightweight NaturalDocs-like LeafletJS-style documentation generator
54 stars 19 forks source link

leafDirective doesn't work #10

Closed ghost closed 9 years ago

ghost commented 9 years ago
function redoLeafDirective(char) {
    leafDirective = XRegExp('  \\s* ' + char + ' (?<directive> \\S+ ) (\\s+ (?<content> [^;\\n]+ )){0,1} ', 'gnx');
    // I think we need this line
    module.exports.leafDirective = leafDirective;
}
IvanSanchez commented 9 years ago

I think we need this line

No, because leafDirective is a persistent variable within the module, and exports will keep a reference to it.

ghost commented 9 years ago

Could you tell me which node version you are using? In fact, I've tried leafDirective with node 5.1.0, and directives were not parsed properly.

As an experiment, I wrote this code: a.js

var b = require('./b');

console.log(b.foo);
b.f(444);
console.log(b.foo);

b.js

var foo = 123;

function f(arg) {
    foo = arg;
    console.log("f called");
};

module.exports = { 
    foo: foo,
    f: f
};

Result:

$ node a.js
123
f called
123