cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/5] docs commit: CB-6751 Rewrite docs generation to use Node instead of Ruby (close #236)
Date Tue, 23 Dec 2014 16:21:13 GMT
Repository: cordova-docs
Updated Branches:
  refs/heads/master d1e1e6730 -> 455ed5998


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/455ed599/spec/cordova/yaml_front_matter_spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova/yaml_front_matter_spec.js b/spec/cordova/yaml_front_matter_spec.js
new file mode 100644
index 0000000..1e9b359
--- /dev/null
+++ b/spec/cordova/yaml_front_matter_spec.js
@@ -0,0 +1,67 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+/*jslint node: true */
+/*global describe, it, beforeEach, afterEach, after, before */
+(function () {
+    'use strict';
+    var assert = require("assert"),
+        path = require('path'),
+        fs = require('fs'),
+        cheerio = require('cheerio'),
+        YamlFrontMatter = require("../../lib/cordova/pre/yamlfrontmatter"),
+        SpecHelpers = require("../spec_helpers");
+
+    describe('YamlFrontMatter', function () {
+        var sut,
+            files;
+        
+        beforeEach(function (done) {
+            var tmp_directory = SpecHelpers.create_tmp_directory_assets(module.filename);
+            sut = new YamlFrontMatter();
+            files = {
+                'yaml': path.join(tmp_directory, 'has_yaml.md'),
+                'no_yaml': path.join(tmp_directory, 'no_yaml.md')
+            };
+            done();
+        });
+        
+        afterEach(function (done) {
+            SpecHelpers.remove_tmp_directory();
+            done();
+        });
+
+        it('should skip files with no YAML Front Matter', function () {
+            var expected_data = fs.readFileSync(files.no_yaml, "utf8"),
+                data,
+                actual_data;
+            data = sut.run(files.no_yaml);
+            assert.deepEqual({}, data);
+            actual_data = fs.readFileSync(files.no_yaml, "utf8");
+            assert.strictEqual(expected_data, actual_data);
+        });
+
+        it('should parse files with YAML Front Matter', function () {
+            var data = sut.run(files.yaml);
+            assert.deepEqual({
+                'platforms': 'Android, BlackBerry, iOS',
+                'type': 'Function'
+            }, data);
+        });
+    });
+}());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/455ed599/spec/file_helpers_spec.js
----------------------------------------------------------------------
diff --git a/spec/file_helpers_spec.js b/spec/file_helpers_spec.js
new file mode 100644
index 0000000..5eceb42
--- /dev/null
+++ b/spec/file_helpers_spec.js
@@ -0,0 +1,33 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+/*jslint node: true*/
+/*global describe, it, beforeEach */
+(function () {
+    'use strict';
+    var assert = require("assert"),
+        path = require('path'),
+        fs = require('fs'),
+        FileHelpers = require("../lib/file_helpers");
+
+    describe('FileHelpers', function () {
+        it('should have a default input directory that exists', function () {
+            assert.equal(true, fs.existsSync(FileHelpers.getDefaultInputDirectory()));
+        });
+    });
+}());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/455ed599/spec/spec_helpers.js
----------------------------------------------------------------------
diff --git a/spec/spec_helpers.js b/spec/spec_helpers.js
new file mode 100644
index 0000000..c61ae7a
--- /dev/null
+++ b/spec/spec_helpers.js
@@ -0,0 +1,100 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+/*jslint node: true */
+var fs = require("fs-extra");
+var path = require("path");
+var FileHelpers = require("../lib/file_helpers");
+
+var SpecHelpers = (function () {
+    'use strict';
+    
+    /**
+    * Creates a new instance of SpecHelpers
+    * @param options Options for the generation process.
+    */
+    function SpecHelpers() {
+    }
+    
+    SpecHelpers.create_tmp_directory_assets = function (reference_filename) {
+        var directories;
+        if (reference_filename === null || reference_filename === undefined) {
+            directories = {
+                source: SpecHelpers.docs_directory(),
+                destination: SpecHelpers.tmp_docs_directory()
+            };
+        } else {
+            directories = SpecHelpers.find_test_directories(reference_filename);
+        }
+
+        if (directories !== null) {
+            fs.copySync(directories.source, directories.destination);
+        }
+
+        return directories.destination;
+    };
+    
+    SpecHelpers.find_test_directories = function (filename) {
+        var extension = path.extname(filename),
+            source_directory = filename.replace(extension, ''),
+            destination_directory = path.join(SpecHelpers.tmp_directory(), path.basename(source_directory));
+    
+        if (!fs.existsSync(source_directory)) {
+            console.warn("The directory " + source_directory + " not present");
+            return null;
+        }
+        
+        return {
+            source: source_directory,
+            destination: destination_directory
+        };
+    };
+    
+    SpecHelpers.tmp_public_directory = function () {
+        return path.join(SpecHelpers.tmp_directory(), 'public');
+    };
+    
+    SpecHelpers.docs_directory = function () {
+        return FileHelpers.getDefaultInputDirectory();
+    };
+    
+    SpecHelpers.tmp_docs_directory = function () {
+        return path.join(SpecHelpers.tmp_directory(), 'docs');
+    };
+    
+    /**
+    * Gets temporary directory for running specs.
+    */
+    SpecHelpers.tmp_directory = function () {
+        return path.resolve(path.join(SpecHelpers.root_directory(), '..', 'tmp_spec'));
+    };
+    
+    /**
+    * Root directory for the project.
+    */
+    SpecHelpers.root_directory = function () {
+        return path.resolve(path.dirname(module.filename));
+    };
+    
+    SpecHelpers.remove_tmp_directory = function () {
+        fs.removeSync(SpecHelpers.tmp_directory());
+    };
+    
+    return SpecHelpers;
+}());
+module.exports = SpecHelpers;
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message