diff --git a/apps/tests/Readme.md b/RunTests.md similarity index 100% rename from apps/tests/Readme.md rename to RunTests.md diff --git a/apps/tests/console-tests.ts b/apps/tests/console-tests.ts index dad848cee..beebefb07 100644 --- a/apps/tests/console-tests.ts +++ b/apps/tests/console-tests.ts @@ -1,70 +1,43 @@ export var test_DummyTestForSnippetOnly0 = function () { - // - // # Console - // ### Logging - // Logging to the console does not require the "console" module since the console variable is global. It can be used anywhere within your code. - // You can log your message in several different categories. - // ``` JavaScript - //// Verbously logs a message. + // >> console-log console.log("Hello, world!"); console.info("I am NativeScript"); console.warn("Low memory"); console.error("Uncaught Application Exception"); - // ``` - // + // << console-log } export var test_DummyTestForSnippetOnly1 = function () { - // - // ### Time - // ``` JavaScript - //// Begins counting a time span for a given name (key). + // >> console-time console.time("LoadTime"); - //// Do something... - //// Ends a previously started time span through the time method. + // << console-time + // >> console-timeEnd console.timeEnd("LoadTime"); - // ``` - // + // << console-timeEnd } export var test_DummyTestForSnippetOnly2 = function () { - // - // ### Assert - // ``` JavaScript - //// Asserts a boolean condition and prints a message in case the assert fails. + // >> console-assert console.assert(2 === 2, "2 equals 2"); - // ``` - // + // << console-assert } export var test_DummyTestForSnippetOnly3 = function () { - // - // ### Dir - // ``` JavaScript - //// Prints the state of the specified object to the console. + // >> console-dir var obj = {name: "John", age: 34}; console.dir(obj); - // ``` - // + // << console-dir } export var test_DummyTestForSnippetOnly4 = function () { - // - // ### Dump - // ``` JavaScript - //// Prints the state of the specified object to the console. + // >> console-dump var obj = { name: "John", age: 34 }; console.dump(obj); - // ``` - // + // << console-dump } export var test_DummyTestForSnippetOnly5 = function () { - // - // ### Trace - // ``` JavaScript - //// Prints the current stack trace in the console. + // >> console-trace console.trace(); - // ``` - // + // << console-traceß } \ No newline at end of file diff --git a/apps/tests/console.md b/apps/tests/console.md new file mode 100644 index 000000000..0accb7510 --- /dev/null +++ b/apps/tests/console.md @@ -0,0 +1,33 @@ +--- +nav-title: "console How-To" +title: "How-To" +description: "Examples for using console" +--- +# Console +### Logging +Logging to the console does not require the "console" module since the console variable is global. It can be used anywhere within your code. +You can log your message in several different categories. + + +### Time +Begins counting a time span for a given name (key). + + +Ends a previously started time span through the time method. + + +### Assert +Asserts a boolean condition and prints a message in case the assert fails. + + +### Dir +Prints the state of the specified object to the console. + + +### Dump +Prints the state of the specified object to the console. + + +### Trace +Prints the current stack trace in the console. + diff --git a/gruntfile.js b/gruntfile.js index 5bbbb56fd..6c358c93f 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -139,12 +139,14 @@ module.exports = function(grunt) { var localCfg = { srcDir: ".", srcAppsDir: "./apps", + srcAppsTests: "./apps/tests", packageJsonFilePath: "./package.json", outDir: "./bin/dist", + outArticlesDir: "./bin/dist/articles", outModulesDir: tsconfig.compilerOptions.outDir || "./bin/dist/modules", outAppsDir: "./bin/dist/apps", outTsAppsDir: "./bin/dist/ts-apps", - outApiRefDir: "./bin/dist/api-ref" + outApiRefDir: "./bin/dist/apiref" }; var nodeTestEnv = JSON.parse(JSON.stringify(process.env)); @@ -214,6 +216,12 @@ module.exports = function(grunt) { }, readyAppFiles: { src: [localCfg.outModulesDir + "/apps/**"] + }, + articles: { + src: [ localCfg.outArticlesDir ] + }, + "apiref": { + src: [ localCfg.outApiRefDir ] } }, copy: { @@ -228,6 +236,12 @@ module.exports = function(grunt) { dest: localCfg.outModulesDir, cwd: localCfg.srcDir }, + articleMDs: { + expand: true, + src: [ "**/*.md" ], + dest: localCfg.outArticlesDir, + cwd: localCfg.srcAppsTests + }, license: { expand: true, src: [ @@ -413,6 +427,9 @@ module.exports = function(grunt) { }, mochaNode: { cmd: "grunt simplemocha:node" + }, + injectArticles: { + cmd: "./node_modules/.bin/mdinject --root=<%= localCfg.srcAppsTests %> --docsroot=<%= localCfg.outArticlesDir %>" } }, multidest: { @@ -707,4 +724,20 @@ module.exports = function(grunt) { "ts:build-inplace", "generate-tns-core-modules-dev-dts" ]); + + grunt.registerTask("apiref", [ + "clean:apiref", + "typedoc:build" + ]); + + grunt.registerTask("articles", [ + "clean:articles", + "copy:articleMDs", + "exec:injectArticles" + ]); + + grunt.registerTask("docs", [ + "apiref", + "articles" + ]); }; diff --git a/package.json b/package.json index b35f8a24f..2497d75c8 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "grunt-ts": "5.3.2", "grunt-typedoc": "0.2.3", "grunt-untar": "0.0.1", + "markdown-snippet-injector": "^0.1.1", "mocha": "2.2.5", "shelljs": "0.5.3", "grunt-tslint": "3.0.3",