Skip to content

Commit

Permalink
add documentation, guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
fewieden committed Apr 27, 2017
1 parent f06577d commit c0d4cdc
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .doclets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dir: .
packageJson: package.json
articles:
- Overview: README.md
- Developer: DEVELOPER.md
- Changelog: CHANGELOG.md
- License: LICENSE
branches:
- master
- develop
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contribution Guidelines

Thanks for contributing to this module!

Please create pull requests to the branch `develop`.

To hold one code style and standard there are several linters and tools in this project set. Make sure you fullfill the requirements.
Also there will be automatically analysis performed once you created the pull request.
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Platform (Hardware/OS):

Node version:

MagicMirror version:

Module version:

Description of the issue:
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Please create pull requests to the branch `develop`.

* Does the pull request solve an issue (add a reference)?
* What are the features of this pr?
* Add screenshots for visual changes.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.log
npm-debug.log*

node_modules/

.idea/

docs/
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MMM-voice Changelog

## [1.0.1]

### Added

* Code linter
* Documentation
* [Doclets.io](https://doclets.io/fewieden/MMM-voice/master) integration
* Contributing guidelines
* Issue template
* Pull request template
* Gitignore

### Changed

* Dependency manipulation exchanged to fork

## [1.0.0]

Initial version
96 changes: 92 additions & 4 deletions MMM-voice.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
/* Magic Mirror
* Module: MMM-voice
/**
* @file MMM-voice.js
*
* By fewieden https://github.com/fewieden/MMM-voice
* MIT Licensed.
* @author fewieden
* @license MIT
*
* @see https://github.com/fewieden/MMM-voice
*/

/* global Module Log MM */

/**
* @external Module
* @see https://github.com/MichMich/MagicMirror/blob/master/js/module.js
*/

/**
* @external Log
* @see https://github.com/MichMich/MagicMirror/blob/master/js/logger.js
*/

/**
* @external MM
* @see https://github.com/MichMich/MagicMirror/blob/master/js/main.js
*/

/**
* @module MMM-voice
* @description Frontend for the module to display data.
*
* @requires external:Module
* @requires external:Log
* @requires external:MM
*/
Module.register('MMM-voice', {

/** @member {string} icon - Microphone icon. */
icon: 'fa-microphone-slash',
/** @member {boolean} pulsing - Flag to indicate listening state. */
pulsing: true,
/** @member {boolean} help - Flag to switch between render help or not. */
help: false,

/**
* @member {Object} voice - Defines the default mode and commands of this module.
* @property {string} mode - Voice mode of this module.
* @property {string[]} sentences - List of voice commands of this module.
*/
voice: {
mode: 'VOICE',
sentences: [
Expand All @@ -25,25 +58,51 @@ Module.register('MMM-voice', {
]
},

/** @member {Object[]} modules - Set of all modules with mode and commands. */
modules: [],

/**
* @member {Object} defaults - Defines the default config values.
* @property {int} timeout - Seconds to active listen for commands.
* @property {string} keyword - Keyword to activate active listening.
* @property {boolean} debug - Flag to enable debug information.
*/
defaults: {
timeout: 15,
keyword: 'MAGIC MIRROR',
debug: false
},

/**
* @function start
* @description Sets mode to initialising.
* @override
*/
start() {
Log.info(`Starting module: ${this.name}`);
this.mode = this.translate('INIT');
this.modules.push(this.voice);
Log.info(`${this.name} is waiting for voice command registrations.`);
},

/**
* @function getStyles
* @description Style dependencies for this module.
* @override
*
* @returns {string[]} List of the style dependency filepaths.
*/
getStyles() {
return ['font-awesome.css', 'MMM-voice.css'];
},

/**
* @function getTranslations
* @description Translations for this module.
* @override
*
* @returns {Object.<string, string>} Available translations for this module (key: language code, value: filepath).
*/
getTranslations() {
return {
en: 'translations/en.json',
Expand All @@ -52,6 +111,13 @@ Module.register('MMM-voice', {
};
},

/**
* @function getDom
* @description Creates the UI as DOM for displaying in MagicMirror application.
* @override
*
* @returns {Element}
*/
getDom() {
const wrapper = document.createElement('div');
const voice = document.createElement('div');
Expand Down Expand Up @@ -97,6 +163,14 @@ Module.register('MMM-voice', {
return wrapper;
},

/**
* @function notificationReceived
* @description Handles incoming broadcasts from other modules or the MagicMirror core.
* @override
*
* @param {string} notification - Notification name
* @param {*} payload - Detailed payload of the notification.
*/
notificationReceived(notification, payload) {
if (notification === 'DOM_OBJECTS_CREATED') {
this.sendSocketNotification('START', { config: this.config, modules: this.modules });
Expand All @@ -107,6 +181,14 @@ Module.register('MMM-voice', {
}
},

/**
* @function socketNotificationReceived
* @description Handles incoming messages from node_helper.
* @override
*
* @param {string} notification - Notification name
* @param {*} payload - Detailed payload of the notification.
*/
socketNotificationReceived(notification, payload) {
if (notification === 'READY') {
this.icon = 'fa-microphone';
Expand Down Expand Up @@ -152,6 +234,12 @@ Module.register('MMM-voice', {
this.updateDom(300);
},

/**
* @function appendHelp
* @description Creates the UI for the voice command SHOW HELP.
*
* @param {Element} appendTo - DOM Element where the UI gets appended as child.
*/
appendHelp(appendTo) {
const title = document.createElement('h1');
title.classList.add('medium');
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MMM-voice [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/fewieden/MMM-voice/master/LICENSE) [![Build Status](https://travis-ci.org/fewieden/MMM-voice.svg?branch=master)](https://travis-ci.org/fewieden/MMM-voice) [![Code Climate](https://codeclimate.com/github/fewieden/MMM-voice/badges/gpa.svg?style=flat)](https://codeclimate.com/github/fewieden/MMM-voice) [![Known Vulnerabilities](https://snyk.io/test/github/fewieden/mmm-voice/badge.svg)](https://snyk.io/test/github/fewieden/mmm-voice)
# MMM-voice [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/fewieden/MMM-voice/master/LICENSE) [![Build Status](https://travis-ci.org/fewieden/MMM-voice.svg?branch=master)](https://travis-ci.org/fewieden/MMM-voice) [![Code Climate](https://codeclimate.com/github/fewieden/MMM-voice/badges/gpa.svg?style=flat)](https://codeclimate.com/github/fewieden/MMM-voice) [![Known Vulnerabilities](https://snyk.io/test/github/fewieden/mmm-voice/badge.svg)](https://snyk.io/test/github/fewieden/mmm-voice) [![API Doc](https://doclets.io/fewieden/MMM-voice/master.svg)](https://doclets.io/fewieden/MMM-voice/master)

Voice Recognition Module for MagicMirror<sup>2</sup>

Expand Down Expand Up @@ -69,6 +69,15 @@ To select a MODE, the specfic MODE has to be the first word of a COMMAND or righ
List of all supported modules in the [Wiki](https://github.com/fewieden/MMM-voice/wiki/Supported-Modules).
## Developers Guide
## Developer
If you want to support your own module, check out the [Documentation](https://github.com/fewieden/MMM-voice/blob/master/DEVELOPER.md) and add it to the [Wiki](https://github.com/fewieden/MMM-voice/wiki/Supported-Modules).
* `npm run lint` - Lints JS and CSS files.
* `npm run docs` - Generates documentation.
### Documentation
The documentation can be found [here](https://doclets.io/fewieden/MMM-voice/master)
### Developers Guide
If you want to support your own module, check out the [Guide](DEVELOPER.md) and add it to the [Wiki](https://github.com/fewieden/MMM-voice/wiki/Supported-Modules).
19 changes: 19 additions & 0 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"tags": {
"dictionaries": ["jsdoc"]
},
"source": {
"include": [
"package.json",
"README.md"
],
"exclude": [
"node_modules",
"Bytes.js"
]
},
"opts": {
"destination": "docs",
"recurse": true
}
}
Loading

0 comments on commit c0d4cdc

Please sign in to comment.