Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "reference", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Generate documentation from JSON.", | ||
"main": "reference.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/michellebu/reference.git" | ||
}, | ||
"repository": "", | ||
"author": "Michelle Bu", | ||
"license": "BSD" | ||
"license": "BSD", | ||
"dependencies": { | ||
"yaml": "~0.2.3" | ||
} | ||
} |
@@ -6,2 +6,17 @@ # reference.js | ||
npm install reference | ||
## Usage | ||
```javascript | ||
var reference = require('reference'); | ||
var fs = require('fs'); | ||
var file = fs.readFileSync('./documentation.json', {anchor: true}); // adds permalinks/anchors for all headings. | ||
// also accepts yaml. | ||
// Generated HTML! | ||
var html = reference(file); | ||
``` | ||
## Expected style | ||
@@ -8,0 +23,0 @@ |
@@ -0,1 +1,3 @@ | ||
var yaml = require('yaml'); | ||
// TODO: eventually allow configurable yaml/json, html/md. | ||
@@ -5,7 +7,14 @@ function reference(file, options) { | ||
var components; | ||
try { | ||
var components = JSON.parse(file); | ||
components = JSON.parse(file); | ||
} catch (e) { | ||
throw new Error('Please pass in a JSON file buffer/string.'); | ||
try { | ||
components = yaml.eval(file); | ||
} catch (e) { | ||
} | ||
} | ||
if (!components || typeof components !== 'object') { | ||
throw new Error('Please pass in a JSON or YAML string.'); | ||
} | ||
@@ -12,0 +21,0 @@ return process(components, '', options.anchor); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1038311
18929
2
90
18
1
+ Addedyaml@~0.2.3
+ Addedyaml@0.2.3(transitive)