Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task for compiling docs to json and then to html.
- Loading branch information
Showing
6 changed files
with
130 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
var path = require('path'), | |||
yfm = require('assemble-yaml'); | |||
|
|||
module.exports = function (grunt) { | |||
grunt.registerTask('docs', function (root) { | |||
if (root !== 'moment' && root !== 'moment-timezone') { | |||
throw new Error("Missing project name.\n\nUse `grunt docs:moment` or `grunt docs:moment-timezone`"); | |||
} | |||
|
|||
var files = grunt.file.expand(path.join('docs', root, '**/*.md')), | |||
groups = [], | |||
cache = {}; | |||
|
|||
files.forEach(function (file) { | |||
var data = yfm.extract(file), | |||
groupPath = path.basename(path.dirname(file)), | |||
itemPath = path.basename(file, '.md'), | |||
groupSlug = groupPath.replace(/^\d\d-/, ''), | |||
itemSlug = itemPath.replace(/^\d\d-/, ''), | |||
group = cache[groupSlug], | |||
item = data.context; | |||
|
|||
if (!group) { | |||
group = cache[groupSlug] = { | |||
slug : groupSlug, | |||
items : [] | |||
}; | |||
groups.push(group); | |||
} | |||
|
|||
if (itemPath === '00-intro') { | |||
group.title = item.title; | |||
} | |||
|
|||
group.items.push(item); | |||
|
|||
item.body = data.content; | |||
item.slug = groupSlug + '/' + itemSlug; | |||
item.edit = 'https://github.com/moment/momentjs.com/blob/master/docs/' + groupPath + '/' + itemPath + '.md'; | |||
}); | |||
|
|||
grunt.file.write('.temp/docs/' + root + '.json', JSON.stringify(groups, null, 4)); | |||
}); | |||
|
|||
|
|||
|
|||
grunt.config('watch.docs-moment', { | |||
files: ['docs/moment/**/*.md'], | |||
tasks: ['docs:moment'] | |||
}); | |||
|
|||
grunt.config('watch.docs-moment-timezone', { | |||
files: ['docs/moment-timezone/**/*.md'], | |||
tasks: ['docs:moment-timezone'] | |||
}); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters