fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
path = require 'path'
|
2015-04-25 02:33:10 +08:00
|
|
|
Handlebars = require 'handlebars'
|
2015-05-14 02:44:28 +08:00
|
|
|
marked = require 'meta-marked'
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
fs = require 'fs-plus'
|
2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-28 04:29:08 +08:00
|
|
|
marked.setOptions
|
|
|
|
highlight: (code) ->
|
|
|
|
require('highlight.js').highlightAuto(code).value
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
standardClassURLRoot = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/'
|
|
|
|
|
|
|
|
standardClasses = [
|
|
|
|
'string',
|
|
|
|
'object',
|
|
|
|
'array',
|
|
|
|
'function',
|
|
|
|
'number',
|
|
|
|
'date',
|
|
|
|
'error',
|
|
|
|
'boolean',
|
|
|
|
'null',
|
|
|
|
'undefined',
|
|
|
|
'json',
|
|
|
|
'set',
|
|
|
|
'map',
|
|
|
|
'typeerror',
|
|
|
|
'syntaxerror',
|
|
|
|
'referenceerror',
|
2015-04-29 01:38:24 +08:00
|
|
|
'rangeerror'
|
2015-04-25 02:33:10 +08:00
|
|
|
]
|
|
|
|
|
2015-04-28 08:28:51 +08:00
|
|
|
thirdPartyClasses = {
|
|
|
|
'react.component': 'https://facebook.github.io/react/docs/component-api.html',
|
2015-04-29 01:38:24 +08:00
|
|
|
'promise': 'https://github.com/petkaantonov/bluebird/blob/master/API.md',
|
|
|
|
'range': 'https://developer.mozilla.org/en-US/docs/Web/API/Range',
|
|
|
|
'selection': 'https://developer.mozilla.org/en-US/docs/Web/API/Selection',
|
|
|
|
'node': 'https://developer.mozilla.org/en-US/docs/Web/API/Node',
|
2015-04-28 08:28:51 +08:00
|
|
|
}
|
|
|
|
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
module.exports = (grunt) ->
|
2015-05-09 10:17:09 +08:00
|
|
|
|
|
|
|
{cp, mkdir, rm} = require('./task-helpers')(grunt)
|
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
relativePathForGuide = (filename) ->
|
2015-10-03 01:54:57 +08:00
|
|
|
filename[0..-4]+'.html'
|
2015-09-09 08:10:29 +08:00
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
relativePathForClass = (classname) ->
|
2015-10-03 01:54:57 +08:00
|
|
|
classname+'.html'
|
2015-05-14 02:44:28 +08:00
|
|
|
|
|
|
|
outputPathFor = (relativePath) ->
|
|
|
|
docsOutputDir = grunt.config.get('docsOutputDir')
|
|
|
|
path.join(docsOutputDir, relativePath)
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
processFields = (json, fields = [], tasks = []) ->
|
|
|
|
if json instanceof Array
|
|
|
|
for val in json
|
|
|
|
processFields(val, fields, tasks)
|
|
|
|
else
|
|
|
|
for key, val of json
|
|
|
|
if key in fields
|
|
|
|
for task in tasks
|
|
|
|
val = task(val)
|
|
|
|
json[key] = val
|
|
|
|
if _.isObject(val)
|
|
|
|
processFields(val, fields, tasks)
|
|
|
|
|
|
|
|
grunt.registerTask 'render-docs', 'Builds html from the API docs', ->
|
|
|
|
docsOutputDir = grunt.config.get('docsOutputDir')
|
2015-05-14 02:44:28 +08:00
|
|
|
|
|
|
|
# Parse API reference Markdown
|
|
|
|
|
|
|
|
classes = []
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
apiJsonPath = path.join(docsOutputDir, 'api.json')
|
2015-05-14 02:44:28 +08:00
|
|
|
apiJSON = JSON.parse(grunt.file.read(apiJsonPath))
|
|
|
|
|
|
|
|
for classname, contents of apiJSON.classes
|
|
|
|
# Parse a "@Section" out of the description if one is present
|
|
|
|
sectionRegex = /Section: ?([\w ]*)(?:$|\n)/
|
|
|
|
section = 'General'
|
2015-10-02 04:19:34 +08:00
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
match = sectionRegex.exec(contents.description)
|
|
|
|
if match
|
|
|
|
contents.description = contents.description.replace(match[0], '')
|
|
|
|
section = match[1].trim()
|
|
|
|
|
|
|
|
# Replace superClass "React" with "React.Component". The Coffeescript Lexer
|
|
|
|
# is so bad.
|
|
|
|
if contents.superClass is "React"
|
|
|
|
contents.superClass = "React.Component"
|
|
|
|
|
|
|
|
classes.push({
|
|
|
|
name: classname
|
|
|
|
documentation: contents
|
|
|
|
section: section
|
|
|
|
})
|
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
# Parse guide Markdown
|
2015-05-14 02:44:28 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
guides = []
|
2015-10-03 01:54:57 +08:00
|
|
|
guidesPath = path.resolve(__dirname, '..', '..', 'docs')
|
2015-10-02 04:19:34 +08:00
|
|
|
fs.traverseTreeSync guidesPath, (file) ->
|
2015-09-09 08:10:29 +08:00
|
|
|
if path.extname(file) is '.md'
|
|
|
|
{html, meta} = marked(grunt.file.read(file))
|
|
|
|
|
|
|
|
filename = path.basename(file)
|
|
|
|
meta ||= {title: filename}
|
|
|
|
for key, val of meta
|
|
|
|
meta[key.toLowerCase()] = val
|
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
guides.push({
|
2015-09-09 08:10:29 +08:00
|
|
|
html: html
|
|
|
|
meta: meta
|
|
|
|
name: meta.title
|
|
|
|
filename: filename
|
2015-10-02 04:19:34 +08:00
|
|
|
link: relativePathForGuide(filename)
|
2015-09-09 08:10:29 +08:00
|
|
|
})
|
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
# Sort guides by the `Order` flag when present. Lower order, higher in list.
|
|
|
|
guides.sort (a, b) ->
|
2015-09-09 08:10:29 +08:00
|
|
|
(a.meta?.order ? 1000)/1 - (b.meta?.order ? 1000)/1
|
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
# Build Sidebar metadata we can hand off to each of the templates to
|
|
|
|
# generate the sidebar
|
2015-09-09 08:10:29 +08:00
|
|
|
sidebar = {sections: []}
|
|
|
|
sidebar.sections.push
|
|
|
|
name: 'Getting Started'
|
2015-10-02 04:19:34 +08:00
|
|
|
items: guides.filter ({meta}) -> meta.section is 'Getting Started'
|
2015-09-09 08:10:29 +08:00
|
|
|
|
|
|
|
sidebar.sections.push
|
|
|
|
name: 'Guides'
|
2015-10-02 04:19:34 +08:00
|
|
|
items: guides.filter ({meta}) -> meta.section is 'Guides'
|
2015-09-09 08:10:29 +08:00
|
|
|
|
|
|
|
sidebar.sections.push
|
|
|
|
name: 'Sample Code'
|
2015-10-05 20:08:53 +08:00
|
|
|
link: 'https://nylas.com/N1/examples'
|
2015-10-03 07:09:44 +08:00
|
|
|
external: true
|
2015-05-14 02:44:28 +08:00
|
|
|
|
|
|
|
referenceSections = {}
|
|
|
|
for klass in classes
|
|
|
|
section = referenceSections[klass.section]
|
|
|
|
if not section
|
|
|
|
section = {name: klass.section, classes: []}
|
|
|
|
referenceSections[klass.section] = section
|
|
|
|
section.classes.push(klass)
|
|
|
|
|
2015-11-12 02:25:11 +08:00
|
|
|
preferredSectionOrdering = ['General', 'Component Kit', 'Models', 'Stores', 'Database', 'Drafts', 'NylasEnv']
|
2015-05-14 02:44:28 +08:00
|
|
|
sorted = []
|
|
|
|
for key in preferredSectionOrdering
|
|
|
|
if referenceSections[key]
|
|
|
|
sorted.push(referenceSections[key])
|
|
|
|
delete referenceSections[key]
|
|
|
|
for key, val of referenceSections
|
|
|
|
sorted.push(val)
|
|
|
|
|
2015-09-09 08:10:29 +08:00
|
|
|
sidebar.sections.push
|
|
|
|
name: 'API Reference'
|
|
|
|
items: sorted.map ({name, classes}) ->
|
|
|
|
name: name
|
|
|
|
items: classes.map ({name}) -> {name: name, link: relativePathForClass(name) }
|
2015-05-14 02:44:28 +08:00
|
|
|
|
|
|
|
# Prepare to render by loading handlebars partials
|
2015-04-28 08:28:51 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
templatesPath = path.resolve(__dirname, '..', '..', 'docs', 'templates')
|
2015-04-25 02:33:10 +08:00
|
|
|
grunt.file.recurse templatesPath, (abspath, root, subdir, filename) ->
|
|
|
|
if filename[0] is '_' and path.extname(filename) is '.html'
|
|
|
|
Handlebars.registerPartial(filename[0..-6], grunt.file.read(abspath))
|
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
# Render Helpers
|
2015-05-09 10:17:09 +08:00
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
knownClassnames = {}
|
|
|
|
for classname, val of apiJSON.classes
|
|
|
|
knownClassnames[classname.toLowerCase()] = val
|
2015-04-25 02:33:10 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
knownGuides = {}
|
|
|
|
for guide in guides
|
|
|
|
knownGuides[guide.filename.toLowerCase()] = guide
|
2015-09-09 08:10:29 +08:00
|
|
|
|
|
|
|
expandTypeReferences = (val) ->
|
|
|
|
refRegex = /{([\w.]*)}/g
|
|
|
|
while (match = refRegex.exec(val)) isnt null
|
|
|
|
term = match[1].toLowerCase()
|
|
|
|
label = match[1]
|
|
|
|
url = false
|
|
|
|
if term in standardClasses
|
|
|
|
url = standardClassURLRoot+term
|
|
|
|
else if thirdPartyClasses[term]
|
|
|
|
url = thirdPartyClasses[term]
|
|
|
|
else if knownClassnames[term]
|
2015-10-05 05:27:44 +08:00
|
|
|
url = relativePathForClass(knownClassnames[term].name)
|
2015-10-02 04:19:34 +08:00
|
|
|
else if knownGuides[term]
|
|
|
|
label = knownGuides[term].meta.title
|
|
|
|
url = relativePathForGuide(knownGuides[term].filename)
|
2015-09-09 08:10:29 +08:00
|
|
|
else
|
|
|
|
console.warn("Cannot find class named #{term}")
|
|
|
|
|
|
|
|
if url
|
|
|
|
val = val.replace(match[0], "<a href='#{url}'>#{label}</a>")
|
|
|
|
val
|
|
|
|
|
|
|
|
expandFuncReferences = (val) ->
|
|
|
|
refRegex = /{([\w]*)?::([\w]*)}/g
|
|
|
|
while (match = refRegex.exec(val)) isnt null
|
|
|
|
[text, a, b] = match
|
|
|
|
url = false
|
|
|
|
if a and b
|
|
|
|
url = "#{relativePathForClass(a)}##{b}"
|
|
|
|
label = "#{a}::#{b}"
|
|
|
|
else
|
|
|
|
url = "##{b}"
|
|
|
|
label = "#{b}"
|
|
|
|
if url
|
|
|
|
val = val.replace(text, "<a href='#{url}'>#{label}</a>")
|
|
|
|
val
|
|
|
|
|
2015-10-03 01:54:57 +08:00
|
|
|
# Render sidebar json
|
2015-10-02 04:19:34 +08:00
|
|
|
|
2015-10-03 01:54:57 +08:00
|
|
|
grunt.file.write(outputPathFor('sidebar.json'), JSON.stringify(sidebar, null, 2))
|
2015-10-03 07:09:44 +08:00
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
# Render Class Pages
|
|
|
|
|
|
|
|
classTemplatePath = path.join(templatesPath, 'class.html')
|
|
|
|
classTemplate = Handlebars.compile(grunt.file.read(classTemplatePath))
|
2015-04-25 02:33:10 +08:00
|
|
|
|
2015-05-14 02:44:28 +08:00
|
|
|
for {name, documentation, section} in classes
|
|
|
|
# Recursively process `description` and `type` fields to process markdown,
|
|
|
|
# expand references to types, functions and other files.
|
2015-09-09 08:10:29 +08:00
|
|
|
processFields(documentation, ['description'], [marked.noMeta, expandTypeReferences, expandFuncReferences])
|
|
|
|
processFields(documentation, ['type'], [expandTypeReferences])
|
2015-05-09 10:17:09 +08:00
|
|
|
|
2015-09-09 08:10:29 +08:00
|
|
|
result = classTemplate({name, documentation, section, sidebar})
|
2015-05-14 02:44:28 +08:00
|
|
|
grunt.file.write(outputPathFor(relativePathForClass(name)), result)
|
2015-09-09 08:10:29 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
# Render Guide Pages
|
2015-09-09 08:10:29 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
guideTemplatePath = path.join(templatesPath, 'guide.html')
|
|
|
|
guideTemplate = Handlebars.compile(grunt.file.read(guideTemplatePath))
|
2015-09-09 08:10:29 +08:00
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
for {name, meta, html, filename} in guides
|
|
|
|
# Process the guide content to expand references to types, functions
|
2015-09-09 08:10:29 +08:00
|
|
|
for task in [expandTypeReferences, expandFuncReferences]
|
|
|
|
html = task(html)
|
|
|
|
|
2015-10-02 04:19:34 +08:00
|
|
|
result = guideTemplate({name, meta, html, sidebar})
|
|
|
|
grunt.file.write(outputPathFor(relativePathForGuide(filename)), result)
|
|
|
|
|
|
|
|
# Remove temp cjsx output
|
|
|
|
rm(outputPathFor("temp-cjsx"))
|