Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 4f49008

Browse files
committed
Update documentation
1 parent 4a4df80 commit 4f49008

3 files changed

Lines changed: 100 additions & 7 deletions

File tree

README.md

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,93 @@
1-
# feed-validator
2-
Simple validator for feeds or opensearch.xml based on validator.w3.org/feed
1+
# Feed validator
2+
Simple validator for feeds like RSS or Atom. Supports opensearch.xml validation.
3+
Based on validator.w3.org/feed
4+
5+
Supports plugins for custom checks
6+
7+
## Installation
8+
```
9+
npm install [-g] feed-validator
10+
```
11+
12+
## Usage
13+
```
14+
usage: opensearch-validator [-h] [-v] [-c FILE_PATH] [-r REPORTER_NAME]
15+
[--no-colors]
16+
url
17+
18+
Simple validator for RSS, Atom or opensearch.xml that using validator.w3.
19+
org/feed and plugins
20+
21+
Positional arguments:
22+
url Feed url to validate
23+
24+
Optional arguments:
25+
-h, --help Show this help message and exit.
26+
-v, --version Show program's version number and exit.
27+
-c FILE_PATH, --config FILE_PATH
28+
Config file path
29+
-r REPORTER_NAME, --reporter REPORTER_NAME
30+
Reporter name: text, json
31+
--no-colors Don't use colors
32+
```
33+
34+
## Arguments and options
35+
Options can be defined by command line and configuration file.
36+
37+
### url
38+
URL of the validated feed.
39+
40+
### config
41+
Configuration file. Can be passed from command line. Example of config file see in `examples` folder.
42+
43+
### reporter
44+
Reporter type: text or JSON. Can be defined in command line: `--reporter json` or in config file: `reporter: 'json'`
45+
46+
### noColors
47+
Don't use colors in report. Can be passed from command line: `--no-colors` and from config file: `noColors: true`.
48+
49+
### suppress
50+
You can suppress some messages by defining objects that contains fields to match in config file.
51+
Example of suppressing:
52+
```js
53+
suppress: [
54+
{level: 'error', text: 'Unexpected method attribute on Url element'},
55+
{level: 'warning', type: 'ShouldIncludeExample'}
56+
],
57+
```
58+
59+
### plugins
60+
Can be defined in config file (see `examples`). Each plugin is function that take JSON feed representation and returns errors,
61+
warnings and information messages list.
62+
63+
Plugin function example:
64+
```js
65+
/**
66+
* Check HTTPS in urls from opensearch.xml
67+
* @param {Object} feedJson Feed JSON representation
68+
* @param {Object} options Program options
69+
*/
70+
function checkHttps(feedJson, options) {
71+
var path = 'OpenSearchDescription.Url';
72+
var urls = _.get(feedJson, path);
73+
74+
var errors = [];
75+
if (!urls) {
76+
errors.push({level: 'error', path: path, text: 'No urls'});
77+
}
78+
79+
_.each(urls, function (item, i) {
80+
var url = _.get(item, '$.template');
81+
var type = _.get(item, '$.type');
82+
83+
var errPath = [path, i, '$.template'].join('.');
84+
if (!url) {
85+
errors.push({level: 'error', path: errPath, text: 'No url template for type ' + type});
86+
} else if (!/(https:)?\/\//.test(url)) {
87+
errors.push({level: 'error', path: errPath, text: 'Non HTTPS schema in type ' + type});
88+
}
89+
});
90+
return errors;
91+
}
92+
```
93+
You should define `level` and `text` fields. And you can define your own custom `type` field.

actions/cli/get-options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ var packageInfo = require('../../package.json');
1818
*/
1919
module.exports = function () {
2020
var parser = new ArgumentParser({
21+
prog: packageInfo.name,
22+
description: packageInfo.description,
2123
version: packageInfo.version,
2224
addHelp: true,
23-
description: packageInfo.description,
2425
epilog: 'Feed validator: Of Steamworks and Magick Obscura'
2526
});
2627
parser.addArgument(['-c', '--config'], {
@@ -35,7 +36,7 @@ module.exports = function () {
3536
required: false,
3637
defaultValue: 'text',
3738
choices: ['text', 'json'],
38-
help: 'Reporter name'
39+
help: 'Reporter name: text, json'
3940
});
4041
parser.addArgument(['--no-colors'], {
4142
action: 'storeTrue',

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Andrey Prokopyuk <andrey.prokopyuk@gmail.com>",
3-
"name": "opensearch-validator",
4-
"description": "Simple validator for opensearch.xml that using validator.w3.org/feed",
3+
"name": "feed-validator",
4+
"description": "Simple validator for RSS, Atom or opensearch.xml that using validator.w3.org/feed and plugins",
55
"version": "1.0.0",
66
"main": "cli/run.js",
77
"keywords": [
@@ -11,7 +11,8 @@
1111
"RSS",
1212
"Atom",
1313
"OpenSearch",
14-
"opensearch.xml"
14+
"opensearch.xml",
15+
"plugins"
1516
],
1617
"repository": {
1718
"type": "git",

0 commit comments

Comments
 (0)