chore(docs): make left menu manually generated

This commit is contained in:
Andy Joslin
2014-03-17 10:23:05 -06:00
parent bd66fc8b28
commit 5e865962b0
6 changed files with 42 additions and 35 deletions

View File

@@ -5,7 +5,7 @@ First, follow these steps: https://github.com/driftyco/ionic#documentation
**Templates in `templates` folder**
- `templates/pages-data.template.html` => `_layout/docs_0.9.0.html`
- `templates/pages-data.template.html` => `_layout/docs_api.html`
- `templates/index.template.html` => The 'index' page for a doc version - http://ajoslin.github.io/docs/0.9.26/
- `templates/lib/yaml.template.html` => the common yaml config items that every doc page includes
- `templates/api/componentGroup.template.html` => the template for every 'componentGroup' (eg http://ajoslin.github.io/docs/0.9.26/api/ionic/directive/)
@@ -13,3 +13,11 @@ First, follow these steps: https://github.com/driftyco/ionic#documentation
- `templates/api/{something}.template.html` - the template for {something} - eg directive.template.html for directives
Not everything in all the pages is used - a lot of it is from Angular templates. Eg things like 'doc.deprecated' aren't used currently.
**New Versions**
Every version uses its own include for left menu, which is manually written.
The first time a version is generated, if there is no _includes/api_menu_{{versionName}}.html, it will generate a generic one for you.
Then you can do what you want to edit that.

View File

@@ -66,7 +66,8 @@ module.exports = function(config) {
require('./processors/keywords'),
require('./processors/pages-data'),
require('./processors/index-page'),
require('./processors/version-data')
require('./processors/version-data'),
require('./processors/output')
]);
return config;

29
docs/processors/output.js Normal file
View File

@@ -0,0 +1,29 @@
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 '<li class="menu-item{% if page.path == "' + link.replace(/^.*?\/api/, 'api') + '" %} active{% endif %}">\n' +
' <a href="' + link + '">' + link.replace(/^.*?\/api\//, '') + '</a>\n' +
'</li>';
}).join('\n'));
}
}
};

View File

@@ -21,11 +21,5 @@ module.exports = [
},
{
name: 'alias'
},
{
name: 'group'
},
{
name: 'groupMainItem'
}
];

View File

@@ -1,5 +1,4 @@
layout: docs_api
layout: "docs_api"
version: "<$ version.current.name $>"
versionHref: "<$ version.current.href $>"
path: "<$ doc.path $>"
group: "<$ doc.group $>"

View File

@@ -61,31 +61,7 @@
JavaScript
</a>
</li>
<@ for group in doc.groups @>
<div class="menu-group-container{% if page.group == "<$ group.name $>" %} active{% endif %}">
<li class="menu-group">
<a href="{{page.versionHref}}/<$ group.sections[0].pages[0].href $>">
<@ if group.name == "Other" @>User Interaction<@ else @><$ group.name $><@ endif @>
</a>
</li>
<@ for section in group.sections @>
<div class="menu-section">
<$ section.name $>
</div>
<@ for component in section.pages @>
<li class="menu-item{% if page.doc == "<$ component.name $>" %} active{% endif %}">
<a href="{{page.versionHref}}/<$ component.href $>">
<@ if component.type == "directive" @>
<$ component.name | dashCase $>
<@ else @>
<$ component.name $>
<@ endif @>
</a>
</li>
<@ endfor @>
<@ endfor @>
</div>
<@ endfor @>
{% include api_menu_<$ version.current.name $>.html %}
</ul>
<ul class="nav left-menu">