From 565a99a64f2e6ea530b97e65443bf04aabec9a66 Mon Sep 17 00:00:00 2001 From: Danny Nemer Date: Thu, 24 Sep 2015 11:25:51 -0400 Subject: [PATCH] Add option for alphabetic sorting Adds `options.sort` to `docdown(options)`. If `options.sort` is `true`, then the methods (and categories, if enabled) are sorted alphabetically in the documentation. If `false`, then methods (and categories) are ordered as they appear in source. Defaults to `true`. Fixes: #3 --- index.js | 1 + lib/generator.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b73ea6b..9f6aa98 100755 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ function docdown(options) { 'lang': 'js', 'sort': true, 'title': path.basename(options.path) + ' API documentation', + 'sort': true, 'toc': 'properties' }); diff --git a/lib/generator.js b/lib/generator.js index 0b4bbc1..6810e8f 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -267,7 +267,7 @@ function generateDoc(source, options) { // Sort categories and add special categories back. if (sortEntries) { - tocGroups.sort(util.compareNatural); + if (sortEntries) tocGroups.sort(util.compareNatural); } push.apply(tocGroups, catogoriesUsed); } @@ -354,4 +354,4 @@ function generateDoc(source, options) { return docMarkdown.join('\n'); } -module.exports = generateDoc; +module.exports = generateDoc; \ No newline at end of file