Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes towards modularity #146

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules/
bower_components/
build/
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/grammar.js
47 changes: 7 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NODE_MODULES := node_modules/.bin
BOWER_COMPONENTS := bower_components

all: node_modules lint build/sequence-diagram-min.js test
all: node_modules lint build test

node_modules: package.json
#
Expand All @@ -16,7 +16,7 @@ bower_components: bower.json
#
# Bower update needed.
#
$(NODE_MODULES)/bower update
$(NODE_MODULES)/bower update -q
touch $@

dependencies: node_modules bower_components
Expand All @@ -28,13 +28,10 @@ veryclean: clean
-rm -rf node_modules
-rm -rf bower_components

lint: dependencies package.json bower.json
$(NODE_MODULES)/jshint --verbose src/*.js
$(NODE_MODULES)/jshint --verbose test/*.js
$(NODE_MODULES)/jsonlint package.json -q
$(NODE_MODULES)/jsonlint bower.json -q
lint:
npm run lint

test: dependencies build/sequence-diagram-min.js
test: dependencies build

# Test the un-minifed file (with underscore)
$(NODE_MODULES)/qunit \
Expand All @@ -60,38 +57,8 @@ test: dependencies build/sequence-diagram-min.js
-t test/*-tests.js \
-d test/raphael-mock.js $(BOWER_COMPONENTS)/lodash/lodash.min.js

build/grammar.js: src/grammar.jison
$(NODE_MODULES)/jison $< -o [email protected]

# After building the grammar, run it through the uglifyjs to fix some non-strict issues.
# Until https://github.com/zaach/jison/issues/285 is fixed, we must do this to create valid non-minified code.
$(NODE_MODULES)/uglifyjs \
[email protected] -o $@ \
--comments all --compress --beautify

build/diagram-grammar.js: src/diagram.js build/grammar.js
#
# Compiling grammar
#
$(NODE_MODULES)/preprocess $< . > $@

build/sequence-diagram.js: src/main.js build/diagram-grammar.js src/jquery-plugin.js fonts/daniel/daniel_700.font.js src/sequence-diagram.js
#
# Finally combine all javascript files together
#
$(NODE_MODULES)/preprocess $< . > $@

build/sequence-diagram-min.js build/sequence-diagram-min.js.map: build/sequence-diagram.js
#
# Please ignore the warnings below (these are in combined js code)
#
$(NODE_MODULES)/uglifyjs \
build/sequence-diagram.js \
-o build/sequence-diagram-min.js \
--compress --comments --lint \
--source-map build/sequence-diagram-min.js.map \
--source-map-url sequence-diagram-min.js.map

build:
npm run build
#
# Copy minified file to site
#
Expand Down
13 changes: 13 additions & 0 deletions build-grammar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// temporary solution of https://github.com/zaach/jison/issues/300
var Parser = require('jison').Parser;
var fs = require('fs');
var path = require('path');

var options = {
moduleMain: function() {}
};

var grammar = fs.readFileSync(path.join(__dirname, 'src/grammar.jison'), 'utf8');
var parser = new Parser(grammar);
var parserSource = parser.generate(options);
fs.writeFileSync(path.join(__dirname, 'src/grammar.js'), parserSource, 'utf8');
11 changes: 3 additions & 8 deletions build/sequence-diagram-min.js

Large diffs are not rendered by default.

Loading