|
|
@ -2,11 +2,10 @@ |
|
|
|
import fs from "fs"; |
|
|
|
import fs from "fs"; |
|
|
|
import assert from "assert"; |
|
|
|
import assert from "assert"; |
|
|
|
import logging from '../lib/logging.js'; |
|
|
|
import logging from '../lib/logging.js'; |
|
|
|
import { mkdir, mkdir_to, glob } from "../lib/builderator.js"; |
|
|
|
import { mkdir_to, glob } from "../lib/builderator.js"; |
|
|
|
import { create_renderer } from "../lib/docgen.js"; |
|
|
|
import { create_renderer } from "../lib/docgen.js"; |
|
|
|
import path from "path"; |
|
|
|
import path from "path"; |
|
|
|
import slugify from "slugify"; |
|
|
|
import slugify from "slugify"; |
|
|
|
import template from "lodash/template.js"; |
|
|
|
|
|
|
|
import * as acorn from "acorn"; |
|
|
|
import * as acorn from "acorn"; |
|
|
|
import * as acorn_walk from "acorn-walk"; |
|
|
|
import * as acorn_walk from "acorn-walk"; |
|
|
|
|
|
|
|
|
|
|
@ -16,6 +15,7 @@ export const description = "Describe your command here." |
|
|
|
|
|
|
|
|
|
|
|
// your command uses the npm package commander's options format
|
|
|
|
// your command uses the npm package commander's options format
|
|
|
|
export const options = [ |
|
|
|
export const options = [ |
|
|
|
|
|
|
|
["--quiet", "Don't output the stats at the end."] |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
// example of a positional argument, it's the 1st argument to main
|
|
|
|
// example of a positional argument, it's the 1st argument to main
|
|
|
@ -28,6 +28,7 @@ export const required = [ |
|
|
|
|
|
|
|
|
|
|
|
const RENDERER = create_renderer(); |
|
|
|
const RENDERER = create_renderer(); |
|
|
|
const CAPS_WORDS = ["BUG", "TODO", "WARNING", "FOOTGUN", "DEPRECATED"]; |
|
|
|
const CAPS_WORDS = ["BUG", "TODO", "WARNING", "FOOTGUN", "DEPRECATED"]; |
|
|
|
|
|
|
|
const STATS = {total: 0, docs: 0, undoc: 0}; |
|
|
|
|
|
|
|
|
|
|
|
const slug = (instring) => slugify(instring, { lower: true, strict: true, trim: true}); |
|
|
|
const slug = (instring) => slugify(instring, { lower: true, strict: true, trim: true}); |
|
|
|
|
|
|
|
|
|
|
@ -98,6 +99,7 @@ class ParseWalker { |
|
|
|
|
|
|
|
|
|
|
|
new_method.code = this.slice_code(new_method.range); |
|
|
|
new_method.code = this.slice_code(new_method.range); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.update_stats(new_method); // methods can't go through add_export
|
|
|
|
new_class.methods.push(new_method); |
|
|
|
new_class.methods.push(new_method); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -142,6 +144,16 @@ class ParseWalker { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update_stats(exp) { |
|
|
|
|
|
|
|
STATS.total += 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(exp.comment) { |
|
|
|
|
|
|
|
STATS.docs += 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
STATS.undoc += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_export(id, exp) { |
|
|
|
add_export(id, exp) { |
|
|
|
exp.name = id.name; |
|
|
|
exp.name = id.name; |
|
|
|
exp.slug = exp.slug ? exp.slug : slug(id.name); |
|
|
|
exp.slug = exp.slug ? exp.slug : slug(id.name); |
|
|
@ -150,6 +162,8 @@ class ParseWalker { |
|
|
|
this.has_CAPS(exp); |
|
|
|
this.has_CAPS(exp); |
|
|
|
exp.code = this.slice_code(exp.range); |
|
|
|
exp.code = this.slice_code(exp.range); |
|
|
|
this.exported.push(exp); |
|
|
|
this.exported.push(exp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.update_stats(exp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
slice_code(range) { |
|
|
|
slice_code(range) { |
|
|
@ -314,5 +328,13 @@ export const main = async (source_globs, opts) => { |
|
|
|
// now write the grand index
|
|
|
|
// now write the grand index
|
|
|
|
const index_name = path.join(opts.output, "index.json"); |
|
|
|
const index_name = path.join(opts.output, "index.json"); |
|
|
|
fs.writeFileSync(index_name, dump(index)); |
|
|
|
fs.writeFileSync(index_name, dump(index)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const percent = Math.floor(100 * STATS.docs / STATS.total); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!opts.quiet) { |
|
|
|
|
|
|
|
console.log(`Total ${STATS.total}, ${percent}% documented (${STATS.docs} docs vs. ${STATS.undoc} no docs).`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
process.exit(0); |
|
|
|
process.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|