From e9bf43a81343bb34d2dd5fe8f29925b5fa6fc947 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Mon, 17 Mar 2014 14:22:05 -0600 Subject: [PATCH] docs: sort by groups by default --- docs/docs.config.js | 3 +- docs/processors/output.js | 29 -------- docs/processors/pages-data.js | 77 ++++++++------------- docs/templates/menu-data.template.html | 12 ++++ js/ext/angular/src/directive/ionicNavBar.js | 6 +- 5 files changed, 46 insertions(+), 81 deletions(-) delete mode 100644 docs/processors/output.js create mode 100644 docs/templates/menu-data.template.html diff --git a/docs/docs.config.js b/docs/docs.config.js index bcc381da6c..2c8fd31177 100644 --- a/docs/docs.config.js +++ b/docs/docs.config.js @@ -66,8 +66,7 @@ module.exports = function(config) { require('./processors/keywords'), require('./processors/pages-data'), require('./processors/index-page'), - require('./processors/version-data'), - require('./processors/output') + require('./processors/version-data') ]); return config; diff --git a/docs/processors/output.js b/docs/processors/output.js deleted file mode 100644 index 657e1f0e4c..0000000000 --- a/docs/processors/output.js +++ /dev/null @@ -1,29 +0,0 @@ -var _ = require('lodash'); -var path = require('canonical-path'); -var fs = require('fs'); - -module.exports = { - name: 'output', - description: 'log all doc urls after everything is done', - runAfter: ['files-written'], - process: function(docs, config) { - var links = docs - .filter(function(doc) { - return doc.match(/\/api\/.*?\/index.md$/) && doc.indexOf('/module/ionic') == -1; - }) - .map(function(doc) { - return doc.replace(/^.*?\/docs/,'/docs').replace(/\/index.md$/, ''); - }); - - var outputFolder = path.join(config.get('basePath'), config.get('rendering.outputFolder')); - var menuInclude = path.join(outputFolder, '_includes/api_menu_' + config.versionData.current.name + '.html'); - - if (!fs.existsSync(menuInclude)) { - fs.writeFileSync(menuInclude, links.map(function(link) { - return ''; - }).join('\n')); - } - } -}; diff --git a/docs/processors/pages-data.js b/docs/processors/pages-data.js index 8cba473598..3ea54787ef 100644 --- a/docs/processors/pages-data.js +++ b/docs/processors/pages-data.js @@ -1,4 +1,5 @@ var _ = require('lodash'); +var fs = require('fs'); var path = require('canonical-path'); var log = require('winston'); @@ -17,7 +18,7 @@ module.exports = { processorConfig = config.get('processing.pages-data', {}); currentVersion = config.get('currentVersion'); }, - process: function(docs) { + process: function(docs, config) { // Generate an object collection of pages that is grouped by section e.g. // - section "directive" // - group "Tab Bar" @@ -28,67 +29,49 @@ module.exports = { // - ion-checkbox // - ... // - var groups = _(docs) + var sections = _(docs) .filter(function(doc) { return doc.area === 'api'; }) .filter(function(doc) { return doc.module === 'ionic'; }) .filter(function(doc) { return doc.docType !== 'componentGroup'; }) - .groupBy(function(doc) { if (!doc.group) doc.group = 'Other'; return doc.group; }) - .map(function(pages, groupName) { - var sections = _(pages) - .groupBy('docType') - .map(function(pages, docType) { + .groupBy('docType') + .map(function(pages, docType) { + return { + name: docType, + components: pages.map(function(page) { return { - name: docType, - pages: _(pages) - .sortBy(function(doc) { - return doc.groupMainItem; - }) - .map(function(doc) { - return { - href: doc.path, - name: doc.name, - docType: doc.docType, - type: doc.docType, - }; - }) - .filter(function(doc) { - return !!doc.name; - }) - .value() + href: page.path, + name: page.name, + docType: page.docType, + type: page.docType }; }) - .sortBy(function(section) { - //Directives always first - return section.name != 'directive'; - }) - .value(); - - return { - name: groupName, - sections: sections }; }) - .sortBy(function(group) { - //Sort by groups with most items last - return _.values(group.sections).length; + .sortBy(function(section) { + //Directives always first + return section.name != 'directive'; }) .value(); - _.forEach(docs, function(doc) { - if ( !doc.path ) { - log.warn('Missing path property for ', doc.id); - } - }); + var outputFolder = path.join(config.get('basePath'), config.get('rendering.outputFolder')); + var menuFileName = '_includes/api_menu_' + config.versionData.current.name + '.html'; + var menuInclude = path.join(outputFolder, menuFileName); - var docData = { + if (!fs.existsSync(menuInclude)) { + docs.push({ + docType: 'menu-data', + id: 'menu-data', + template: 'menu-data.template.html', + outputPath: menuFileName, + sections: sections + }); + } + + docs.push({ docType: 'pages-data', id: 'pages-data', template: processorConfig.template || 'pages-data.template.js', outputPath: processorConfig.outputPath || 'js/pages-data.js', - - groups: groups - }; - - docs.push(docData); + }); } }; diff --git a/docs/templates/menu-data.template.html b/docs/templates/menu-data.template.html new file mode 100644 index 0000000000..e395468e0e --- /dev/null +++ b/docs/templates/menu-data.template.html @@ -0,0 +1,12 @@ +<@ for section in doc.sections @> + + <@ for component in section.components @> + + <@ endfor @> +<@ endfor @> diff --git a/js/ext/angular/src/directive/ionicNavBar.js b/js/ext/angular/src/directive/ionicNavBar.js index 99dec1854b..f5603ce60d 100644 --- a/js/ext/angular/src/directive/ionicNavBar.js +++ b/js/ext/angular/src/directive/ionicNavBar.js @@ -191,9 +191,9 @@ function($scope, $element, $ionicViewService, $animate, $compile) { * ```html * * - * + * + * * * *