diff --git a/build/tasks/docs-task.coffee b/build/tasks/docs-task.coffee index e6bb0f041..dff208d69 100644 --- a/build/tasks/docs-task.coffee +++ b/build/tasks/docs-task.coffee @@ -52,9 +52,6 @@ module.exports = (grunt) -> {cp, mkdir, rm} = require('./task-helpers')(grunt) - relativePathForArticle = (filename) -> - filename[0..-4]+'.html' - relativePathForClass = (classname) -> classname+'.html' @@ -170,51 +167,8 @@ module.exports = (grunt) -> # Parse Article Markdown - articles = [] - articlesPath = path.resolve(__dirname, '..', '..', 'docs') - fs.traverseTreeSync articlesPath, (file) -> - 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 - - articles.push({ - html: html - meta: meta - name: meta.title - filename: filename - link: relativePathForArticle(filename) - }) - - # Sort articles by the `Order` flag when present. Lower order, higher in list. - articles.sort (a, b) -> - (a.meta?.order ? 1000)/1 - (b.meta?.order ? 1000)/1 - # Build Sidebar metadata we can hand off to each of the templates to # generate the sidebar - sidebar = {sections: []} - sidebar.sections.push - name: 'Getting Started' - items: articles.filter ({meta}) -> meta.section is 'Getting Started' - - sidebar.sections.push - name: 'Guides' - items: articles.filter ({meta}) -> meta.section is 'Guides' - - sidebar.sections.push - name: 'Sample Code' - items: [{ - name: 'Composer Translation' - link: 'https://github.com/nylas/edgehill-plugins/tree/master/translate' - external: true - },{ - name: 'Github Sidebar' - link: 'https://github.com/nylas/edgehill-plugins/tree/master/sidebar-github-profile' - external: true - }] referenceSections = {} for klass in classes @@ -233,13 +187,18 @@ module.exports = (grunt) -> for key, val of referenceSections sorted.push(val) - sidebar.sections.push - name: 'API Reference' - items: sorted.map ({name, classes}) -> + api_sidebar_meta = sorted.map ({name, classes}) -> name: name - items: classes.map ({name}) -> {name: name, link: relativePathForClass(name) } + items: classes.map ({name}) -> {name: name, link: relativePathForClass(name), slug: name.toLowerCase() } + + console.log("Here's the sidebar info:") + console.log(api_sidebar_meta.toString()) + + docsOutputDir = grunt.config.get('docsOutputDir') + sidebarJson = JSON.stringify(api_sidebar_meta, null, 2) + sidebarPath = path.join(docsOutputDir, '_sidebar.json') + grunt.file.write(sidebarPath, sidebarJson) - console.log(sidebar) # Prepare to render by loading handlebars partials @@ -255,10 +214,6 @@ module.exports = (grunt) -> for classname, val of apiJSON.classes knownClassnames[classname.toLowerCase()] = val - knownArticles = {} - for article in articles - knownArticles[article.filename.toLowerCase()] = article - expandTypeReferences = (val) -> refRegex = /{([\w.]*)}/g while (match = refRegex.exec(val)) isnt null @@ -271,9 +226,6 @@ module.exports = (grunt) -> url = thirdPartyClasses[term] else if knownClassnames[term] url = relativePathForClass(term) - else if knownArticles[term] - label = knownArticles[term].meta.title - url = relativePathForArticle(knownArticles[term].filename) else console.warn("Cannot find class named #{term}") @@ -307,25 +259,5 @@ module.exports = (grunt) -> processFields(documentation, ['description'], [marked.noMeta, expandTypeReferences, expandFuncReferences]) processFields(documentation, ['type'], [expandTypeReferences]) - result = classTemplate({name, documentation, section, sidebar}) + result = classTemplate({name, documentation, section}) grunt.file.write(outputPathFor(relativePathForClass(name)), result) - - # Render Article Pages - - articleTemplatePath = path.join(templatesPath, 'article.html') - articleTemplate = Handlebars.compile(grunt.file.read(articleTemplatePath)) - - for {name, meta, html, filename} in articles - # Process the article content to expand references to types, functions - for task in [expandTypeReferences, expandFuncReferences] - html = task(html) - - result = articleTemplate({name, meta, html, sidebar}) - grunt.file.write(outputPathFor(relativePathForArticle(filename)), result) - - # Copy styles and images - - imagesPath = path.resolve(__dirname, '..', '..', 'docs', 'images') - cssPath = path.resolve(__dirname, '..', '..', 'docs', 'css') - cp imagesPath, path.join(docsOutputDir, "images") - cp cssPath, path.join(docsOutputDir, "css") diff --git a/docs-templates/_footer.html b/docs-templates/_footer.html deleted file mode 100644 index dd2eb354a..000000000 --- a/docs-templates/_footer.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
- -