Skip to content

Commit

Permalink
add inline documentation with jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
csimi committed Mar 7, 2018
1 parent 61fa711 commit 2c3834f
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
docs
/dist
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
npm-debug.log*
docs
coverage
.nyc_output
/dist
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
npm-debug.log*
docs
coverage
.nyc_output
.babelrc
Expand Down
24 changes: 24 additions & 0 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"plugins": [],
"recurseDepth": 10,
"source": {
"include": [
"./src"
],
"includePattern": ".+\\.js(doc|x)?$"
},
"sourceType": "module",
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc", "closure"]
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
},
"opts": {
"encoding": "utf8",
"destination": "./docs",
"recurse": true
}
}
121 changes: 120 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elvoline/twig",
"version": "2.0.0",
"version": "2.0.1",
"description": "twig.js renderer for elvoline",
"module": "dist/es.js",
"main": "dist/index.js",
Expand All @@ -16,7 +16,8 @@
"posttest": "npm run coverage",
"coverage": "nyc report --reporter=lcov",
"codecov": "codecov",
"prepublish": "npm run build"
"prepublish": "npm run build",
"docs": "jsdoc -c jsdoc.json"
},
"author": "Elvoline S.à r.l.",
"license": "ISC",
Expand All @@ -43,6 +44,7 @@
"cross-env": "^5.1.1",
"eslint": "^4.12.0",
"jquery": "^3.2.1",
"jsdoc": "^3.5.5",
"jsdom": "^11.5.1",
"lodash": "^4.17.4",
"mocha": "^5.0.0",
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

This is a Twig.js renderer customized for use on Elvoline.

Added features include an always-on promise support, deferred template parsing, global variables, automatic DOM creation and i18n.
Added features are:

* always-on promise support
* deferred template parsing
* global variables
* automatic DOM creation
* i18n

# Docs

Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default [
getConfig({
'file': 'dist/index.js',
'format': 'cjs',
'exports': 'named',
}),
getConfig({
'file': 'dist/es.js',
Expand Down
25 changes: 23 additions & 2 deletions src/globals.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
/**
* Global variables module.
* @module
*/

/**
* Global variables to be added to render data.
* @type {Object}
*/

var globals = {};
export default globals;

/**
* Adds a new global variable.
* @param {string} - variable name
* @param {*} - variable value
* @return {*} The given variable value.
*/

export function addGlobal (key, value) {
return globals[key] = value;
}

/**
* Getter for the globals object.
* @return {Object} The globals object.
*/

export function getGlobals () {
return globals;
}

export default globals;
13 changes: 13 additions & 0 deletions src/jsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Represents the eventual result of an asynchronous operation.
* @external Promise
* @global
* @see {@link https://promisesaplus.com/}
*/

/**
* jQuery instance.
* @external jQuery
* @global
* @see {@link http://api.jquery.com/}
*/

0 comments on commit 2c3834f

Please sign in to comment.