| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a568ad4 commit cea1777
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,6 +108,19 @@ em code { | |||
| 108 | 108 | background-color: #0084B6; | |
| 109 | 109 | } | |
| 110 | 110 | ||
| 111 | + .api_metadata { | ||
| 112 | + font-size: .75em; | ||
| 113 | + margin-bottom: 1em; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + .api_metadata span { | ||
| 117 | + margin-right: 1em; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + .api_metadata span:last-child { | ||
| 121 | + margin-right: 0px; | ||
| 122 | + } | ||
| 123 | + | ||
| 111 | 124 | ul.plain { | |
| 112 | 125 | list-style: none; | |
| 113 | 126 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,18 +6,27 @@ Each type of heading has a description block. | |||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | 8 | ## module | |
| 9 | + <!-- YAML | ||
| 10 | + added: v0.10.0 | ||
| 11 | + --> | ||
| 9 | 12 | ||
| 10 | 13 | Stability: 3 - Stable | |
| 11 | 14 | ||
| 12 | 15 | description and examples. | |
| 13 | 16 | ||
| 14 | 17 | ### module.property | |
| 18 | + <!-- YAML | ||
| 19 | + added: v0.10.0 | ||
| 20 | + --> | ||
| 15 | 21 | ||
| 16 | 22 | * Type | |
| 17 | 23 | ||
| 18 | 24 | description of the property. | |
| 19 | 25 | ||
| 20 | 26 | ### module.someFunction(x, y, [z=100]) | |
| 27 | + <!-- YAML | ||
| 28 | + added: v0.10.0 | ||
| 29 | + --> | ||
| 21 | 30 | ||
| 22 | 31 | * `x` {String} the description of the string | |
| 23 | 32 | * `y` {Boolean} Should I stay or should I go? | |
@@ -26,17 +35,26 @@ Each type of heading has a description block. | |||
| 26 | 35 | A description of the function. | |
| 27 | 36 | ||
| 28 | 37 | ### Event: 'blerg' | |
| 38 | + <!-- YAML | ||
| 39 | + added: v0.10.0 | ||
| 40 | + --> | ||
| 29 | 41 | ||
| 30 | 42 | * Argument: SomeClass object. | |
| 31 | 43 | ||
| 32 | 44 | Modules don't usually raise events on themselves. `cluster` is the | |
| 33 | 45 | only exception. | |
| 34 | 46 | ||
| 35 | 47 | ## Class: SomeClass | |
| 48 | + <!-- YAML | ||
| 49 | + added: v0.10.0 | ||
| 50 | + --> | ||
| 36 | 51 | ||
| 37 | 52 | description of the class. | |
| 38 | 53 | ||
| 39 | 54 | ### Class Method: SomeClass.classMethod(anArg) | |
| 55 | + <!-- YAML | ||
| 56 | + added: v0.10.0 | ||
| 57 | + --> | ||
| 40 | 58 | ||
| 41 | 59 | * `anArg` {Object} Just an argument | |
| 42 | 60 | * `field` {String} anArg can have this field. | |
@@ -46,16 +64,25 @@ Each type of heading has a description block. | |||
| 46 | 64 | Description of the method for humans. | |
| 47 | 65 | ||
| 48 | 66 | ### someClass.nextSibling() | |
| 67 | + <!-- YAML | ||
| 68 | + added: v0.10.0 | ||
| 69 | + --> | ||
| 49 | 70 | ||
| 50 | 71 | * Return: {SomeClass object | null} The next someClass in line. | |
| 51 | 72 | ||
| 52 | 73 | ### someClass.someProperty | |
| 74 | + <!-- YAML | ||
| 75 | + added: v0.10.0 | ||
| 76 | + --> | ||
| 53 | 77 | ||
| 54 | 78 | * String | |
| 55 | 79 | ||
| 56 | 80 | The indication of what someProperty is. | |
| 57 | 81 | ||
| 58 | 82 | ### Event: 'grelb' | |
| 83 | + <!-- YAML | ||
| 84 | + added: v0.10.0 | ||
| 85 | + --> | ||
| 59 | 86 | ||
| 60 | 87 | * `isBlerg` {Boolean} | |
| 61 | 88 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const yaml = require('js-yaml'); | ||
| 4 | + | ||
| 5 | + function isYAMLBlock(text) { | ||
| 6 | + return !!text.match(/^<!-- YAML/); | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + exports.isYAMLBlock = isYAMLBlock; | ||
| 10 | + | ||
| 11 | + function extractAndParseYAML(text) { | ||
| 12 | + text = text.trim(); | ||
| 13 | + | ||
| 14 | + text = text.replace(/^<!-- YAML/, '') | ||
| 15 | + .replace(/-->$/, ''); | ||
| 16 | + | ||
| 17 | + // js-yaml.safeLoad() throws on error | ||
| 18 | + return yaml.safeLoad(text); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + exports.extractAndParseYAML = extractAndParseYAML; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,15 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - var processIncludes = require('./preprocess.js'); | ||
| 4 | - var fs = require('fs'); | ||
| 3 | + const processIncludes = require('./preprocess.js'); | ||
| 4 | + const fs = require('fs'); | ||
| 5 | 5 | ||
| 6 | 6 | // parse the args. | |
| 7 | 7 | // Don't use nopt or whatever for this. It's simple enough. | |
| 8 | 8 | ||
| 9 | - var args = process.argv.slice(2); | ||
| 10 | - var format = 'json'; | ||
| 11 | - var template = null; | ||
| 12 | - var inputFile = null; | ||
| 9 | + const args = process.argv.slice(2); | ||
| 10 | + let format = 'json'; | ||
| 11 | + let template = null; | ||
| 12 | + let inputFile = null; | ||
| 13 | 13 | ||
| 14 | 14 | args.forEach(function(arg) { | |
| 15 | 15 | if (!arg.match(/^\-\-/)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,11 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - var fs = require('fs'); | ||
| 4 | - var marked = require('marked'); | ||
| 5 | - var path = require('path'); | ||
| 6 | - var preprocess = require('./preprocess.js'); | ||
| 7 | - var typeParser = require('./type-parser.js'); | ||
| 3 | + const common = require('./common.js'); | ||
| 4 | + const fs = require('fs'); | ||
| 5 | + const marked = require('marked'); | ||
| 6 | + const path = require('path'); | ||
| 7 | + const preprocess = require('./preprocess.js'); | ||
| 8 | + const typeParser = require('./type-parser.js'); | ||
| 8 | 9 | ||
| 9 | 10 | module.exports = toHTML; | |
| 10 | 11 | ||
@@ -148,6 +149,9 @@ function parseLists(input) { | |||
| 148 | 149 | output.push(tok); | |
| 149 | 150 | return; | |
| 150 | 151 | } | |
| 152 | + if (tok.type === 'html' && common.isYAMLBlock(tok.text)) { | ||
| 153 | + tok.text = parseYAML(tok.text); | ||
| 154 | + } | ||
| 151 | 155 | state = null; | |
| 152 | 156 | output.push(tok); | |
| 153 | 157 | return; | |
@@ -174,6 +178,18 @@ function parseLists(input) { | |||
| 174 | 178 | return output; | |
| 175 | 179 | } | |
| 176 | 180 | ||
| 181 | + function parseYAML(text) { | ||
| 182 | + const meta = common.extractAndParseYAML(text); | ||
| 183 | + let html = '<div class="api_metadata">'; | ||
| 184 | + | ||
| 185 | + if (meta.added || meta.Added) { | ||
| 186 | + meta.added = meta.added || meta.Added; | ||
| 187 | + | ||
| 188 | + html += '<span>Added: ' + meta.added + '</span>'; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + return html + '</div>'; | ||
| 192 | + } | ||
| 177 | 193 | ||
| 178 | 194 | // Syscalls which appear in the docs, but which only exist in BSD / OSX | |
| 179 | 195 | var BSD_ONLY_SYSCALLS = new Set(['lchmod']); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,8 @@ module.exports = doJSON; | |||
| 5 | 5 | // Take the lexed input, and return a JSON-encoded object | |
| 6 | 6 | // A module looks like this: https://gist.github.com/1777387 | |
| 7 | 7 | ||
| 8 | - var marked = require('marked'); | ||
| 8 | + const common = require('./common.js'); | ||
| 9 | + const marked = require('marked'); | ||
| 9 | 10 | ||
| 10 | 11 | function doJSON(input, filename, cb) { | |
| 11 | 12 | var root = {source: filename}; | |
@@ -91,6 +92,8 @@ function doJSON(input, filename, cb) { | |||
| 91 | 92 | current.list = current.list || []; | |
| 92 | 93 | current.list.push(tok); | |
| 93 | 94 | current.list.level = 1; | |
| 95 | + } else if (type === 'html' && common.isYAMLBlock(tok.text)) { | ||
| 96 | + current.meta = parseYAML(tok.text); | ||
| 94 | 97 | } else { | |
| 95 | 98 | current.desc = current.desc || []; | |
| 96 | 99 | if (!Array.isArray(current.desc)) { | |
@@ -274,6 +277,9 @@ function processList(section) { | |||
| 274 | 277 | delete section.list; | |
| 275 | 278 | } | |
| 276 | 279 | ||
| 280 | + function parseYAML(text) { | ||
| 281 | + return common.extractAndParseYAML(text); | ||
| 282 | + } | ||
| 277 | 283 | ||
| 278 | 284 | // textRaw = "someobject.someMethod(a[, b=100][, c])" | |
| 279 | 285 | function parseSignature(text, sig) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments