From b30d60e385b45dbb6396cc19dab2f4366df9bb39 Mon Sep 17 00:00:00 2001 From: jy95 Date: Wed, 30 Aug 2017 19:05:42 +0200 Subject: [PATCH] Docs: Make docs great --- .jsdoc.json | 2 + README.md | 60 ++++++------ docs/TorrentLibrary.html | 75 ++++++++------- docs/TorrentLibrary.js.html | 14 ++- docs/external-FileHound.html | 6 +- docs/external-Promise.html | 8 +- docs/external-access.html | 6 +- docs/external-basename.html | 6 +- docs/external-difference.html | 8 +- docs/external-nameParser.html | 8 +- docs/external-normalize.html | 148 +++++++++++++++++++++++++++++ docs/external-uniq.html | 8 +- docs/external-videosExtension.html | 8 +- docs/global.html | 50 +++++----- docs/index.html | 73 +++++++++++++- examples.md | 80 ++++++++++++++++ 16 files changed, 432 insertions(+), 128 deletions(-) create mode 100644 docs/external-normalize.html create mode 100644 examples.md diff --git a/.jsdoc.json b/.jsdoc.json index 9daee9e..352ea56 100644 --- a/.jsdoc.json +++ b/.jsdoc.json @@ -6,8 +6,10 @@ "source": { "include": [ "./src" ] }, + "plugins": ["plugins/markdown"], "opts": { "template": "node_modules/minami", + "readme": "examples.md", "encoding": "utf8", "destination": "./docs", "recurse": true diff --git a/README.md b/README.md index 77e71cb..4f24305 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,20 @@ # torrent-files-library [![Build Status](https://img.shields.io/travis/jy95/torrent-files-library.svg)](https://travis-ci.org/jy95/torrent-files-library) [![Coveralls branch](https://img.shields.io/coveralls/jy95/torrent-files-library/master.svg)](https://coveralls.io/github/jy95/torrent-files-library?branch=master) [![Dependency Status](https://img.shields.io/david/jy95/torrent-files-library.svg)](https://david-dm.org/jy95/torrent-files-library) [![Dev Dependency Status](https://img.shields.io/david/dev/jy95/torrent-files-library.svg)](https://david-dm.org/jy95/torrent-files-library?type=dev) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) > Enables to get a library of downloaded torrent files (movie or tv show) from a directory -WIP +## Installation -## Usage +For npm users : -### Get category for each file +```sh +$ npm install --save torrent-files-library +``` + +for Yarn : +```sh +$ yarn add torrent-files-library +``` + +## Demo ```node const TorrentLibrary = require("torrent-files-library"); @@ -43,38 +52,23 @@ libInstance ``` ![fileMappingDemo](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/fileMapping.gif) -### List found movies +## Documentation +For more examples and API details, see [API documentation](https://jy95.github.io/torrent-files-library/) -```node -const TorrentLibrary = require("torrent-files-library"); +## Test -let paths = [ - "D:\\DDL\\FILMS", // a path where I can find both movies and tv-series - "D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie -]; +``` +npm test +``` -// create an instance -let libInstance = new TorrentLibrary(); +To generate a test coverage report: -// add these paths inside this lib -libInstance - .addNewPath(...paths) - .then( (message) => { - console.log(message); - return libInstance.scan(); - }) - .then( (otherMessage) => { - console.log(otherMessage); - console.log("I found these movie(s) : "); - setTimeout(function(){ - // display the found movie(s) - for (let movie of libInstance.allMovies) { - console.log(movie.title + ((movie.year) ? " - " + movie.year : "") ); - } - }, 1000); - }) - .catch( (err) => { - console.log(err.message); - }); ``` -![foundMovies](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/foundMovies.gif) \ No newline at end of file +npm run coverage +``` +## Contributing + +* If you're unsure if a feature would make a good addition, you can always [create an issue](https://github.com/jy95/torrent-files-library/issues/new) first. +* We aim for 100% test coverage. Please write tests for any new functionality or changes. +* Any API changes should be fully documented. +* Be mindful of others when making suggestions and/or code reviewing. \ No newline at end of file diff --git a/docs/TorrentLibrary.html b/docs/TorrentLibrary.html index 5123d22..f366062 100644 --- a/docs/TorrentLibrary.html +++ b/docs/TorrentLibrary.html @@ -24,7 +24,7 @@
@@ -45,7 +45,7 @@

TorrentLibrary

-
Class representing the TorrentLibrary
+

Class representing the TorrentLibrary

@@ -67,7 +67,7 @@

new Tor
- Create a TorrentLibrary +

Create a TorrentLibrary

@@ -103,7 +103,7 @@

new Tor
Source:
@@ -180,7 +180,7 @@

(static)
- constant for movie category +

constant for movie category

@@ -219,7 +219,7 @@

(static)
Source:
@@ -247,7 +247,7 @@

(static) - constant for tv series category +

constant for tv series category

@@ -286,7 +286,7 @@

(static) Source:
@@ -314,7 +314,7 @@

catego
- Mapping filepath => category +

Mapping filepath => category

@@ -350,7 +350,7 @@

catego
Source:
@@ -393,7 +393,7 @@

defaultPat
- just an easy way to scan the current directory path, if not other paths provided +

just an easy way to scan the current directory path, if not other paths provided

@@ -434,7 +434,7 @@

defaultPat
Source:
@@ -472,7 +472,7 @@

paths - the paths where we are looking the media files +

the paths where we are looking the media files

@@ -513,7 +513,7 @@

pathsSource:
@@ -556,7 +556,7 @@

stores - The variable where we store all kind of media files found in paths +

The variable where we store all kind of media files found in paths

@@ -592,7 +592,7 @@

storesSource:
@@ -640,7 +640,7 @@

(static)
- Provides the array of files extensions considered to be media extensions +

Provides the array of files extensions considered to be media extensions

@@ -679,7 +679,7 @@

(static)
Source:
@@ -729,7 +729,7 @@
Returns:
- array of files extensions +

array of files extensions

@@ -758,7 +758,7 @@

addNewPath<
- Add the path(s) to be analyzed by the library if they exist and are readable +

Add the path(s) to be analyzed by the library if they exist and are readable

@@ -797,7 +797,7 @@

addNewPath<
Source:
@@ -870,7 +870,7 @@

Parameters:
- A or more path(s) +

A or more path(s)

@@ -911,7 +911,9 @@
Returns:
- On success the promise will be resolved with "All paths were added!"
On error the promise will be rejected with an Error object "Missing parameter" if the argument is missing
or an Error object from fs
+

On success the promise will be resolved with "All paths were added!"
+On error the promise will be rejected with an Error object "Missing parameter" if the argument is missing
+or an Error object from fs

@@ -940,7 +942,7 @@

a
- return the mapping between filepaths and category +

return the mapping between filepaths and category

@@ -979,7 +981,7 @@

a
Source:
@@ -1054,7 +1056,7 @@

allMovies - Getter for all found movies +

Getter for all found movies

@@ -1093,7 +1095,7 @@

allMoviesSource:
@@ -1168,7 +1170,7 @@

allTvSerie
- Getter for all found tv-series +

Getter for all found tv-series

@@ -1207,7 +1209,7 @@

allTvSerie
Source:
@@ -1282,7 +1284,7 @@

- Tell us if the user has provided us paths +

Tell us if the user has provided us paths

@@ -1321,7 +1323,7 @@

Source:
@@ -1371,7 +1373,7 @@

Returns:
- Has user provided us paths ? +

Has user provided us paths ?

@@ -1393,7 +1395,7 @@

scan - Scans the paths in search for new files to be added inside this lib +

Scans the paths in search for new files to be added inside this lib

@@ -1432,7 +1434,7 @@

scanSource:
@@ -1482,7 +1484,8 @@
Returns:
- On success the promise will be resolved with "Scanning completed"
On error the promise will be rejected with an Error object from sub modules
+

On success the promise will be resolved with "Scanning completed"
+On error the promise will be rejected with an Error object from sub modules

@@ -1509,7 +1512,7 @@
Returns:

- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:13 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/TorrentLibrary.js.html b/docs/TorrentLibrary.js.html index d1619dc..3668d89 100644 --- a/docs/TorrentLibrary.js.html +++ b/docs/TorrentLibrary.js.html @@ -24,7 +24,7 @@
@@ -126,6 +126,13 @@

TorrentLibrary.js

*/ import {basename} from 'path'; +/** + * Normalize method from module path (node) + * @external normalize + * @see {@link https://nodejs.org/api/path.html#path_path_normalize_path} + */ +import {normalize} from 'path'; + /** * uniq method from Lodash * @external uniq @@ -350,7 +357,8 @@

TorrentLibrary.js

return promisifiedAccess(path); }).then(function () { // keep only unique paths - that.paths = uniq([...that.paths, ...paths]); + // use normalize for cross plateform code + that.paths = uniq([...that.paths, ...paths.map(normalize)]); resolve("All paths were added!"); }).catch(e => { reject(e); @@ -518,7 +526,7 @@

TorrentLibrary.js


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-FileHound.html b/docs/external-FileHound.html index 34f3e10..2fc2e86 100644 --- a/docs/external-FileHound.html +++ b/docs/external-FileHound.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
module for exploring directories
+

module for exploring directories

@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-Promise.html b/docs/external-Promise.html index ee4d084..8f905c4 100644 --- a/docs/external-Promise.html +++ b/docs/external-Promise.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
A promise object provided by the bluebird promise library.
+

A promise object provided by the bluebird promise library.

@@ -87,7 +87,7 @@

Source:
@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-access.html b/docs/external-access.html index 86da8f4..38c8e61 100644 --- a/docs/external-access.html +++ b/docs/external-access.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
Access method from module fs (node)
+

Access method from module fs (node)

@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-basename.html b/docs/external-basename.html index 2370ebc..784905a 100644 --- a/docs/external-basename.html +++ b/docs/external-basename.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
Basename method from module path (node)
+

Basename method from module path (node)

@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-difference.html b/docs/external-difference.html index a384dd3..27f71e1 100644 --- a/docs/external-difference.html +++ b/docs/external-difference.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
difference method from lodash
+

difference method from lodash

@@ -87,7 +87,7 @@

Source:
@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-nameParser.html b/docs/external-nameParser.html index ffbf4d8..f3b38b6 100644 --- a/docs/external-nameParser.html +++ b/docs/external-nameParser.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
Parser for media files name
+

Parser for media files name

@@ -87,7 +87,7 @@

Source:
@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-normalize.html b/docs/external-normalize.html new file mode 100644 index 0000000..e659d1b --- /dev/null +++ b/docs/external-normalize.html @@ -0,0 +1,148 @@ + + + + + + normalize - Documentation + + + + + + + + + + + + + + + + + +
+ +

normalize

+ + + + + + + +
+ +
+ +

+ normalize +

+ + +
+ + + +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/external-uniq.html b/docs/external-uniq.html index 0b1d7da..732f45f 100644 --- a/docs/external-uniq.html +++ b/docs/external-uniq.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
uniq method from Lodash
+

uniq method from Lodash

@@ -87,7 +87,7 @@

Source:
@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/external-videosExtension.html b/docs/external-videosExtension.html index a6f2bb2..023ccb2 100644 --- a/docs/external-videosExtension.html +++ b/docs/external-videosExtension.html @@ -24,7 +24,7 @@
@@ -52,7 +52,7 @@

-
List of video file extensions
+

List of video file extensions

@@ -87,7 +87,7 @@

Source:
@@ -139,7 +139,7 @@


- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/global.html b/docs/global.html index 680a0d9..fadf79e 100644 --- a/docs/global.html +++ b/docs/global.html @@ -24,7 +24,7 @@
@@ -122,7 +122,7 @@

StoreVar

- The variable where we store all kind of media files found in paths +

The variable where we store all kind of media files found in paths

@@ -201,7 +201,7 @@

TPN

- The result of parsing file name +

The result of parsing file name

@@ -250,7 +250,7 @@
Properties:
- The file title +

The file title

@@ -278,7 +278,7 @@
Properties:
- The season number +

The season number

@@ -306,7 +306,7 @@
Properties:
- The episode number +

The episode number

@@ -334,7 +334,7 @@
Properties:
- The episode name +

The episode name

@@ -362,7 +362,7 @@
Properties:
- The year +

The year

@@ -390,7 +390,7 @@
Properties:
- The resolution +

The resolution

@@ -418,7 +418,7 @@
Properties:
- The quality +

The quality

@@ -446,7 +446,7 @@
Properties:
- The codec +

The codec

@@ -474,7 +474,7 @@
Properties:
- The audio +

The audio

@@ -502,7 +502,7 @@
Properties:
- The group that releases this file +

The group that releases this file

@@ -530,7 +530,7 @@
Properties:
- The quality +

The quality

@@ -558,7 +558,7 @@
Properties:
- extended ? +

extended ?

@@ -586,7 +586,7 @@
Properties:
- hardcoded ? +

hardcoded ?

@@ -614,7 +614,7 @@
Properties:
- proper ? +

proper ?

@@ -642,7 +642,7 @@
Properties:
- repack ? +

repack ?

@@ -670,7 +670,7 @@
Properties:
- The container +

The container

@@ -698,7 +698,7 @@
Properties:
- The website that releases this file +

The website that releases this file

@@ -726,7 +726,7 @@
Properties:
- The file language +

The file language

@@ -754,7 +754,7 @@
Properties:
- Unmatched text from filename +

Unmatched text from filename

@@ -840,7 +840,7 @@

TPN_Extended

- The extended TPN object +

The extended TPN object

@@ -889,7 +889,7 @@
Properties:
- additionnal property useful for this library +

additionnal property useful for this library

@@ -975,7 +975,7 @@
Type:

- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/docs/index.html b/docs/index.html index 5f56d06..4d58822 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,7 +24,7 @@
@@ -47,6 +47,75 @@ +
+

torrent-files-library Build Status Coveralls branch Dependency Status Dev Dependency Status License: MIT semantic-release

+

Enables to get a library of downloaded torrent files (movie or tv show) from a directory

+
+

Common examples

Get category for each file

const TorrentLibrary = require("torrent-files-library");
+
+let paths = [
+    "D:\\DDL\\FILMS", // a path where I can find both movies and tv-series
+    "D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie
+];
+
+// create an instance
+let libInstance = new TorrentLibrary();
+
+// add these paths inside this lib
+libInstance
+    .addNewPath(...paths)
+    .then( (message) => {
+        console.log(message);
+        return libInstance.scan();
+    })
+    .then( (otherMessage) => {
+        console.log(otherMessage);
+
+        setTimeout(function(){
+            // display the found files and their category
+            libInstance
+                .allFilesWithCategory
+                .forEach(function(value,key){
+                    console.log(key + " : " + value);
+                });
+        }, 1000);
+    })
+    .catch( (err) => {
+        console.log(err.message);
+    });

fileMappingDemo

+

List found movies

const TorrentLibrary = require("torrent-files-library");
+
+let paths = [
+    "D:\\DDL\\FILMS", // a path where I can find both movies and tv-series
+    "D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie
+];
+
+// create an instance
+let libInstance = new TorrentLibrary();
+
+// add these paths inside this lib
+libInstance
+    .addNewPath(...paths)
+    .then( (message) => {
+        console.log(message);
+        return libInstance.scan();
+    })
+    .then( (otherMessage) => {
+        console.log(otherMessage);
+        console.log("I found these movie(s) : ");
+        setTimeout(function(){
+            // display the found movie(s)
+            for (let movie of libInstance.allMovies) {
+                console.log(movie.title + ((movie.year) ? " - " + movie.year : "") + " at " + movie.filePath );
+            }
+        }, 1000);
+    })
+    .catch( (err) => {
+        console.log(err.message);
+    });

foundMovies

+

More example are comming ...

+
+ @@ -57,7 +126,7 @@
- Generated by JSDoc 3.5.4 on Sun Aug 27 2017 11:46:37 GMT+0200 (Romance Daylight Time) using the Minami theme. + Generated by JSDoc 3.5.4 on Wed Aug 30 2017 19:01:12 GMT+0200 (Romance Daylight Time) using the Minami theme.
diff --git a/examples.md b/examples.md new file mode 100644 index 0000000..3893df8 --- /dev/null +++ b/examples.md @@ -0,0 +1,80 @@ +# torrent-files-library [![Build Status](https://img.shields.io/travis/jy95/torrent-files-library.svg)](https://travis-ci.org/jy95/torrent-files-library) [![Coveralls branch](https://img.shields.io/coveralls/jy95/torrent-files-library/master.svg)](https://coveralls.io/github/jy95/torrent-files-library?branch=master) [![Dependency Status](https://img.shields.io/david/jy95/torrent-files-library.svg)](https://david-dm.org/jy95/torrent-files-library) [![Dev Dependency Status](https://img.shields.io/david/dev/jy95/torrent-files-library.svg)](https://david-dm.org/jy95/torrent-files-library?type=dev) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +> Enables to get a library of downloaded torrent files (movie or tv show) from a directory + +## Common examples + +### Get category for each file + +```node +const TorrentLibrary = require("torrent-files-library"); + +let paths = [ + "D:\\DDL\\FILMS", // a path where I can find both movies and tv-series + "D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie +]; + +// create an instance +let libInstance = new TorrentLibrary(); + +// add these paths inside this lib +libInstance + .addNewPath(...paths) + .then( (message) => { + console.log(message); + return libInstance.scan(); + }) + .then( (otherMessage) => { + console.log(otherMessage); + + setTimeout(function(){ + // display the found files and their category + libInstance + .allFilesWithCategory + .forEach(function(value,key){ + console.log(key + " : " + value); + }); + }, 1000); + }) + .catch( (err) => { + console.log(err.message); + }); +``` +![fileMappingDemo](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/fileMapping.gif) + +### List found movies + +```node +const TorrentLibrary = require("torrent-files-library"); + +let paths = [ + "D:\\DDL\\FILMS", // a path where I can find both movies and tv-series + "D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie +]; + +// create an instance +let libInstance = new TorrentLibrary(); + +// add these paths inside this lib +libInstance + .addNewPath(...paths) + .then( (message) => { + console.log(message); + return libInstance.scan(); + }) + .then( (otherMessage) => { + console.log(otherMessage); + console.log("I found these movie(s) : "); + setTimeout(function(){ + // display the found movie(s) + for (let movie of libInstance.allMovies) { + console.log(movie.title + ((movie.year) ? " - " + movie.year : "") + " at " + movie.filePath ); + } + }, 1000); + }) + .catch( (err) => { + console.log(err.message); + }); +``` +![foundMovies](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/foundMovies.gif) + +More example are comming ... \ No newline at end of file